From: Eric Biggers Date: Fri, 14 Mar 2014 20:45:13 +0000 (-0500) Subject: inode_fixup.c: Don't check ADS count when all have zero hashes X-Git-Tag: v1.6.2~22 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=50e2715272c44a059f9726f5558782d796a0df8f;hp=fafad622d2727848834f0a0803bec6c09bc8d743 inode_fixup.c: Don't check ADS count when all have zero hashes --- diff --git a/src/inode_fixup.c b/src/inode_fixup.c index 07feb074..23d171f2 100644 --- a/src/inode_fixup.c +++ b/src/inode_fixup.c @@ -97,27 +97,49 @@ ref_inodes_consistent(const struct wim_inode * restrict ref_inode_1, return true; } +/* Returns true iff the specified inode has any data streams with nonzero hash. + */ +static bool +inode_has_data_streams(const struct wim_inode *inode) +{ + for (unsigned i = 0; i <= inode->i_num_ads; i++) + if (!is_zero_hash(inode_stream_hash(inode, i))) + return true; + return false; +} + +/* Returns true iff the specified dentry has any data streams with nonzero hash. + */ static bool -inodes_consistent(const struct wim_inode * restrict ref_inode, - const struct wim_inode * restrict inode) +dentry_has_data_streams(const struct wim_dentry *dentry) { - wimlib_assert(ref_inode != inode); + return inode_has_data_streams(dentry->d_inode); +} - if (ref_inode->i_num_ads != inode->i_num_ads && - inode->i_num_ads != 0) +static bool +inodes_consistent(const struct wim_inode *ref_inode, + const struct wim_inode *inode) +{ + if (ref_inode->i_security_id != inode->i_security_id) return false; - if (ref_inode->i_security_id != inode->i_security_id - || ref_inode->i_attributes != inode->i_attributes) + + if (ref_inode->i_attributes != inode->i_attributes) return false; - for (unsigned i = 0; i <= min(ref_inode->i_num_ads, inode->i_num_ads); i++) { - const u8 *ref_hash, *hash; - ref_hash = inode_stream_hash(ref_inode, i); - hash = inode_stream_hash(inode, i); - if (!hashes_equal(ref_hash, hash) && !is_zero_hash(hash)) - return false; - if (i && !ads_entries_have_same_name(&ref_inode->i_ads_entries[i - 1], - &inode->i_ads_entries[i - 1])) + + if (inode_has_data_streams(inode)) { + if (ref_inode->i_num_ads != inode->i_num_ads) return false; + for (unsigned i = 0; i <= ref_inode->i_num_ads; i++) { + const u8 *ref_hash, *hash; + + ref_hash = inode_stream_hash(ref_inode, i); + hash = inode_stream_hash(inode, i); + if (!hashes_equal(ref_hash, hash) && !is_zero_hash(hash)) + return false; + if (i && !ads_entries_have_same_name(&ref_inode->i_ads_entries[i - 1], + &inode->i_ads_entries[i - 1])) + return false; + } } return true; } @@ -171,20 +193,6 @@ fix_true_inode(struct wim_inode *inode, struct list_head *inode_list) return 0; } -/* Returns true iff the specified dentry has any data streams with nonzero hash. - */ -static bool -dentry_has_data_streams(const struct wim_dentry *dentry) -{ - const struct wim_inode *inode = dentry->d_inode; - for (unsigned i = 0; i <= inode->i_num_ads; i++) { - const u8 *hash = inode_stream_hash(inode, i); - if (!is_zero_hash(hash)) - return true; - } - return false; -} - /* * Fixes up a nominal inode. *