CMD_UNMOUNT,
#endif
CMD_UPDATE,
+ CMD_VERIFY,
CMD_MAX,
};
{NULL, 0, NULL, 0},
};
+static const struct option verify_options[] = {
+ {T("ref"), required_argument, NULL, IMAGEX_REF_OPTION},
+ {T("nocheck"), no_argument, NULL, IMAGEX_NOCHECK_OPTION},
+
+ {NULL, 0, NULL, 0},
+};
+
#if 0
# define _format_attribute(type, format_str, args_start) \
__attribute__((format(type, format_str, args_start)))
T("NTFS volume") : T("directory")),
info->extract.target);
break;
+ case WIMLIB_PROGRESS_MSG_EXTRACT_FILE_STRUCTURE:
+ if (info->extract.end_file_count >= 2000) {
+ percent_done = TO_PERCENT(info->extract.current_file_count,
+ info->extract.end_file_count);
+ imagex_printf(T("\rCreating files: %"PRIu64" of %"PRIu64" (%u%%) done"),
+ info->extract.current_file_count,
+ info->extract.end_file_count, percent_done);
+ if (info->extract.current_file_count == info->extract.end_file_count)
+ imagex_printf(T("\n"));
+ }
+ break;
case WIMLIB_PROGRESS_MSG_EXTRACT_STREAMS:
percent_done = TO_PERCENT(info->extract.completed_bytes,
info->extract.total_bytes);
if (info->extract.completed_bytes >= info->extract.total_bytes)
imagex_printf(T("\n"));
break;
+ case WIMLIB_PROGRESS_MSG_EXTRACT_METADATA:
+ if (info->extract.end_file_count >= 2000) {
+ percent_done = TO_PERCENT(info->extract.current_file_count,
+ info->extract.end_file_count);
+ imagex_printf(T("\rApplying metadata to files: %"PRIu64" of %"PRIu64" (%u%%) done"),
+ info->extract.current_file_count,
+ info->extract.end_file_count, percent_done);
+ if (info->extract.current_file_count == info->extract.end_file_count)
+ imagex_printf(T("\n"));
+ }
+ break;
case WIMLIB_PROGRESS_MSG_EXTRACT_SPWM_PART_BEGIN:
if (info->extract.total_parts != 1) {
imagex_printf(T("\nReading split pipable WIM part %u of %u\n"),
}
}
break;
+ case WIMLIB_PROGRESS_MSG_BEGIN_VERIFY_IMAGE:
+ imagex_printf(T("Verifying metadata for image %"PRIu32" of %"PRIu32"\n"),
+ info->verify_image.current_image,
+ info->verify_image.total_images);
+ break;
+ case WIMLIB_PROGRESS_MSG_VERIFY_STREAMS:
+ percent_done = TO_PERCENT(info->verify_streams.completed_bytes,
+ info->verify_streams.total_bytes);
+ unit_shift = get_unit(info->verify_streams.total_bytes, &unit_name);
+ imagex_printf(T("\rVerifying streams: "
+ "%"PRIu64" %"TS" of %"PRIu64" %"TS" (%u%%) done"),
+ info->verify_streams.completed_bytes >> unit_shift,
+ unit_name,
+ info->verify_streams.total_bytes >> unit_shift,
+ unit_name,
+ percent_done);
+ if (info->verify_streams.completed_bytes == info->verify_streams.total_bytes)
+ imagex_printf(T("\n"));
+ break;
default:
break;
}
imagex_capture_or_append(int argc, tchar **argv, int cmd)
{
int c;
- int open_flags = WIMLIB_OPEN_FLAG_WRITE_ACCESS;
- int add_image_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE |
- WIMLIB_ADD_IMAGE_FLAG_WINCONFIG |
- WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+ int open_flags = 0;
+ int add_flags = WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE |
+ WIMLIB_ADD_FLAG_WINCONFIG |
+ WIMLIB_ADD_FLAG_VERBOSE;
int write_flags = 0;
int compression_type = WIMLIB_COMPRESSION_TYPE_INVALID;
uint32_t chunk_size = UINT32_MAX;
for_opt(c, capture_or_append_options) {
switch (c) {
case IMAGEX_BOOT_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_BOOT;
+ add_flags |= WIMLIB_ADD_FLAG_BOOT;
break;
case IMAGEX_CHECK_OPTION:
open_flags |= WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
break;
case IMAGEX_CONFIG_OPTION:
config_file = optarg;
- add_image_flags &= ~WIMLIB_ADD_IMAGE_FLAG_WINCONFIG;
+ add_flags &= ~WIMLIB_ADD_FLAG_WINCONFIG;
break;
case IMAGEX_COMPRESS_OPTION:
compression_type = get_compression_type(optarg);
flags_element = optarg;
break;
case IMAGEX_DEREFERENCE_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE;
+ add_flags |= WIMLIB_ADD_FLAG_DEREFERENCE;
break;
case IMAGEX_VERBOSE_OPTION:
/* No longer does anything. */
write_flags |= WIMLIB_WRITE_FLAG_REBUILD;
break;
case IMAGEX_UNIX_DATA_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA;
+ add_flags |= WIMLIB_ADD_FLAG_UNIX_DATA;
break;
case IMAGEX_SOURCE_LIST_OPTION:
source_list = true;
break;
case IMAGEX_NO_ACLS_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_NO_ACLS;
+ add_flags |= WIMLIB_ADD_FLAG_NO_ACLS;
break;
case IMAGEX_STRICT_ACLS_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_STRICT_ACLS;
+ add_flags |= WIMLIB_ADD_FLAG_STRICT_ACLS;
break;
case IMAGEX_RPFIX_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_RPFIX;
+ add_flags |= WIMLIB_ADD_FLAG_RPFIX;
break;
case IMAGEX_NORPFIX_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_NORPFIX;
+ add_flags |= WIMLIB_ADD_FLAG_NORPFIX;
break;
case IMAGEX_PIPABLE_OPTION:
write_flags |= WIMLIB_WRITE_FLAG_PIPABLE;
write_flags |= WIMLIB_WRITE_FLAG_SKIP_EXTERNAL_WIMS;
break;
case IMAGEX_WIMBOOT_OPTION:
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_WIMBOOT;
+ add_flags |= WIMLIB_ADD_FLAG_WIMBOOT;
break;
default:
goto out_usage;
if (compression_type == WIMLIB_COMPRESSION_TYPE_INVALID) {
/* No compression type specified. Use the default. */
- if (add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) {
+ if (add_flags & WIMLIB_ADD_FLAG_WIMBOOT) {
/* With --wimboot, default to XPRESS compression. */
compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS;
} else if (write_flags & WIMLIB_WRITE_FLAG_PACK_STREAMS) {
/* Open the existing WIM, or create a new one. */
if (cmd == CMD_APPEND) {
- ret = wimlib_open_wim_with_progress(wimfile, open_flags, &wim,
- imagex_progress_func, NULL);
+ ret = wimlib_open_wim_with_progress(wimfile,
+ open_flags | WIMLIB_OPEN_FLAG_WRITE_ACCESS,
+ &wim,
+ imagex_progress_func,
+ NULL);
if (ret)
goto out_free_capture_sources;
} else {
ret = wimlib_set_output_chunk_size(wim, chunk_size);
if (ret)
goto out_free_wim;
- } else if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_WIMBOOT) &&
+ } else if ((add_flags & WIMLIB_ADD_FLAG_WIMBOOT) &&
compression_type == WIMLIB_COMPRESSION_TYPE_XPRESS) {
ret = wimlib_set_output_chunk_size(wim, 4096);
if (ret)
if (S_ISBLK(stbuf.st_mode) || S_ISREG(stbuf.st_mode)) {
imagex_printf(T("Capturing WIM image from NTFS "
"filesystem on \"%"TS"\"\n"), source);
- add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_NTFS;
+ add_flags |= WIMLIB_ADD_FLAG_NTFS;
}
} else {
if (errno != ENOENT) {
for (size_t i = 0; i < base_wimfiles.num_strings; i++) {
ret = wimlib_open_wim_with_progress(
- base_wimfiles.strings[i],
- open_flags, &base_wims[i],
- imagex_progress_func, NULL);
+ base_wimfiles.strings[i], open_flags,
+ &base_wims[i], imagex_progress_func, NULL);
if (ret)
goto out_free_base_wims;
num_sources,
name,
config_file,
- add_image_flags);
+ add_flags);
if (ret)
goto out_free_template_wim;
goto out_free_command_str;
}
+/* Verify a WIM file. */
+static int
+imagex_verify(int argc, tchar **argv, int cmd)
+{
+ int ret;
+ const tchar *wimfile;
+ WIMStruct *wim;
+ int open_flags = WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+ int verify_flags = 0;
+ STRING_SET(refglobs);
+ int c;
+ for_opt(c, verify_options) {
+ switch (c) {
+ case IMAGEX_REF_OPTION:
+ ret = string_set_append(&refglobs, optarg);
+ if (ret)
+ goto out_free_refglobs;
+ break;
+ case IMAGEX_NOCHECK_OPTION:
+ open_flags &= ~WIMLIB_OPEN_FLAG_CHECK_INTEGRITY;
+ break;
+ default:
+ goto out_usage;
+ }
+ }
+
+ argv += optind;
+ argc -= optind;
+
+ if (argc != 1) {
+ if (argc == 0)
+ imagex_error(T("Must specify a WIM file!"));
+ else
+ imagex_error(T("At most one WIM file can be specified!"));
+ goto out_usage;
+ }
+
+ wimfile = argv[0];
+
+ ret = wimlib_open_wim_with_progress(wimfile,
+ open_flags,
+ &wim,
+ imagex_progress_func,
+ NULL);
+ if (ret)
+ goto out_free_refglobs;
+
+ ret = wim_reference_globs(wim, &refglobs, open_flags);
+ if (ret)
+ goto out_wimlib_free;
+
+ ret = wimlib_verify_wim(wim, verify_flags);
+ if (ret) {
+ tputc(T('\n'), stderr);
+ imagex_error(T("\"%"TS"\" failed verification!"),
+ wimfile);
+ if (ret == WIMLIB_ERR_RESOURCE_NOT_FOUND &&
+ refglobs.num_strings == 0)
+ {
+ imagex_printf(T("Note: if this WIM file is not standalone, "
+ "use the --ref option to specify the other parts.\n"));
+ }
+ } else {
+ imagex_printf(T("\n\"%"TS"\" was successfully verified.\n"),
+ wimfile);
+ }
+
+out_wimlib_free:
+ wimlib_free(wim);
+out_free_refglobs:
+ string_set_destroy(&refglobs);
+ return ret;
+
+out_usage:
+ usage(CMD_VERIFY, stderr);
+ ret = -1;
+ goto out_free_refglobs;
+}
struct imagex_command {
const tchar *name;
[CMD_UNMOUNT] = {T("unmount"), imagex_unmount},
#endif
[CMD_UPDATE] = {T("update"), imagex_update},
+ [CMD_VERIFY] = {T("verify"), imagex_verify},
};
#ifdef __WIN32__
" [--command=STRING] [--wimboot-config=FILE]\n"
" [< CMDFILE]\n"
),
+[CMD_VERIFY] =
+T(
+" %"TS" WIMFILE [--ref=\"GLOB\"]\n"
+),
};
static const tchar *invocation_name;
{
static tchar buf[50];
if (cmd == CMD_NONE) {
- tsprintf(buf, T("%"TS), T(IMAGEX_PROGNAME));
+ return T("wimlib-imagex");
} else if (invocation_cmd != CMD_NONE) {
tsprintf(buf, T("wim%"TS), imagex_commands[cmd].name);
} else {
{
static const tchar *s =
T(
-IMAGEX_PROGNAME " (distributed with " PACKAGE " " PACKAGE_VERSION ")\n"
+"wimlib-imagex (distributed with " PACKAGE " " PACKAGE_VERSION ")\n"
"Copyright (C) 2012, 2013, 2014 Eric Biggers\n"
"License GPLv3+; GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n"
"This is free software: you are free to change and redistribute it.\n"
/* Allow being invoked as wimCOMMAND (e.g. wimapply). */
cmd = CMD_NONE;
if (!tstrncmp(invocation_name, T("wim"), 3) &&
- tstrcmp(invocation_name, T(IMAGEX_PROGNAME))) {
+ tstrcmp(invocation_name, T("wimlib-imagex"))) {
for (int i = 0; i < CMD_MAX; i++) {
if (!tstrcmp(invocation_name + 3,
imagex_commands[i].name))