X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fntfs-capture.c;h=aa4458c04095fe073b17de2591e919846eb5868d;hp=fb670dc0183845e08f8e2349bc1c8b4cc6434295;hb=3cf06a471de65b5e69b44c41b95b1bbfb49ab55f;hpb=0541069de2f74283d44ebb02372b60fb608795f2 diff --git a/src/ntfs-capture.c b/src/ntfs-capture.c index fb670dc0..aa4458c0 100644 --- a/src/ntfs-capture.c +++ b/src/ntfs-capture.c @@ -27,15 +27,12 @@ #include "config.h" -#ifdef WITH_NTFS_3G #include #include -#endif #include "wimlib_internal.h" -#ifdef WITH_NTFS_3G #include "dentry.h" #include "lookup_table.h" #include "io.h" @@ -408,7 +405,8 @@ struct readdir_ctx { struct sd_set *sd_set; const struct capture_config *config; ntfs_volume **ntfs_vol_p; - int flags; + int add_image_flags; + wimlib_progress_func_t progress_func; }; static int @@ -419,7 +417,8 @@ build_dentry_tree_ntfs_recursive(struct dentry **root_p, ntfs_inode *dir_ni, struct sd_set *sd_set, const struct capture_config *config, ntfs_volume **ntfs_vol_p, - int flags); + int add_image_flags, + wimlib_progress_func_t progress_func); static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name, const int name_len, const int name_type, @@ -466,7 +465,8 @@ static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name, ni, ctx->path, path_len, name_type, ctx->lookup_table, ctx->sd_set, ctx->config, ctx->ntfs_vol_p, - ctx->flags); + ctx->add_image_flags, + ctx->progress_func); if (child) dentry_add_child(ctx->parent, child); @@ -509,7 +509,8 @@ static int build_dentry_tree_ntfs_recursive(struct dentry **root_p, struct sd_set *sd_set, const struct capture_config *config, ntfs_volume **ntfs_vol_p, - int flags) + int add_image_flags, + wimlib_progress_func_t progress_func) { u32 attributes; int mrec_flags; @@ -517,6 +518,19 @@ static int build_dentry_tree_ntfs_recursive(struct dentry **root_p, char dos_name_utf8[64]; struct dentry *root; + if (exclude_path(path, config, false)) { + if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE) + && progress_func) + { + union wimlib_progress_info info; + info.scan.cur_path = path; + info.scan.excluded = true; + progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); + } + *root_p = NULL; + return 0; + } + mrec_flags = ni->mrec->flags; struct SECURITY_CONTEXT ctx; memset(&ctx, 0, sizeof(ctx)); @@ -530,23 +544,15 @@ static int build_dentry_tree_ntfs_recursive(struct dentry **root_p, return WIMLIB_ERR_NTFS_3G; } - if (exclude_path(path, config, false)) { - if (flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE) { - const char *file_type; - if (attributes & MFT_RECORD_IS_DIRECTORY) - file_type = "directory"; - else - file_type = "file"; - printf("Excluding %s `%s' from capture\n", - file_type, path); - } - *root_p = NULL; - return 0; + if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE) + && progress_func) + { + union wimlib_progress_info info; + info.scan.cur_path = path; + info.scan.excluded = false; + progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); } - if (flags & WIMLIB_ADD_IMAGE_FLAG_VERBOSE) - printf("Scanning `%s'\n", path); - root = new_dentry_with_timeless_inode(path_basename(path)); if (!root) return WIMLIB_ERR_NOMEM; @@ -599,7 +605,8 @@ static int build_dentry_tree_ntfs_recursive(struct dentry **root_p, .sd_set = sd_set, .config = config, .ntfs_vol_p = ntfs_vol_p, - .flags = flags, + .add_image_flags = add_image_flags, + .progress_func = progress_func, }; ret = ntfs_readdir(ni, &pos, &ctx, wim_ntfs_capture_filldir); if (ret != 0) { @@ -646,13 +653,14 @@ static int build_dentry_tree_ntfs_recursive(struct dentry **root_p, return ret; } -static int build_dentry_tree_ntfs(struct dentry **root_p, - const char *device, - struct lookup_table *lookup_table, - struct wim_security_data *sd, - const struct capture_config *config, - int flags, - void *extra_arg) +int build_dentry_tree_ntfs(struct dentry **root_p, + const char *device, + struct lookup_table *lookup_table, + struct wim_security_data *sd, + const struct capture_config *config, + int add_image_flags, + wimlib_progress_func_t progress_func, + void *extra_arg) { ntfs_volume *vol; ntfs_inode *root_ni; @@ -700,7 +708,8 @@ static int build_dentry_tree_ntfs(struct dentry **root_p, ret = build_dentry_tree_ntfs_recursive(root_p, NULL, root_ni, path, 1, FILE_NAME_POSIX, lookup_table, &sd_set, config, ntfs_vol_p, - flags); + add_image_flags, + progress_func); out_cleanup: FREE(path); ntfs_inode_close(root_ni); @@ -721,34 +730,3 @@ out: } return ret; } - - - -WIMLIBAPI int wimlib_add_image_from_ntfs_volume(WIMStruct *w, - const char *device, - const char *name, - const char *config_str, - size_t config_len, - int flags) -{ - if (flags & (WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE)) { - ERROR("Cannot dereference files when capturing directly from NTFS"); - return WIMLIB_ERR_INVALID_PARAM; - } - return do_add_image(w, device, name, config_str, config_len, flags, - build_dentry_tree_ntfs, &w->ntfs_vol); -} - -#else /* WITH_NTFS_3G */ -WIMLIBAPI int wimlib_add_image_from_ntfs_volume(WIMStruct *w, - const char *device, - const char *name, - const char *config_str, - size_t config_len, - int flags) -{ - ERROR("wimlib was compiled without support for NTFS-3g, so"); - ERROR("we cannot capture a WIM image directly from a NTFS volume"); - return WIMLIB_ERR_UNSUPPORTED; -} -#endif /* WITH_NTFS_3G */