]> wimlib.net Git - wimlib/blobdiff - include/wimlib/dentry.h
Improve handling of invalid filenames
[wimlib] / include / wimlib / dentry.h
index e67eb5b5ec60bdc74c427bddf47de1f6f59ca3e6..e515abec732b26c722d83c0b10ecad362a71c331 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _WIMLIB_DENTRY_H
 #define _WIMLIB_DENTRY_H
 
+#include "wimlib/compiler.h"
 #include "wimlib/list.h"
 #include "wimlib/rbtree.h"
 #include "wimlib/sha1.h"
@@ -21,10 +22,6 @@ struct wim_inode;
 /* Size of the struct wim_dentry up to and including the file_name_len. */
 #define WIM_DENTRY_DISK_SIZE    102
 
-/* Size of on-disk WIM alternate data stream entry, in bytes, up to and
- * including the stream length field (see below). */
-#define WIM_ADS_ENTRY_DISK_SIZE 38
-
 /*
  * Reparse tags documented at
  * http://msdn.microsoft.com/en-us/library/dd541667(v=prot.10).aspx
@@ -73,19 +70,20 @@ struct wim_ads_entry {
        };
 
        /* Length of UTF16-encoded stream name, in bytes, not including the
-        * terminating null character. */
+        * terminating null character; or 0 if the stream is unnamed. */
        u16 stream_name_nbytes;
 
        /* Number to identify an alternate data stream even after it's possibly
         * been moved or renamed. */
        u32 stream_id;
 
-       /* Stream name (UTF-16LE) */
+       /* Stream name (UTF-16LE), null-terminated, or NULL if the stream is
+        * unnamed.  */
        utf16lechar *stream_name;
 
-       /* Unused field.  We read it into memory so we can write it out
+       /* Reserved field.  We read it into memory so we can write it out
         * unchanged. */
-       u64 unused;
+       u64 reserved;
 };
 
 
@@ -130,9 +128,20 @@ struct wim_dentry {
        /* The inode for this dentry */
        struct wim_inode *d_inode;
 
-       /* Red-black tree of sibling dentries */
+       /* Node for the parent's red-black tree of child dentries, sorted by
+        * case sensitive long name. */
        struct rb_node rb_node;
 
+#ifdef __WIN32__
+       /* Node for the parent's red-black tree of child dentries, sorted by
+        * case insensitive long name. */
+       struct rb_node rb_node_case_insensitive;
+
+       /* List of dentries in a directory that have different case sensitive
+        * long names but share the same case insensitive long name */
+       struct list_head case_insensitive_conflict_list;
+#endif
+
        /* Length of UTF-16LE encoded short filename, in bytes, not including
         * the terminating zero wide-character. */
        u16 short_name_nbytes;
@@ -151,6 +160,8 @@ struct wim_dentry {
        /* Only used during NTFS capture */
        u8 is_win32_name : 1;
 
+       u8 not_extracted : 1;
+
        /* Temporary list */
        struct list_head tmp_list;
 
@@ -186,14 +197,25 @@ struct wim_dentry {
         * points. */
        u64 subdir_offset;
 
+       u64 d_unused_1;
+       u64 d_unused_2;
+
        /* Pointer to the UTF-16LE short filename (malloc()ed buffer) */
        utf16lechar *short_name;
 
        /* Pointer to the UTF-16LE filename (malloc()ed buffer). */
        utf16lechar *file_name;
 
-       /* Full path of this dentry */
+       /* Full path of this dentry in the WIM */
        tchar *_full_path;
+
+       /* Actual name to extract this dentry as. */
+       tchar *extraction_name;
+       size_t extraction_name_nchars;
+
+       /* List head for building a list of dentries that contain a certain
+        * stream. */
+       struct list_head extraction_stream_list;
 };
 
 #define rbnode_dentry(node) container_of(node, struct wim_dentry, rb_node)
@@ -245,17 +267,21 @@ struct wim_inode {
 
        /* Unused/unknown fields that we just read into memory so we can
         * re-write them unchanged.  */
-       u64 i_unused_1;
-       u64 i_unused_2;
        u32 i_rp_unknown_1;
        u16 i_rp_unknown_2;
 
-       /* A hash of the file's contents, or a pointer to the lookup table entry
-        * for this dentry if the lookup table entries have been resolved.
+       /* If i_resolved == 0:
+        *      SHA1 message digest of the contents of the unnamed-data stream
+        *      of this inode, or all zeroes if this inode has no unnamed data
+        *      stream, or optionally all zeroes if this inode has an empty
+        *      unnamed data stream.
         *
-        * More specifically, this is for the un-named default file stream, as
-        * opposed to the alternate (named) file streams, which may have their
-        * own lookup table entries.  */
+        * If i_resolved == 1:
+        *      Pointer to the lookup table entry for the unnamed data stream
+        *      of this inode, or NULL if this inode has no unnamed data stream,
+        *      or optionally all zeroes if this inode has an empty unnamed data
+        *      stream.
+        */
        union {
                u8 i_hash[SHA1_HASH_SIZE];
                struct wim_lookup_table_entry *i_lte;
@@ -294,6 +320,10 @@ struct wim_inode {
         * noted in the @attributes field.) */
        struct rb_root i_children;
 
+#ifdef __WIN32__
+       struct rb_root i_children_case_insensitive;
+#endif
+
        /* Next alternate data stream ID to be assigned */
        u32 i_next_stream_id;
 
@@ -382,6 +412,9 @@ print_dentry(struct wim_dentry *dentry, void *lookup_table);
 extern int
 print_dentry_full_path(struct wim_dentry *entry, void *ignore);
 
+extern int
+calculate_dentry_full_path(struct wim_dentry *dentry);
+
 extern int
 calculate_dentry_tree_full_paths(struct wim_dentry *root);
 
@@ -389,7 +422,7 @@ extern tchar *
 dentry_full_path(struct wim_dentry *dentry);
 
 extern struct wim_inode *
-new_timeless_inode(void);
+new_timeless_inode(void) _malloc_attribute;
 
 extern int
 new_dentry(const tchar *name, struct wim_dentry **dentry_ret);
@@ -462,7 +495,7 @@ struct wimlib_unix_data {
        u16 uid;
        u16 gid;
        u16 mode;
-} PACKED;
+} _packed_attribute;
 
 #ifndef __WIN32__
 
@@ -484,10 +517,9 @@ inode_set_unix_data(struct wim_inode *inode, uid_t uid, gid_t gid, mode_t mode,
 #endif
 
 extern int
-read_dentry(const u8 metadata_resource[], u64 metadata_resource_len,
+read_dentry(const u8 *metadata_resource, u64 metadata_resource_len,
            u64 offset, struct wim_dentry *dentry);
 
-
 extern int
 read_dentry_tree(const u8 metadata_resource[], u64 metadata_resource_len,
                 struct wim_dentry *dentry);