From: Eric Biggers Date: Thu, 16 Jan 2014 02:02:07 +0000 (-0600) Subject: Add support for not extracting file attributes X-Git-Tag: v1.6.1~27 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=2f1f50993984f88df675f0c3302cf4fa52982f05 Add support for not extracting file attributes --- diff --git a/doc/imagex-apply.1.in b/doc/imagex-apply.1.in index 1b76adb0..6043d025 100644 --- a/doc/imagex-apply.1.in +++ b/doc/imagex-apply.1.in @@ -352,6 +352,9 @@ combined with \fB--unix-data\fR to cause \fB@IMAGEX_PROGNAME@\fR to fail immediately if the UNIX owner, group, or mode on an extracted file cannot be set for any reason. .TP +\fB--no-attributes\fR +Do not restore Windows file attributes such as readonly, hidden, etc. +.TP \fB--include-invalid-names\fR Extract files and directories with invalid names by replacing characters and appending a suffix rather than ignoring them. Exactly what is considered an diff --git a/doc/imagex-extract.1.in b/doc/imagex-extract.1.in index 38886915..9a9e1592 100644 --- a/doc/imagex-extract.1.in +++ b/doc/imagex-extract.1.in @@ -91,6 +91,9 @@ See the documentation for this option in \fB@IMAGEX_PROGNAME@-apply\fR (1). \fB--strict-acls\fR See the documentation for this option in \fB@IMAGEX_PROGNAME@-apply\fR (1). .TP +\fB--no-attributes\fR +See the documentation for this option in \fB@IMAGEX_PROGNAME@-apply\fR (1). +.TP \fB--include-invalid-names\fR See the documentation for this option in \fB@IMAGEX_PROGNAME@-apply\fR (1). .TP diff --git a/include/wimlib.h b/include/wimlib.h index 28f5e9ef..c2c32a8c 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -1514,6 +1514,9 @@ typedef int (*wimlib_iterate_lookup_table_callback_t)(const struct wimlib_resour * one of the provided globs did not match a file. */ #define WIMLIB_EXTRACT_FLAG_STRICT_GLOB 0x00080000 +/** Do not extract Windows file attributes such as readonly, hidden, etc. */ +#define WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES 0x00100000 + /** @} */ /** @ingroup G_mounting_wim_images * @{ */ diff --git a/programs/imagex.c b/programs/imagex.c index 990a41e5..6044a93c 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -145,6 +145,7 @@ enum { IMAGEX_NORPFIX_OPTION, IMAGEX_NOCHECK_OPTION, IMAGEX_NO_ACLS_OPTION, + IMAGEX_NO_ATTRIBUTES_OPTION, IMAGEX_NO_WILDCARDS_OPTION, IMAGEX_ONE_FILE_ONLY_OPTION, IMAGEX_NOT_PIPABLE_OPTION, @@ -183,6 +184,7 @@ static const struct option apply_options[] = { {T("noacls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION}, {T("no-acls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION}, {T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION}, + {T("no-attributes"), no_argument, NULL, IMAGEX_NO_ATTRIBUTES_OPTION}, {T("rpfix"), no_argument, NULL, IMAGEX_RPFIX_OPTION}, {T("norpfix"), no_argument, NULL, IMAGEX_NORPFIX_OPTION}, {T("include-invalid-names"), no_argument, NULL, IMAGEX_INCLUDE_INVALID_NAMES_OPTION}, @@ -264,6 +266,7 @@ static const struct option extract_options[] = { {T("noacls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION}, {T("no-acls"), no_argument, NULL, IMAGEX_NO_ACLS_OPTION}, {T("strict-acls"), no_argument, NULL, IMAGEX_STRICT_ACLS_OPTION}, + {T("no-attributes"), no_argument, NULL, IMAGEX_NO_ATTRIBUTES_OPTION}, {T("dest-dir"), required_argument, NULL, IMAGEX_DEST_DIR_OPTION}, {T("to-stdout"), no_argument, NULL, IMAGEX_TO_STDOUT_OPTION}, {T("include-invalid-names"), no_argument, NULL, IMAGEX_INCLUDE_INVALID_NAMES_OPTION}, @@ -1618,6 +1621,9 @@ imagex_apply(int argc, tchar **argv, int cmd) case IMAGEX_STRICT_ACLS_OPTION: extract_flags |= WIMLIB_EXTRACT_FLAG_STRICT_ACLS; break; + case IMAGEX_NO_ATTRIBUTES_OPTION: + extract_flags |= WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES; + break; case IMAGEX_NORPFIX_OPTION: extract_flags |= WIMLIB_EXTRACT_FLAG_NORPFIX; break; @@ -3008,6 +3014,9 @@ imagex_extract(int argc, tchar **argv, int cmd) case IMAGEX_STRICT_ACLS_OPTION: extract_flags |= WIMLIB_EXTRACT_FLAG_STRICT_ACLS; break; + case IMAGEX_NO_ATTRIBUTES_OPTION: + extract_flags |= WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES; + break; case IMAGEX_DEST_DIR_OPTION: dest_dir = optarg; break; @@ -4042,8 +4051,9 @@ T( T( " %"TS" WIMFILE [(IMAGE_NUM | IMAGE_NAME | all)]\n" " (DIRECTORY | NTFS_VOLUME) [--check] [--ref=\"GLOB\"]\n" -" [--no-acls] [--strict-acls] [--rpfix] [--norpfix]\n" -" [--hardlink] [--symlink] [--include-invalid-names]\n" +" [--no-acls] [--strict-acls] [--no-attributes]\n" +" [--rpfix] [--norpfix] [--hardlink] [--symlink]\n" +" [--include-invalid-names]\n" ), [CMD_CAPTURE] = T( @@ -4075,7 +4085,7 @@ T( T( " %"TS" WIMFILE (IMAGE_NUM | IMAGE_NAME) ([PATH...] | @LISTFILE)\n" " [--check] [--ref=\"GLOB\"] [--no-acls] [--strict-acls]\n" -" [--to-stdout] [--dest-dir=CMD_DIR]\n" +" [--no-attributes] [--to-stdout] [--dest-dir=CMD_DIR]\n" " [--include-invalid-names]\n" ), [CMD_INFO] = diff --git a/src/extract.c b/src/extract.c index 3e4fbcc8..23c93054 100644 --- a/src/extract.c +++ b/src/extract.c @@ -669,6 +669,7 @@ extract_file_attributes(const tchar *path, struct apply_ctx *ctx, int ret; if (ctx->ops->set_file_attributes && + !(ctx->extract_flags & WIMLIB_EXTRACT_FLAG_NO_ATTRIBUTES) && !(dentry == ctx->extract_root && ctx->root_dentry_is_special)) { u32 attributes = dentry->d_inode->i_attributes;