]> wimlib.net Git - wimlib/blobdiff - include/wimlib/inode.h
Update progress functions
[wimlib] / include / wimlib / inode.h
index 468bdbac1ff28cc05310eabe92809d163848348e..9a94ce2fd8adff6a59da17b722c728e29b5f2c71 100644 (file)
@@ -4,7 +4,6 @@
 #include "wimlib/assert.h"
 #include "wimlib/list.h"
 #include "wimlib/lookup_table.h"
-#include "wimlib/rbtree.h"
 #include "wimlib/sha1.h"
 #include "wimlib/unix_data.h"
 
@@ -15,6 +14,7 @@ struct wim_dentry;
 struct wim_security_data;
 struct wim_lookup_table;
 struct wimfs_fd;
+struct avl_tree_node;
 
 /*
  * WIM inode.
@@ -47,13 +47,17 @@ struct wim_inode {
         * this inode. */
        u32 i_attributes;
 
-       /* Root of a red-black tree storing the child dentries of this inode, if
-        * any.  Keyed by wim_dentry->file_name, case sensitively. */
-       struct rb_root i_children;
+       /* Root of a balanced binary search tree storing the child directory
+        * entries of this inode, if any.  Keyed by wim_dentry->file_name, case
+        * sensitively.  If this inode is not a directory or if it has no
+        * children then this will be an empty tree (NULL).  */
+       struct avl_tree_node *i_children;
 
-       /* Root of a red-black tree storing the children of this inode, if any.
-        * Keyed by wim_dentry->file_name, case insensitively. */
-       struct rb_root i_children_case_insensitive;
+       /* Root of a balanced binary search tree storing the child directory
+        * entries of this inode, if any.  Keyed by wim_dentry->file_name, case
+        * insensitively.  If this inode is not a directory or if it has no
+        * children then this will be an empty tree (NULL).  */
+       struct avl_tree_node *i_children_ci;
 
        /* List of dentries that are aliases for this inode.  There will be
         * i_nlink dentries in this list.  */
@@ -61,10 +65,10 @@ struct wim_inode {
 
        /* Field to place this inode into a list. */
        union {
-               /* Hash list node- used in hardlink.c when the inodes are placed
-                * into a hash table keyed by inode number and optionally device
-                * number, in order to detect dentries that are aliases for the
-                * same inode. */
+               /* Hash list node- used in inode_fixup.c when the inodes are
+                * placed into a hash table keyed by inode number and optionally
+                * device number, in order to detect dentries that are aliases
+                * for the same inode. */
                struct hlist_node i_hlist;
 
                /* Normal list node- used to connect all the inodes of a WIM image
@@ -95,9 +99,6 @@ struct wim_inode {
         * error paths.  */
        u8 i_visited : 1;
 
-       /* Set if the DOS name of an inode has already been extracted.  */
-       u8 i_dos_name_extracted : 1;
-
        /* 1 iff all ADS entries of this inode are named or if this inode
         * has no ADS entries  */
        u8 i_canonical_streams : 1;
@@ -141,6 +142,9 @@ struct wim_inode {
         * wim_dentry_on_disk'.  */
        u64 i_ino;
 
+       /* UNIX data (wimlib extension)  */
+       struct wimlib_unix_data i_unix_data;
+
        union {
                /* Device number, used only during image capture, so we can
                 * identify hard linked files by the combination of inode number
@@ -149,19 +153,22 @@ struct wim_inode {
                 * to 0 otherwise.  */
                u64 i_devno;
 
+               /* Fields used only during extraction  */
                struct {
-
-                       /* Used only during image extraction: pointer to the first path
-                        * (malloc()ed buffer) at which this inode has been extracted.
-                        * Freed and set to NULL after the extraction is done (either
-                        * success or failure).  */
-                       tchar *i_extracted_file;
-
-                       /** Used only during image extraction: "cookie" that
-                        * identifies this extracted file (inode), for example
-                        * an inode number.  Only used if supported by the
-                        * extraction mode.  */
-                       u64 extract_cookie;
+                       /* List of aliases of this dentry that are being
+                        * extracted in the current extraction operation.  This
+                        * will be a (possibly nonproper) subset of the dentries
+                        * in the i_dentry list.  This list will be constructed
+                        * regardless of whether the extraction backend supports
+                        * hard links or not.  */
+                       struct list_head i_extraction_aliases;
+
+               #ifdef WITH_NTFS_3G
+                       /* In NTFS-3g extraction mode, this is set to the Master
+                        * File Table (MFT) number of the NTFS file that was
+                        * created for this inode.  */
+                       u64 i_mft_no;
+               #endif
                };
 
 #ifdef WITH_FUSE
@@ -233,7 +240,7 @@ struct wim_ads_entry_on_disk {
        le16 stream_name_nbytes;
 
        /* Stream name in UTF-16LE.  It is @stream_name_nbytes bytes long,
-        * excluding the the null terminator.  There is a null terminator
+        * excluding the null terminator.  There is a null terminator
         * character if @stream_name_nbytes != 0; i.e., if this stream is named.
         * */
        utf16lechar stream_name[];
@@ -332,18 +339,15 @@ inode_remove_ads(struct wim_inode *inode, u16 idx,
                 struct wim_lookup_table *lookup_table);
 
 static inline bool
-ads_entry_is_unix_data(const struct wim_ads_entry *entry)
+ads_entry_is_named_stream(const struct wim_ads_entry *entry)
 {
-       return (entry->stream_name_nbytes ==
-                       WIMLIB_UNIX_DATA_TAG_UTF16LE_NBYTES) &&
-               !memcmp(entry->stream_name, WIMLIB_UNIX_DATA_TAG_UTF16LE,
-                       WIMLIB_UNIX_DATA_TAG_UTF16LE_NBYTES);
+       return entry->stream_name_nbytes != 0;
 }
 
 static inline bool
-ads_entry_is_named_stream(const struct wim_ads_entry *entry)
+inode_has_unix_data(const struct wim_inode *inode)
 {
-       return entry->stream_name_nbytes != 0 && !ads_entry_is_unix_data(entry);
+       return inode->i_unix_data.mode != 0;
 }
 
 /* Is the inode a directory?
@@ -382,12 +386,12 @@ inode_is_symlink(const struct wim_inode *inode)
 
 /* Does the inode have children?
  * Currently (based on read_dentry_tree()), this can only return true for inodes
- * for which inode_is_directory() returns true.  However, if a directory is
- * empty, this returns false.  */
+ * for which inode_is_directory() returns true.  (This also returns false on
+ * empty directories.)  */
 static inline bool
 inode_has_children(const struct wim_inode *inode)
 {
-       return inode->i_children.rb_node != NULL;
+       return inode->i_children != NULL;
 }
 
 extern int
@@ -504,6 +508,10 @@ verify_inode(struct wim_inode *inode, const struct wim_security_data *sd);
 extern void
 inode_ref_streams(struct wim_inode *inode);
 
+extern void
+inode_unref_streams(struct wim_inode *inode,
+                   struct wim_lookup_table *lookup_table);
+
 /* inode_fixup.c  */
 extern int
 dentry_tree_fix_inodes(struct wim_dentry *root, struct list_head *inode_list);