- return entry_1->stream_name_nbytes == entry_2->stream_name_nbytes &&
- memcmp(entry_1->stream_name, entry_2->stream_name,
- entry_1->stream_name_nbytes) == 0;
-}
-
-static bool
-ref_inodes_consistent(const struct wim_inode * restrict ref_inode_1,
- const struct wim_inode * restrict ref_inode_2)
-{
- wimlib_assert(ref_inode_1 != ref_inode_2);
-
- if (ref_inode_1->i_num_ads != ref_inode_2->i_num_ads)
- return false;
- if (ref_inode_1->i_security_id != ref_inode_2->i_security_id
- || ref_inode_1->i_attributes != ref_inode_2->i_attributes)
- return false;
- for (unsigned i = 0; i <= ref_inode_1->i_num_ads; i++) {
- const u8 *ref_1_hash, *ref_2_hash;
- ref_1_hash = inode_stream_hash(ref_inode_1, i);
- ref_2_hash = inode_stream_hash(ref_inode_2, i);
- if (!hashes_equal(ref_1_hash, ref_2_hash))
- return false;
- if (i && !ads_entries_have_same_name(&ref_inode_1->i_ads_entries[i - 1],
- &ref_inode_2->i_ads_entries[i - 1]))
- return false;
-
- }
- return true;
-}
-
-static bool
-inodes_consistent(const struct wim_inode * restrict ref_inode,
- const struct wim_inode * restrict inode)
-{
- wimlib_assert(ref_inode != inode);
-
- if (ref_inode->i_num_ads != inode->i_num_ads &&
- inode->i_num_ads != 0)
- return false;
- if (ref_inode->i_security_id != inode->i_security_id
- || 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]))
- return false;
- }
- return true;
+ /* This certainly isn't the only thing we need to check to make sure the
+ * inodes are consistent. However, this seems to be the only thing that
+ * the MS implementation checks when working around its own bug.
+ *
+ * (Tested: If two dentries share the same hard link group ID, Windows
+ * 8.1 DISM will link them if they have the same unnamed stream hash,
+ * even if the dentries provide different timestamps, attributes,
+ * alternate data streams, and security IDs! And the one that gets used
+ * will change if you merely swap the filenames. But if you use
+ * different unnamed stream hashes with everything else the same, it
+ * doesn't link the dentries.)
+ *
+ * For non-buggy WIMs this function will always return true. */
+ return hashes_equal(inode_get_hash_of_unnamed_data_stream(inode_1),
+ inode_get_hash_of_unnamed_data_stream(inode_2));