diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-09 20:23:03 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-09 20:23:03 +0100 |
commit | 607f65d17145e27c3daae6543d08743ab756043d (patch) | |
tree | 861faa0471065fbb8199b80cdc36a61ce3a894b8 | |
parent | 93ac7d8468feec562b468e87e1e04b0afdec0951 (diff) | |
download | busybox-w32-607f65d17145e27c3daae6543d08743ab756043d.tar.gz busybox-w32-607f65d17145e27c3daae6543d08743ab756043d.tar.bz2 busybox-w32-607f65d17145e27c3daae6543d08743ab756043d.zip |
cpio: improve help text more; fix -p and -F interaction
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/cpio.c | 22 | ||||
-rw-r--r-- | include/usage.h | 10 |
2 files changed, 17 insertions, 15 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index be9fbd0b5..5eb393d57 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -298,6 +298,10 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
298 | ; | 298 | ; |
299 | #endif | 299 | #endif |
300 | 300 | ||
301 | archive_handle = init_handle(); | ||
302 | /* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */ | ||
303 | archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER; | ||
304 | |||
301 | /* As of now we do not enforce this: */ | 305 | /* As of now we do not enforce this: */ |
302 | /* -i,-t,-o,-p are mutually exclusive */ | 306 | /* -i,-t,-o,-p are mutually exclusive */ |
303 | /* -u,-d,-m make sense only with -i or -p */ | 307 | /* -u,-d,-m make sense only with -i or -p */ |
@@ -307,11 +311,17 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
307 | /* no parameters */ | 311 | /* no parameters */ |
308 | opt_complementary = "=0"; | 312 | opt_complementary = "=0"; |
309 | opt = getopt32(argv, OPTION_STR, &cpio_filename); | 313 | opt = getopt32(argv, OPTION_STR, &cpio_filename); |
314 | if (opt & CPIO_OPT_FILE) { /* -F */ | ||
315 | archive_handle->src_fd = xopen(cpio_filename, O_RDONLY); | ||
316 | } | ||
310 | #else | 317 | #else |
311 | /* _exactly_ one parameter for -p, thus <= 1 param if -p is allowed */ | 318 | /* _exactly_ one parameter for -p, thus <= 1 param if -p is allowed */ |
312 | opt_complementary = ENABLE_FEATURE_CPIO_P ? "?1" : "=0"; | 319 | opt_complementary = ENABLE_FEATURE_CPIO_P ? "?1" : "=0"; |
313 | opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); | 320 | opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); |
314 | argv += optind; | 321 | argv += optind; |
322 | if ((opt & (CPIO_OPT_FILE|CPIO_OPT_CREATE)) == CPIO_OPT_FILE) { /* -F without -o */ | ||
323 | xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO); | ||
324 | } | ||
315 | if (opt & CPIO_OPT_PASSTHROUGH) { | 325 | if (opt & CPIO_OPT_PASSTHROUGH) { |
316 | pid_t pid; | 326 | pid_t pid; |
317 | struct fd_pair pp; | 327 | struct fd_pair pp; |
@@ -367,11 +377,6 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
367 | skip: | 377 | skip: |
368 | #endif | 378 | #endif |
369 | 379 | ||
370 | archive_handle = init_handle(); | ||
371 | /* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */ | ||
372 | archive_handle->seek = seek_by_read; | ||
373 | archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER; | ||
374 | |||
375 | /* One of either extract or test options must be given */ | 380 | /* One of either extract or test options must be given */ |
376 | if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) { | 381 | if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) { |
377 | bb_show_usage(); | 382 | bb_show_usage(); |
@@ -398,10 +403,6 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
398 | archive_handle->action_header = header_list; | 403 | archive_handle->action_header = header_list; |
399 | } | 404 | } |
400 | } | 405 | } |
401 | if (opt & CPIO_OPT_FILE) { /* -F */ | ||
402 | archive_handle->src_fd = xopen(cpio_filename, O_RDONLY); | ||
403 | archive_handle->seek = seek_by_jump; | ||
404 | } | ||
405 | if (opt & CPIO_OPT_CREATE_LEADING_DIR) { | 406 | if (opt & CPIO_OPT_CREATE_LEADING_DIR) { |
406 | archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS; | 407 | archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS; |
407 | } | 408 | } |
@@ -422,8 +423,9 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
422 | 423 | ||
423 | if (archive_handle->cpio__blocks != (off_t)-1 | 424 | if (archive_handle->cpio__blocks != (off_t)-1 |
424 | && !(opt & CPIO_OPT_QUIET) | 425 | && !(opt & CPIO_OPT_QUIET) |
425 | ) | 426 | ) { |
426 | printf("%"OFF_FMT"u blocks\n", archive_handle->cpio__blocks); | 427 | printf("%"OFF_FMT"u blocks\n", archive_handle->cpio__blocks); |
428 | } | ||
427 | 429 | ||
428 | return EXIT_SUCCESS; | 430 | return EXIT_SUCCESS; |
429 | } | 431 | } |
diff --git a/include/usage.h b/include/usage.h index 65836d8ce..7a5cbcc9a 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -560,8 +560,8 @@ | |||
560 | "\n -l,-s Create (sym)links" \ | 560 | "\n -l,-s Create (sym)links" \ |
561 | 561 | ||
562 | #define cpio_trivial_usage \ | 562 | #define cpio_trivial_usage \ |
563 | "[-ti" IF_FEATURE_CPIO_O("o") "]" IF_FEATURE_CPIO_P(" [-p DIR]") \ | 563 | "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]") \ |
564 | " [-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]") | 564 | " [-ti"IF_FEATURE_CPIO_O("o")"]" IF_FEATURE_CPIO_P(" [-p DIR]") |
565 | #define cpio_full_usage "\n\n" \ | 565 | #define cpio_full_usage "\n\n" \ |
566 | "Extract or list files from a cpio archive" \ | 566 | "Extract or list files from a cpio archive" \ |
567 | IF_FEATURE_CPIO_O(", or" \ | 567 | IF_FEATURE_CPIO_O(", or" \ |
@@ -573,7 +573,7 @@ | |||
573 | "\n -t List" \ | 573 | "\n -t List" \ |
574 | "\n -i Extract" \ | 574 | "\n -i Extract" \ |
575 | IF_FEATURE_CPIO_O( \ | 575 | IF_FEATURE_CPIO_O( \ |
576 | "\n -o Create" \ | 576 | "\n -o Create (requires -H newc)" \ |
577 | ) \ | 577 | ) \ |
578 | IF_FEATURE_CPIO_P( \ | 578 | IF_FEATURE_CPIO_P( \ |
579 | "\n -p DIR Copy files to DIR" \ | 579 | "\n -p DIR Copy files to DIR" \ |
@@ -583,9 +583,9 @@ | |||
583 | "\n -m Preserve mtime" \ | 583 | "\n -m Preserve mtime" \ |
584 | "\n -v Verbose" \ | 584 | "\n -v Verbose" \ |
585 | "\n -u Overwrite" \ | 585 | "\n -u Overwrite" \ |
586 | "\n -F Input file" \ | 586 | "\n -F FILE Input (-t,-i,-p) or output (-o) file" \ |
587 | IF_FEATURE_CPIO_O( \ | 587 | IF_FEATURE_CPIO_O( \ |
588 | "\n -H Define format" \ | 588 | "\n -H newc Archive format" \ |
589 | ) \ | 589 | ) \ |
590 | 590 | ||
591 | #define crond_trivial_usage \ | 591 | #define crond_trivial_usage \ |