* is encountered. */
#define WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE 0x00000400
+/** Automatically select a capture configuration appropriate for capturing
+ * filesystems containing Windows operating systems. When this flag is
+ * specified, the corresponding @p config parameter or member must be @c NULL.
+ *
+ * Currently, selecting this capture configuration will cause the following
+ * files and directories to be excluded from capture:
+ *
+ * - "\$ntfs.log"
+ * - "\hiberfil.sys"
+ * - "\pagefile.sys"
+ * - "\System Volume Information"
+ * - "\RECYCLER"
+ * - "\Windows\CSC"
+ *
+ * Note that the default behavior--- that is, when this flag is not specified
+ * and @p config is @c NULL--- is to use no capture configuration, meaning that
+ * no files are excluded from capture.
+ */
+#define WIMLIB_ADD_FLAG_WINCONFIG 0x00000800
#define WIMLIB_ADD_IMAGE_FLAG_NTFS WIMLIB_ADD_FLAG_NTFS
#define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE WIMLIB_ADD_FLAG_DEREFERENCE
#define WIMLIB_ADD_IMAGE_FLAG_NORPFIX WIMLIB_ADD_FLAG_NORPFIX
#define WIMLIB_ADD_IMAGE_FLAG_NO_UNSUPPORTED_EXCLUDE \
WIMLIB_ADD_FLAG_NO_UNSUPPORTED_EXCLUDE
+#define WIMLIB_ADD_IMAGE_FLAG_WINCONFIG WIMLIB_ADD_FLAG_WINCONFIG
/******************************
* WIMLIB_DELETE_FLAG_*
wimlib_tchar *wim_target_path;
/** Configuration for excluded files. @c NULL means
- * exclude no files. */
+ * exclude no files (use no configuration), unless
+ * ::WIMLIB_ADD_FLAG_WINCONFIG is specified in @p
+ * add_flags. */
struct wimlib_capture_config *config;
/** Bitwise OR of WIMLIB_ADD_FLAG_* flags. */
return (off_t)-1;
}
-tchar pat_ntfs_log[] = T("/$ntfs.log");
-tchar pat_hiberfil_sys[] = T("/hiberfil.sys");
-tchar pat_pagefile_sys[] = T("/pagefile.sys");
-tchar pat_system_volume_information[] = T("/System Volume Information");
-tchar pat_recycler[] = T("/RECYCLER");
-tchar pat_windows_csc[] = T("/Windows/CSC");
-
-tchar *default_pats[] = {
- pat_ntfs_log,
- pat_hiberfil_sys,
- pat_pagefile_sys,
- pat_system_volume_information,
- pat_recycler,
- pat_windows_csc,
-};
-
-static struct wimlib_capture_config default_capture_config = {
- .exclusion_pats = {
- .num_pats = sizeof(default_pats) / sizeof(default_pats[0]),
- .pats = default_pats,
- },
-};
-
enum {
PARSE_STRING_SUCCESS = 0,
PARSE_STRING_FAILURE = 1,
switch (op) {
case WIMLIB_UPDATE_OP_ADD:
if (!tstrcmp(option, T("--verbose")))
- cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+ cmd->add.add_flags |= WIMLIB_ADD_FLAG_VERBOSE;
else if (!tstrcmp(option, T("--unix-data")))
- cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA;
+ cmd->add.add_flags |= WIMLIB_ADD_FLAG_UNIX_DATA;
else if (!tstrcmp(option, T("--no-acls")) || !tstrcmp(option, T("--noacls")))
- cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_NO_ACLS;
+ cmd->add.add_flags |= WIMLIB_ADD_FLAG_NO_ACLS;
else if (!tstrcmp(option, T("--strict-acls")))
- cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS;
+ cmd->add.add_flags |= WIMLIB_ADD_FLAG_STRICT_ACLS;
else if (!tstrcmp(option, T("--dereference")))
- cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE;
+ cmd->add.add_flags |= WIMLIB_ADD_FLAG_DEREFERENCE;
else
recognized = false;
break;
{
int c;
int open_flags = WIMLIB_OPEN_FLAG_WRITE_ACCESS;
- int add_image_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE;
+ int add_image_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE |
+ WIMLIB_ADD_IMAGE_FLAG_WINCONFIG;
int write_flags = 0;
int compression_type = WIMLIB_COMPRESSION_TYPE_LZX;
const tchar *wimfile;
break;
case IMAGEX_CONFIG_OPTION:
config_file = optarg;
+ add_image_flags &= ~WIMLIB_ADD_IMAGE_FLAG_WINCONFIG;
break;
case IMAGEX_COMPRESS_OPTION:
compression_type = get_compression_type(optarg);
if (ret)
goto out_free_config;
} else {
- config = &default_capture_config;
+ config = NULL;
}
if (cmd == CMD_APPEND)
out_wimlib_free:
wimlib_free(wim);
out_free_config:
- if (config != &default_capture_config) {
+ if (config) {
free(config->exclusion_pats.pats);
free(config->exclusion_exception_pats.pats);
free(config_str);
int open_flags = WIMLIB_OPEN_FLAG_WRITE_ACCESS;
int write_flags = 0;
int update_flags = WIMLIB_UPDATE_FLAG_SEND_PROGRESS;
- int default_add_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE;
+ int default_add_flags = WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE |
+ WIMLIB_ADD_FLAG_WINCONFIG;
int default_delete_flags = 0;
unsigned num_threads = 0;
int c;
/* Global add option */
case IMAGEX_CONFIG_OPTION:
+ default_add_flags &= ~WIMLIB_ADD_FLAG_WINCONFIG;
config_file = optarg;
break;
/* Default add options */
case IMAGEX_VERBOSE_OPTION:
- default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+ default_add_flags |= WIMLIB_ADD_FLAG_VERBOSE;
break;
case IMAGEX_DEREFERENCE_OPTION:
- default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE;
+ default_add_flags |= WIMLIB_ADD_FLAG_DEREFERENCE;
break;
case IMAGEX_UNIX_DATA_OPTION:
- default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA;
+ default_add_flags |= WIMLIB_ADD_FLAG_UNIX_DATA;
break;
case IMAGEX_NO_ACLS_OPTION:
- default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_NO_ACLS;
+ default_add_flags |= WIMLIB_ADD_FLAG_NO_ACLS;
break;
case IMAGEX_STRICT_ACLS_OPTION:
- default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS;
+ default_add_flags |= WIMLIB_ADD_FLAG_STRICT_ACLS;
break;
default:
goto out_usage;
if (ret)
goto out_free_config;
} else {
- config = &default_capture_config;
+ config = NULL;
}
/* Read update commands from standard input, or the command string if
out_free_cmd_file_contents:
free(cmd_file_contents);
out_free_config:
- if (config != &default_capture_config) {
+ if (config) {
free(config->exclusion_pats.pats);
free(config->exclusion_exception_pats.pats);
free(config_str);
return ret;
}
+
+tchar *winpats[] = {
+ T("/$ntfs.log"),
+ T("/hiberfil.sys"),
+ T("/pagefile.sys"),
+ T("/System Volume Information"),
+ T("/RECYCLER"),
+ T("/Windows/CSC"),
+};
+
+static const struct wimlib_capture_config winconfig = {
+ .exclusion_pats = {
+ .num_pats = ARRAY_LEN(winpats),
+ .pats = winpats,
+ },
+};
+
static int
check_add_command(struct wimlib_update_command *cmd,
const struct wim_header *hdr)
{
int ret;
struct wimlib_update_command *cmds_copy;
+ const struct wimlib_capture_config *config;
cmds_copy = CALLOC(num_cmds, sizeof(cmds[0]));
if (!cmds_copy)
if (!cmds_copy[i].add.fs_source_path ||
!cmds_copy[i].add.wim_target_path)
goto oom;
- if (cmds[i].add.config) {
- ret = copy_and_canonicalize_capture_config(cmds[i].add.config,
+ config = cmds[i].add.config;
+ if (cmds[i].add.add_flags & WIMLIB_ADD_FLAG_WINCONFIG)
+ config = &winconfig;
+ if (config) {
+ ret = copy_and_canonicalize_capture_config(config,
&cmds_copy[i].add.config);
if (ret)
goto err;