]> wimlib.net Git - wimlib/commitdiff
wim_inode: Move file descriptors table into union
authorEric Biggers <ebiggers3@gmail.com>
Wed, 22 May 2013 23:44:44 +0000 (18:44 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 22 May 2013 23:44:44 +0000 (18:44 -0500)
include/wimlib/dentry.h
src/dentry.c
src/mount_image.c

index a571e0213f93c93b5885bdf401b301895a7edee0..a6aa31d7488e66434761a98a77d2214b5660ef7d 100644 (file)
@@ -368,17 +368,21 @@ struct wim_inode {
                 * Freed and set to NULL after the extraction is done (either
                 * success or failure).  */
                tchar *i_extracted_file;
                 * Freed and set to NULL after the extraction is done (either
                 * success or failure).  */
                tchar *i_extracted_file;
+
+#ifdef WITH_FUSE
+               /* Used only during image mount:  Table of file descriptors that
+                * have been opened to this inode.  The table is automatically
+                * freed when the last file descriptor is closed.  */
+               struct {
+                       struct wimfs_fd **i_fds;
+                       u16 i_num_opened_fds;
+                       u16 i_num_allocated_fds;
+               };
+#endif
        };
 
        /* Next alternate data stream ID to be assigned */
        u32 i_next_stream_id;
        };
 
        /* Next alternate data stream ID to be assigned */
        u32 i_next_stream_id;
-
-#ifdef WITH_FUSE
-       /* wimfs file descriptors table for the inode */
-       u16 i_num_opened_fds;
-       u16 i_num_allocated_fds;
-       struct wimfs_fd **i_fds;
-#endif
 };
 
 #define inode_for_each_dentry(dentry, inode) \
 };
 
 #define inode_for_each_dentry(dentry, inode) \
index 70250a7f049b6e546fbca0dac8894e41aba9de85..fb430eca1c798e537bb65de14d55aa29c0678a2b 100644 (file)
@@ -1121,10 +1121,6 @@ free_inode(struct wim_inode *inode)
                                destroy_ads_entry(&inode->i_ads_entries[i]);
                        FREE(inode->i_ads_entries);
                }
                                destroy_ads_entry(&inode->i_ads_entries[i]);
                        FREE(inode->i_ads_entries);
                }
-       #ifdef WITH_FUSE
-               wimlib_assert(inode->i_num_opened_fds == 0);
-               FREE(inode->i_fds);
-       #endif
                /* HACK: This may instead delete the inode from i_list, but the
                 * hlist_del() behaves the same as list_del(). */
                if (!hlist_unhashed(&inode->i_hlist))
                /* HACK: This may instead delete the inode from i_list, but the
                 * hlist_del() behaves the same as list_del(). */
                if (!hlist_unhashed(&inode->i_hlist))
index d9a03a998febc11e2ecc2bb932d956a164be8551..ac914618cd5166fe8851545998fad613ccf113da 100644 (file)
@@ -259,8 +259,13 @@ inode_put_fd(struct wim_inode *inode, struct wimfs_fd *fd)
 
        inode->i_fds[fd->idx] = NULL;
        FREE(fd);
 
        inode->i_fds[fd->idx] = NULL;
        FREE(fd);
-       if (--inode->i_num_opened_fds == 0 && inode->i_nlink == 0)
-               free_inode(inode);
+       if (--inode->i_num_opened_fds == 0) {
+               FREE(inode->i_fds);
+               inode->i_fds = NULL;
+               inode->i_num_allocated_fds = 0;
+               if (inode->i_nlink == 0)
+                       free_inode(inode);
+       }
 }
 
 static int
 }
 
 static int