fputs(USAGE_OPTIONS, stream);
fputs(_(" -a for compatibility only, ignored\n"), stream);
fputs(_(" -v, --verbose be more verbose\n"), stream);
- fputs(_(" -x, --destination <dir> extract into directory\n"), stream);
fputs(_(" -y for compatibility only, ignored\n"), stream);
fputs(_(" -b, --blocksize SIZE use this blocksize, defaults to page size\n"), stream);
+ fputs(_(" --extract [DIR] test uncompression, optionally extract into DIR\n"), stream);
fputs(USAGE_SEPARATOR, stream);
fputs(USAGE_HELP, stream);
fputs(USAGE_VERSION, stream);
size);
}
size -= out;
- if (opt_extract)
+ if (*extract_dir != '\0')
if (write(fd, outbuffer, out) < 0)
err(FSCK_EX_ERROR, _("write failed: %s"),
path);
if (opt_verbose)
print_node('d', i, path);
- if (opt_extract) {
+ if (*extract_dir != '\0') {
if (mkdir(path, i->mode) < 0)
err(FSCK_EX_ERROR, _("mkdir failed: %s"), path);
change_file_status(path, i);
start_data = offset;
if (opt_verbose)
print_node('f', i, path);
- if (opt_extract) {
+ if (*extract_dir != '\0') {
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, i->mode);
if (fd < 0)
err(FSCK_EX_ERROR, _("cannot open %s"), path);
}
if (i->size)
do_uncompress(path, fd, offset, i->size);
- if (opt_extract) {
+ if ( *extract_dir != '\0') {
if (close_fd(fd) != 0)
err(FSCK_EX_ERROR, _("write failed: %s"), path);
change_file_status(path, i);
curr, next, next - curr);
free(str);
}
- if (opt_extract) {
+ if (*extract_dir != '\0') {
if (symlink(outbuffer, path) < 0)
err(FSCK_EX_ERROR, _("symlink failed: %s"), path);
change_file_status(path, i);
if (opt_verbose)
print_node(type, i, path);
- if (opt_extract) {
+ if (*extract_dir != '\0') {
if (mknod(path, i->mode, devtype) < 0)
err(FSCK_EX_ERROR, _("mknod failed: %s"), path);
change_file_status(path, i);
size_t length = 0;
static const struct option longopts[] = {
- {"destination", required_argument, 0, 'x'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{"blocksize", required_argument, 0, 'b'},
+ {"extract", optional_argument, 0, 'x'},
{NULL, no_argument, 0, '0'},
};
atexit(close_stdout);
/* command line options */
- while ((c = getopt_long(argc, argv, "ayx:vVhb:", longopts, NULL)) != EOF)
+ while ((c = getopt_long(argc, argv, "ayvVhb:", longopts, NULL)) != EOF)
switch (c) {
case 'a': /* ignore */
case 'y':
case 'x':
#ifdef INCLUDE_FS_TESTS
opt_extract = 1;
- extract_dir = optarg;
+ if(optarg)
+ extract_dir = optarg;
break;
#else
errx(FSCK_EX_USAGE, _("compiled without -x support"));
test_super(&start, &length);
test_crc(start);
#ifdef INCLUDE_FS_TESTS
- if (blksize == 0)
- blksize = getpagesize();
- outbuffer = xmalloc(blksize * 2);
- test_fs(start);
+ if(opt_extract) {
+ if (blksize == 0)
+ blksize = getpagesize();
+ outbuffer = xmalloc(blksize * 2);
+ test_fs(start);
+ }
#endif
if (opt_verbose)