* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "wimlib.h"
#include "config.h"
+
+#include "wimlib.h"
+
+#include <errno.h>
#include <getopt.h>
-#include <stdlib.h>
-#include <stdarg.h>
#include <glob.h>
-#include <string.h>
-#include <errno.h>
+#include <inttypes.h>
#include <libgen.h>
#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <inttypes.h>
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
#define for_opt(c, opts) while ((c = getopt_long_only(argc, (char**)argv, "", \
opts, NULL)) != -1)
-
enum imagex_op_type {
APPEND,
APPLY,
" [--ref=\"GLOB\"]\n",
[MOUNTRW] =
"imagex mountrw WIMFILE [IMAGE_NUM | IMAGE_NAME] DIRECTORY\n"
-" [--check] [--debug] [--streams-interface=INTERFACE]\n",
+" [--check] [--debug] [--streams-interface=INTERFACE]\n"
+" [--staging-dir=DIR]\n",
[OPTIMIZE] =
-"imagex optimize WIMFILE [--check] [--recompress]\n",
+"imagex optimize WIMFILE [--check] [--recompress] [--compress=TYPE]\n",
[SPLIT] =
"imagex split WIMFILE SPLIT_WIMFILE PART_SIZE_MB [--check]\n",
[UNMOUNT] =
};
static const struct option mount_options[] = {
- {"check", no_argument, NULL, 'c'},
- {"debug", no_argument, NULL, 'd'},
+ {"check", no_argument, NULL, 'c'},
+ {"debug", no_argument, NULL, 'd'},
{"streams-interface", required_argument, NULL, 's'},
- {"ref", required_argument, NULL, 'r'},
+ {"ref", required_argument, NULL, 'r'},
+ {"staging-dir", required_argument, NULL, 'D'},
{NULL, 0, NULL, 0},
};
case WIMLIB_PROGRESS_MSG_SCAN_BEGIN:
printf("Scanning `%s'...\n", info->scan.source);
break;
+ case WIMLIB_PROGRESS_MSG_SCAN_DENTRY:
+ if (info->scan.excluded)
+ printf("Excluding `%s' from capture\n", info->scan.cur_path);
+ else
+ printf("Scanning `%s'\n", info->scan.cur_path);
+ break;
/*case WIMLIB_PROGRESS_MSG_SCAN_END:*/
/*break;*/
case WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY:
putchar('\n');
break;
case WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_BEGIN:
- /*printf("Applying image %d (%s) to `%s'\n",*/
- /*info->extract.image,*/
- /*info->extract.image_name,*/
- /*info->extract.target);*/
+ printf("Applying image %d (%s) from `%s' to %s `%s'\n",
+ info->extract.image,
+ info->extract.image_name,
+ info->extract.wimfile_name,
+ ((info->extract.extract_flags & WIMLIB_EXTRACT_FLAG_NTFS) ?
+ "NTFS volume" : "directory"),
+ info->extract.target);
+ break;
+ case WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END:
+ printf("Done applying WIM image.\n");
+ if (info->extract.extract_flags & WIMLIB_EXTRACT_FLAG_NTFS) {
+ printf("Unmounting NTFS volume `%s'...\n",
+ info->extract.target);
+ }
break;
- /*case WIMLIB_PROGRESS_MSG_EXTRACT_IMAGE_END:*/
- /*printf("Done applying image %d!\n",*/
- /*info->extract.image);*/
- /*break;*/
/*case WIMLIB_PROGRESS_MSG_EXTRACT_DIR_STRUCTURE_BEGIN:*/
/*printf("Applying directory structure to %s\n",*/
/*info->extract.target);*/
if (info->extract.completed_bytes == info->extract.total_bytes)
putchar('\n');
break;
+ case WIMLIB_PROGRESS_MSG_EXTRACT_DENTRY:
+ puts(info->extract.cur_path);
+ break;
case WIMLIB_PROGRESS_MSG_JOIN_STREAMS:
percent_done = TO_PERCENT(info->join.completed_bytes,
info->join.total_bytes);
goto out;
}
-#ifdef WITH_NTFS_3G
struct stat stbuf;
ret = stat(target, &stbuf);
if (ret == 0) {
- if (S_ISBLK(stbuf.st_mode) || S_ISREG(stbuf.st_mode)) {
+ if (S_ISBLK(stbuf.st_mode) || S_ISREG(stbuf.st_mode))
extract_flags |= WIMLIB_EXTRACT_FLAG_NTFS;
- printf("Applying `%s' image %d to NTFS volume `%s'\n",
- wimfile, image, target);
- }
} else {
if (errno != ENOENT) {
imagex_error_with_errno("Failed to stat `%s'", target);
goto out;
}
}
-#endif
ret = wimlib_extract_image(w, image, target, extract_flags,
additional_swms, num_additional_swms,
if (ret != 0)
goto out;
-#ifdef WITH_NTFS_3G
struct stat stbuf;
ret = stat(source, &stbuf);
goto out;
}
}
-#endif
+
ret = wimlib_add_image(w, source, name, config_str, config_len,
add_image_flags, imagex_progress_func);
const char *swm_glob = NULL;
WIMStruct **additional_swms = NULL;
unsigned num_additional_swms = 0;
+ const char *staging_dir = NULL;
if (strcmp(argv[0], "mountrw") == 0)
mount_flags |= WIMLIB_MOUNT_FLAG_READWRITE;
case 'r':
swm_glob = optarg;
break;
+ case 'D':
+ staging_dir = optarg;
+ break;
default:
goto mount_usage;
}
}
ret = wimlib_mount_image(w, image, dir, mount_flags, additional_swms,
- num_additional_swms);
+ num_additional_swms, staging_dir);
if (ret != 0) {
imagex_error("Failed to mount image %d from `%s' on `%s'",
image, wimfile, dir);
ret = wimlib_overwrite(w, write_flags, 0, imagex_progress_func);
- new_size = file_get_size(argv[0]);
- printf("`%s' optimized size: ", wimfile);
- if (new_size == -1)
- puts("Unknown");
- else
- printf("%"PRIu64" KiB\n", new_size >> 10);
+ if (ret == 0) {
+ new_size = file_get_size(argv[0]);
+ printf("`%s' optimized size: ", wimfile);
+ if (new_size == -1)
+ puts("Unknown");
+ else
+ printf("%"PRIu64" KiB\n", new_size >> 10);
- fputs("Space saved: ", stdout);
- if (new_size != -1 && old_size != -1) {
- printf("%lld KiB\n",
- ((long long)old_size - (long long)new_size) >> 10);
- } else {
- puts("Unknown");
+ fputs("Space saved: ", stdout);
+ if (new_size != -1 && old_size != -1) {
+ printf("%lld KiB\n",
+ ((long long)old_size - (long long)new_size) >> 10);
+ } else {
+ puts("Unknown");
+ }
}
wimlib_free(w);
return -1;
}
- ret = wimlib_unmount_image(argv[0], unmount_flags);
+ ret = wimlib_unmount_image(argv[0], unmount_flags,
+ imagex_progress_func);
if (ret != 0)
imagex_error("Failed to unmount `%s'", argv[0]);
return ret;