]> wimlib.net Git - wimlib/blobdiff - src/ntfs-3g_apply.c
Support file counts for extract file structure and metadata progress
[wimlib] / src / ntfs-3g_apply.c
index d1cebb9cd1fa05f8ae7d052830a5263c6ebdbd40..db289684589ef4b78f1b05107dc53a0ae75c9237 100644 (file)
@@ -425,7 +425,7 @@ ntfs_3g_set_metadata(ntfs_inode *ni, const struct wim_inode *inode,
  * the NTFS inode @dir_ni.  */
 static int
 ntfs_3g_create_dirs_recursive(ntfs_inode *dir_ni, struct wim_dentry *dir,
-                             const struct ntfs_3g_apply_ctx *ctx)
+                             struct ntfs_3g_apply_ctx *ctx)
 {
        struct wim_dentry *child;
 
@@ -448,7 +448,9 @@ ntfs_3g_create_dirs_recursive(ntfs_inode *dir_ni, struct wim_dentry *dir,
 
                child->d_inode->i_mft_no = ni->mft_no;
 
-               ret = ntfs_3g_set_metadata(ni, child->d_inode, ctx);
+               ret = report_file_created(&ctx->common);
+               if (!ret)
+                       ret = ntfs_3g_set_metadata(ni, child->d_inode, ctx);
                if (!ret)
                        ret = ntfs_3g_create_any_empty_ads(ni, child->d_inode, ctx);
                if (!ret)
@@ -470,7 +472,7 @@ ntfs_3g_create_dirs_recursive(ntfs_inode *dir_ni, struct wim_dentry *dir,
 static int
 ntfs_3g_create_directories(struct wim_dentry *root,
                           struct list_head *dentry_list,
-                          const struct ntfs_3g_apply_ctx *ctx)
+                          struct ntfs_3g_apply_ctx *ctx)
 {
        ntfs_inode *root_ni;
        int ret;
@@ -504,6 +506,9 @@ ntfs_3g_create_directories(struct wim_dentry *root,
                ret = ntfs_3g_restore_dos_name(NULL, NULL, dentry, ctx->vol);
                if (ret)
                        return ret;
+               ret = report_file_created(&ctx->common);
+               if (ret)
+                       return ret;
        }
        return 0;
 }
@@ -660,7 +665,7 @@ out_close_ni:
  * Directories must have already been created.  */
 static int
 ntfs_3g_create_nondirectories(struct list_head *dentry_list,
-                             const struct ntfs_3g_apply_ctx *ctx)
+                             struct ntfs_3g_apply_ctx *ctx)
 {
        struct wim_dentry *dentry;
        struct wim_inode *inode;
@@ -670,9 +675,12 @@ ntfs_3g_create_nondirectories(struct list_head *dentry_list,
                inode = dentry->d_inode;
                if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY)
                        continue;
-               if (dentry != inode_first_extraction_dentry(inode))
-                       continue;
-               ret = ntfs_3g_create_nondirectory(inode, ctx);
+               if (dentry == inode_first_extraction_dentry(inode)) {
+                       ret = ntfs_3g_create_nondirectory(inode, ctx);
+                       if (ret)
+                               return ret;
+               }
+               ret = report_file_created(&ctx->common);
                if (ret)
                        return ret;
        }
@@ -883,6 +891,25 @@ out:
        return ret;
 }
 
+static uint64_t
+ntfs_3g_count_dentries(const struct list_head *dentry_list)
+{
+       const struct wim_dentry *dentry;
+       uint64_t count = 0;
+
+       list_for_each_entry(dentry, dentry_list, d_extraction_list_node) {
+               count++;
+               if ((dentry->d_inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) &&
+                   dentry_has_short_name(dentry))
+               {
+                       count++;
+               }
+
+       }
+
+       return count;
+}
+
 static int
 ntfs_3g_extract(struct list_head *dentry_list, struct apply_ctx *_ctx)
 {
@@ -908,6 +935,11 @@ ntfs_3g_extract(struct list_head *dentry_list, struct apply_ctx *_ctx)
        /* Create all inodes and aliases, including short names, and set
         * metadata (attributes, security descriptors, and timestamps).  */
 
+       ret = start_file_structure_phase(&ctx->common,
+                                        ntfs_3g_count_dentries(dentry_list));
+       if (ret)
+               goto out_unmount;
+
        ret = ntfs_3g_create_directories(root, dentry_list, ctx);
        if (ret)
                goto out_unmount;
@@ -916,6 +948,10 @@ ntfs_3g_extract(struct list_head *dentry_list, struct apply_ctx *_ctx)
        if (ret)
                goto out_unmount;
 
+       ret = end_file_structure_phase(&ctx->common);
+       if (ret)
+               goto out_unmount;
+
        /* Extract streams.  */
        struct read_stream_list_callbacks cbs = {
                .begin_stream      = ntfs_3g_begin_extract_stream,