From: Eric Biggers Date: Sat, 17 Aug 2013 18:03:04 +0000 (-0500) Subject: Exclude unsupported files from capture X-Git-Tag: v1.5.0~58 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=9db1bdc721081a2dead6a60cba77dfb9bdad5ceb Exclude unsupported files from capture --- diff --git a/include/wimlib.h b/include/wimlib.h index 8ba21758..eb8a33ba 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -421,9 +421,19 @@ union wimlib_progress_info { * */ const wimlib_tchar *cur_path; - /** True iff @p cur_path is being excluded from the image - * capture due to the capture configuration file. */ - bool excluded; + enum { + /** File or directory looks okay and will be captured. */ + WIMLIB_SCAN_DENTRY_OK = 0, + + /** File or directory is being excluded from capture due + * to the capture configuration file. */ + WIMLIB_SCAN_DENTRY_EXCLUDED, + + /** File or directory is being excluded from capture due + * to being unsupported (e.g. an encrypted or device + * file). */ + WIMLIB_SCAN_DENTRY_UNSUPPORTED, + } status; /** Target path in the WIM. Only valid on messages * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and @@ -1373,7 +1383,6 @@ enum wimlib_error_code { WIMLIB_ERR_SET_SECURITY, WIMLIB_ERR_SET_SHORT_NAME, WIMLIB_ERR_SET_TIMESTAMPS, - WIMLIB_ERR_SPECIAL_FILE, WIMLIB_ERR_SPLIT_INVALID, WIMLIB_ERR_SPLIT_UNSUPPORTED, WIMLIB_ERR_STAT, diff --git a/programs/imagex.c b/programs/imagex.c index 90b53dd6..9f3939c3 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -1032,10 +1032,18 @@ imagex_progress_func(enum wimlib_progress_msg msg, } break; case WIMLIB_PROGRESS_MSG_SCAN_DENTRY: - if (info->scan.excluded) - imagex_printf(T("Excluding \"%"TS"\" from capture\n"), info->scan.cur_path); - else + switch (info->scan.status) { + case WIMLIB_SCAN_DENTRY_OK: imagex_printf(T("Scanning \"%"TS"\"\n"), info->scan.cur_path); + break; + case WIMLIB_SCAN_DENTRY_EXCLUDED: + imagex_printf(T("Excluding \"%"TS"\" from capture\n"), info->scan.cur_path); + break; + case WIMLIB_SCAN_DENTRY_UNSUPPORTED: + imagex_printf(T("WARNING: Excluding unsupported file or directory\n" + " \"%"TS"\" from capture\n"), info->scan.cur_path); + break; + } break; case WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY: unit_shift = get_unit(info->integrity.total_bytes, &unit_name); diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index 10d4bcc5..27c446a0 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -557,7 +557,7 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret, { union wimlib_progress_info info; info.scan.cur_path = path; - info.scan.excluded = true; + info.scan.status = WIMLIB_SCAN_DENTRY_EXCLUDED; params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); } root = NULL; @@ -572,12 +572,28 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret, return WIMLIB_ERR_NTFS_3G; } + if ((attributes & (FILE_ATTRIBUTE_DIRECTORY | + FILE_ATTRIBUTE_ENCRYPTED)) == FILE_ATTRIBUTE_ENCRYPTED) + { + if ((params->add_flags & WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE) + && params->progress_func) + { + union wimlib_progress_info info; + info.scan.cur_path = path; + info.scan.status = WIMLIB_SCAN_DENTRY_UNSUPPORTED; + params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); + } + root = NULL; + ret = 0; + goto out; + } + if ((params->add_flags & WIMLIB_ADD_FLAG_VERBOSE) && params->progress_func) { union wimlib_progress_info info; info.scan.cur_path = path; - info.scan.excluded = false; + info.scan.status = WIMLIB_SCAN_DENTRY_OK; params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); } diff --git a/src/unix_capture.c b/src/unix_capture.c index 906920a8..a080e8cb 100644 --- a/src/unix_capture.c +++ b/src/unix_capture.c @@ -210,7 +210,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret, { union wimlib_progress_info info; info.scan.cur_path = path; - info.scan.excluded = true; + info.scan.status = WIMLIB_SCAN_DENTRY_EXCLUDED; params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); } goto out; @@ -221,7 +221,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret, { union wimlib_progress_info info; info.scan.cur_path = path; - info.scan.excluded = false; + info.scan.status = WIMLIB_SCAN_DENTRY_OK; params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); } @@ -241,9 +241,14 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret, } if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode) && !S_ISLNK(stbuf.st_mode)) { - ERROR("`%s' is not a regular file, directory, or symbolic link.", - path); - ret = WIMLIB_ERR_SPECIAL_FILE; + if ((params->add_flags & WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE) + && params->progress_func) + { + union wimlib_progress_info info; + info.scan.cur_path = path; + info.scan.status = WIMLIB_SCAN_DENTRY_UNSUPPORTED; + params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); + } goto out; } diff --git a/src/util.c b/src/util.c index 640f8b32..8cb5777d 100644 --- a/src/util.c +++ b/src/util.c @@ -390,8 +390,6 @@ static const tchar *error_strings[] = { = T("Failed to set short name on extracted file"), [WIMLIB_ERR_SET_TIMESTAMPS] = T("Failed to set timestamps on extracted file"), - [WIMLIB_ERR_SPECIAL_FILE] - = T("Encountered a special file that cannot be archived"), [WIMLIB_ERR_SPLIT_INVALID] = T("The WIM is part of an invalid split WIM"), [WIMLIB_ERR_SPLIT_UNSUPPORTED] diff --git a/src/win32_capture.c b/src/win32_capture.c index 9b16796a..cf116399 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -944,7 +944,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret, { union wimlib_progress_info info; info.scan.cur_path = path; - info.scan.excluded = true; + info.scan.status = WIMLIB_SCAN_DENTRY_EXCLUDED; params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); } ret = 0; @@ -968,7 +968,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret, { union wimlib_progress_info info; info.scan.cur_path = path; - info.scan.excluded = false; + info.scan.status = WIMLIB_SCAN_DENTRY_OK; params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info); }