]> wimlib.net Git - wimlib/commitdiff
dentry_hash() function to get hash of default data stream
authorEric Biggers <ebiggers3@gmail.com>
Sat, 18 Aug 2012 05:27:32 +0000 (00:27 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 18 Aug 2012 05:27:32 +0000 (00:27 -0500)
src/dentry.h
src/extract.c

index ac4454f9e442bc014232468a42c6ba03c050bc92..e9fef47530636d322b43f97c6d979508d1a821c2 100644 (file)
@@ -175,6 +175,19 @@ struct dentry {
        int refcnt;
 };
 
+/* Return hash of the "unnamed" (default) data stream. */
+static inline const u8 *dentry_hash(const struct dentry *dentry)
+{
+       /* If there are alternate data streams, the dentry hash field is zeroed
+        * out, and we need to find the hash in the un-named data stream (should
+        * be the first one, but check them in order just in case, and fall back
+        * to the dentry hash field if we can't find an unnamed data stream). */
+       for (u16 i = 0; i < dentry->num_ads; i++)
+               if (dentry->ads_entries[i].stream_name_len == 0)
+                       return dentry->ads_entries[i].hash;
+       return dentry->hash;
+}
+
 extern u64 dentry_total_length(const struct dentry *dentry);
 
 extern void stbuf_to_dentry(const struct stat *stbuf, struct dentry *dentry);
index 80549a6b7df39db616f1b83f40906955c585bd3d..a04e3f2ea81dc96c8c0704677255ed9c73b25e07 100644 (file)
@@ -97,7 +97,7 @@ static int extract_regular_file(WIMStruct *w,
        int out_fd;
        const struct resource_entry *res_entry;
 
-       lte = lookup_resource(w->lookup_table, dentry->hash);
+       lte = lookup_resource(w->lookup_table, dentry_hash(dentry));
 
        /* If we already extracted the same file or a hard link copy of it, we
         * may be able to simply create a link.  The exact action is specified