]> wimlib.net Git - wimlib/blobdiff - src/modify.c
Fix up calculation of image XML statistics
[wimlib] / src / modify.c
index d2b03abe88607c04666da6bea041b91eec06cd70..dc55d5fa8534ffc5ff0fcf0e7580e0511666bbd3 100644 (file)
@@ -44,7 +44,7 @@
  * the WIM image. */
 #define WIMLIB_ADD_IMAGE_FLAG_ROOT 0x80000000
 
-void destroy_image_metadata(struct image_metadata *imd,struct lookup_table *lt)
+void destroy_image_metadata(struct image_metadata *imd, struct lookup_table *lt)
 {
        free_dentry_tree(imd->root_dentry, lt);
        free_security_data(imd->security_data);
@@ -131,9 +131,9 @@ static int build_dentry_tree(struct dentry **root_ret, const char *root_disk_pat
        if (!root)
                return WIMLIB_ERR_NOMEM;
 
-       stbuf_to_dentry(&root_stbuf, root);
+       stbuf_to_inode(&root_stbuf, root->d_inode);
        add_flags &= ~WIMLIB_ADD_IMAGE_FLAG_ROOT;
-       root->inode->resolved = true;
+       root->d_inode->resolved = true;
 
        if (dentry_is_directory(root)) {
                /* Open the directory on disk */
@@ -184,7 +184,7 @@ static int build_dentry_tree(struct dentry **root_ret, const char *root_disk_pat
                }
                deref_name_buf[deref_name_len] = '\0';
                DEBUG("Read symlink `%s'", deref_name_buf);
-               ret = inode_set_symlink(root->inode, deref_name_buf,
+               ret = inode_set_symlink(root->d_inode, deref_name_buf,
                                        lookup_table, NULL);
        } else {
                /* Regular file */
@@ -226,7 +226,7 @@ static int build_dentry_tree(struct dentry **root_ret, const char *root_disk_pat
                        copy_hash(lte->hash, hash);
                        lookup_table_insert(lookup_table, lte);
                }
-               root->inode->lte = lte;
+               root->d_inode->lte = lte;
        }
 out:
        *root_ret = root;
@@ -249,19 +249,21 @@ struct wim_pair {
 static int add_lte_to_dest_wim(struct dentry *dentry, void *arg)
 {
        WIMStruct *src_wim, *dest_wim;
+       struct inode *inode;
 
        src_wim = ((struct wim_pair*)arg)->src_wim;
        dest_wim = ((struct wim_pair*)arg)->dest_wim;
+       inode = dentry->d_inode;
 
-       wimlib_assert(!dentry->inode->resolved);
+       wimlib_assert(!inode->resolved);
 
-       for (unsigned i = 0; i < (unsigned)dentry->inode->num_ads + 1; i++) {
+       for (unsigned i = 0; i <= inode->num_ads; i++) {
                struct lookup_table_entry *src_lte, *dest_lte;
-               src_lte = inode_stream_lte_unresolved(dentry->inode, i,
+               src_lte = inode_stream_lte_unresolved(inode, i,
                                                      src_wim->lookup_table);
                if (!src_lte)
                        continue;
-               dest_lte = inode_stream_lte_unresolved(dentry->inode, i,
+               dest_lte = inode_stream_lte_unresolved(inode, i,
                                                       dest_wim->lookup_table);
                if (dest_lte) {
                        dest_lte->refcnt++;
@@ -805,7 +807,7 @@ int do_add_image(WIMStruct *w, const char *dir, const char *name,
        struct dentry *root_dentry = NULL;
        struct wim_security_data *sd;
        struct capture_config config;
-       struct inode_table *inode_tab;
+       struct inode_table inode_tab;
        struct hlist_head inode_list;
        int ret;
 
@@ -871,11 +873,15 @@ int do_add_image(WIMStruct *w, const char *dir, const char *name,
                goto out_free_dentry_tree;
 
        DEBUG("Inserting dentries into inode table");
-       for_dentry_in_tree(root_dentry, inode_table_insert, inode_tab);
+       ret = init_inode_table(&inode_tab, 9001);
+       if (ret != 0)
+               goto out_destroy_imd;
+
+       for_dentry_in_tree(root_dentry, inode_table_insert, &inode_tab);
 
-       DEBUG("Cleanup up the hard link groups");
-       ret = fix_inodes(inode_tab, &inode_list);
-       free_inode_table(inode_tab);
+       DEBUG("Cleaning up the hard link groups");
+       ret = fix_inodes(&inode_tab, &inode_list);
+       destroy_inode_table(&inode_tab);
        if (ret != 0)
                goto out_destroy_imd;
 
@@ -885,7 +891,7 @@ int do_add_image(WIMStruct *w, const char *dir, const char *name,
        if (flags & WIMLIB_ADD_IMAGE_FLAG_BOOT)
                wimlib_set_boot_idx(w, w->hdr.image_count);
 
-       ret = xml_add_image(w, root_dentry, name);
+       ret = xml_add_image(w, name);
        if (ret != 0)
                goto out_destroy_imd;