diff options
Diffstat (limited to 'archival/cpio.c')
-rw-r--r-- | archival/cpio.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index f139f3130..5c16678e4 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -307,16 +307,17 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
307 | opt = getopt32(argv, OPTION_STR, &cpio_filename); | 307 | opt = getopt32(argv, OPTION_STR, &cpio_filename); |
308 | #else | 308 | #else |
309 | opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); | 309 | opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); |
310 | argv += optind; | ||
310 | if (opt & CPIO_OPT_PASSTHROUGH) { | 311 | if (opt & CPIO_OPT_PASSTHROUGH) { |
311 | pid_t pid; | 312 | pid_t pid; |
312 | struct fd_pair pp; | 313 | struct fd_pair pp; |
313 | 314 | ||
314 | if (argv[optind] == NULL) | 315 | if (argv[0] == NULL) |
315 | bb_show_usage(); | 316 | bb_show_usage(); |
316 | if (opt & CPIO_OPT_CREATE_LEADING_DIR) | 317 | if (opt & CPIO_OPT_CREATE_LEADING_DIR) |
317 | mkdir(argv[optind], 0777); | 318 | mkdir(argv[0], 0777); |
318 | /* Crude existence check: | 319 | /* Crude existence check: |
319 | * close(xopen(argv[optind], O_RDONLY | O_DIRECTORY)); | 320 | * close(xopen(argv[0], O_RDONLY | O_DIRECTORY)); |
320 | * We can also xopen, fstat, IS_DIR, later fchdir. | 321 | * We can also xopen, fstat, IS_DIR, later fchdir. |
321 | * This would check for existence earlier and cleaner. | 322 | * This would check for existence earlier and cleaner. |
322 | * As it stands now, if we fail xchdir later, | 323 | * As it stands now, if we fail xchdir later, |
@@ -335,14 +336,14 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
335 | #else | 336 | #else |
336 | xpiped_pair(pp); | 337 | xpiped_pair(pp); |
337 | #endif | 338 | #endif |
338 | pid = fork_or_rexec(argv); | 339 | pid = fork_or_rexec(argv - optind); |
339 | if (pid == 0) { /* child */ | 340 | if (pid == 0) { /* child */ |
340 | close(pp.rd); | 341 | close(pp.rd); |
341 | xmove_fd(pp.wr, STDOUT_FILENO); | 342 | xmove_fd(pp.wr, STDOUT_FILENO); |
342 | goto dump; | 343 | goto dump; |
343 | } | 344 | } |
344 | /* parent */ | 345 | /* parent */ |
345 | xchdir(argv[optind++]); | 346 | xchdir(*argv++); |
346 | close(pp.wr); | 347 | close(pp.wr); |
347 | xmove_fd(pp.rd, STDIN_FILENO); | 348 | xmove_fd(pp.rd, STDIN_FILENO); |
348 | opt &= ~CPIO_OPT_PASSTHROUGH; | 349 | opt &= ~CPIO_OPT_PASSTHROUGH; |
@@ -361,7 +362,6 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
361 | } | 362 | } |
362 | skip: | 363 | skip: |
363 | #endif | 364 | #endif |
364 | argv += optind; | ||
365 | 365 | ||
366 | archive_handle = init_handle(); | 366 | archive_handle = init_handle(); |
367 | archive_handle->src_fd = STDIN_FILENO; | 367 | archive_handle->src_fd = STDIN_FILENO; |
@@ -407,7 +407,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
407 | 407 | ||
408 | while (*argv) { | 408 | while (*argv) { |
409 | archive_handle->filter = filter_accept_list; | 409 | archive_handle->filter = filter_accept_list; |
410 | llist_add_to(&(archive_handle->accept), *argv); | 410 | llist_add_to(&archive_handle->accept, *argv); |
411 | argv++; | 411 | argv++; |
412 | } | 412 | } |
413 | 413 | ||