diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-03 20:26:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-03 20:26:30 +0200 |
commit | b1a2762ecfe3d0f7c953abe4c48eb0582303c197 (patch) | |
tree | b84044589060468a57bb0dc42daf5a3dc3d8e7a0 | |
parent | 327b9f88486e67ade875780ea06dc8031fd70a49 (diff) | |
download | busybox-w32-b1a2762ecfe3d0f7c953abe4c48eb0582303c197.tar.gz busybox-w32-b1a2762ecfe3d0f7c953abe4c48eb0582303c197.tar.bz2 busybox-w32-b1a2762ecfe3d0f7c953abe4c48eb0582303c197.zip |
cpio: fix "cpio -d -p A/B/C"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | archival/cpio.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index 94303389e..d84f6937d 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -418,7 +418,8 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
418 | if (argv[0] == NULL) | 418 | if (argv[0] == NULL) |
419 | bb_show_usage(); | 419 | bb_show_usage(); |
420 | if (opt & OPT_CREATE_LEADING_DIR) | 420 | if (opt & OPT_CREATE_LEADING_DIR) |
421 | mkdir(argv[0], 0777); | 421 | /* GNU cpio 2.13: "cpio -d -p a/b/c" works */ |
422 | bb_make_directory(argv[0], -1, FILEUTILS_RECUR); | ||
422 | /* Crude existence check: | 423 | /* Crude existence check: |
423 | * close(xopen(argv[0], O_RDONLY | O_DIRECTORY)); | 424 | * close(xopen(argv[0], O_RDONLY | O_DIRECTORY)); |
424 | * We can also xopen, fstat, IS_DIR, later fchdir. | 425 | * We can also xopen, fstat, IS_DIR, later fchdir. |
@@ -428,6 +429,11 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
428 | * a diffrerent problem earlier. | 429 | * a diffrerent problem earlier. |
429 | * This is good enough for now. | 430 | * This is good enough for now. |
430 | */ | 431 | */ |
432 | //FIXME: GNU cpio -d -p DIR does not immediately create DIR - | ||
433 | //it just prepends "DIR/" to the names of files to be created. | ||
434 | //The first file (fails to) be copied, and then the -d logic | ||
435 | //triggers and creates all necessary directories. | ||
436 | //IOW: bare "cpio -d -p DIR" + ^C shouldn't create anything. | ||
431 | #if !BB_MMU | 437 | #if !BB_MMU |
432 | pp.rd = 3; | 438 | pp.rd = 3; |
433 | pp.wr = 4; | 439 | pp.wr = 4; |