From: Eric Biggers Date: Sat, 18 Aug 2012 05:27:32 +0000 (-0500) Subject: dentry_hash() function to get hash of default data stream X-Git-Tag: v1.0.0~146 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=7dd2950f78510a0d1d4a9e464d5164b3566ccbee dentry_hash() function to get hash of default data stream --- diff --git a/src/dentry.h b/src/dentry.h index ac4454f9..e9fef475 100644 --- a/src/dentry.h +++ b/src/dentry.h @@ -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); diff --git a/src/extract.c b/src/extract.c index 80549a6b..a04e3f2e 100644 --- a/src/extract.c +++ b/src/extract.c @@ -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