]> wimlib.net Git - wimlib/blobdiff - src/resource.c
Remove link_dentry()
[wimlib] / src / resource.c
index 013f9ec5145e44e54efa26ccb06923675e323506..f21fd5148355ab2c0920980a4e45306a66f9139e 100644 (file)
@@ -504,11 +504,8 @@ int read_wim_resource(const struct lookup_table_entry *lte, u8 buf[],
                wimlib_assert(lte->ntfs_loc != NULL);
                wimlib_assert(lte->attr != NULL);
                {
-                       u64 adjusted_offset;
                        if (lte->ntfs_loc->is_reparse_point)
-                               adjusted_offset = offset + 8;
-                       else
-                               adjusted_offset = offset;
+                               offset += 8;
                        if (ntfs_attr_pread(lte->attr, offset, size, buf) != size) {
                                ERROR_WITH_ERRNO("Error reading NTFS attribute "
                                                 "at `%s'",
@@ -1203,7 +1200,7 @@ int read_metadata_resource(WIMStruct *w, struct image_metadata *imd)
        if (ret != 0)
                goto out_free_buf;
 
-       dentry_offset = imd->security_data->total_length + 7 & ~7;
+       dentry_offset = (imd->security_data->total_length + 7) & ~7;
 
        if (dentry_offset == 0) {
                ERROR("Integer overflow while reading metadata resource");
@@ -1222,10 +1219,9 @@ int read_metadata_resource(WIMStruct *w, struct image_metadata *imd)
 
        ret = read_dentry(buf, metadata_len, dentry_offset, dentry);
 
-       /* This is the root dentry, so set its pointers correctly. */
+       /* This is the root dentry, so set its parent to itself. */
        dentry->parent = dentry;
-       dentry->next   = dentry;
-       dentry->prev   = dentry;
+
        if (ret != 0)
                goto out_free_dentry_tree;
        inode_add_dentry(dentry, dentry->d_inode);
@@ -1288,7 +1284,6 @@ int write_metadata_resource(WIMStruct *w)
        struct lookup_table_entry *lte;
        u64 metadata_original_size;
        const struct wim_security_data *sd;
-       const unsigned random_tail_len = 20;
 
        DEBUG("Writing metadata resource for image %d", w->current_image);
 
@@ -1314,7 +1309,7 @@ int write_metadata_resource(WIMStruct *w)
        calculate_subdir_offsets(root, &subdir_offset);
 
        /* Total length of the metadata resource (uncompressed) */
-       metadata_original_size = subdir_offset + random_tail_len;
+       metadata_original_size = subdir_offset;
 
        /* Allocate a buffer to contain the uncompressed metadata resource */
        buf = MALLOC(metadata_original_size);
@@ -1330,18 +1325,9 @@ int write_metadata_resource(WIMStruct *w)
        /* Write the dentry tree into the resource buffer */
        p = write_dentry_tree(root, p);
 
-       /*
-        * Append 20 random bytes to the metadata resource so that we don't have
-        * identical metadata resources if we happen to append exactly the same
-        * image twice without any changes in timestamps.  If this were to
-        * happen, it would cause confusion about the number and order of images
-        * in the WIM.
-        */
-       randomize_byte_array(p, random_tail_len);
-
        /* We MUST have exactly filled the buffer; otherwise we calculated its
         * size incorrectly or wrote the data incorrectly. */
-       wimlib_assert(p - buf + random_tail_len == metadata_original_size);
+       wimlib_assert(p - buf == metadata_original_size);
 
        /* Get the lookup table entry for the metadata resource so we can update
         * it. */
@@ -1362,14 +1348,17 @@ int write_metadata_resource(WIMStruct *w)
 
        /* It's very likely the SHA1 message digest of the metadata resource
         * changed, so re-insert the lookup table entry into the lookup table.
+        *
+        * We do not check for other lookup table entries having the same SHA1
+        * message digest.  It's possible for 2 absolutely identical images to
+        * be added, therefore causing 2 identical metadata resources to be in
+        * the WIM.  However, in this case, it's expected for 2 separate lookup
+        * table entries to be created, even though this doesn't make a whole
+        * lot of sense since they will share the same SHA1 message digest.
         * */
        lookup_table_unlink(w->lookup_table, lte);
        lookup_table_insert(w->lookup_table, lte);
 
-       /* We do not allow a metadata resource to be referenced multiple times,
-        * and the 20 random bytes appended to it should make it extremely
-        * likely for each metadata resource to be unique, even if the exact
-        * same image is captured. */
        wimlib_assert(lte->out_refcnt == 0);
        lte->out_refcnt = 1;