From d95ea079466c0f21c3482108a54d92f6b77a682e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 10 Mar 2023 14:45:05 -0600 Subject: [PATCH] cpio -i trying to create a directory that exists is not an error, and don't exit (just warn) for the -d case having an error. --- toys/posix/cpio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/toys/posix/cpio.c b/toys/posix/cpio.c index 71fb5022..195fb9b0 100644 --- a/toys/posix/cpio.c +++ b/toys/posix/cpio.c @@ -13,6 +13,7 @@ * In order: magic ino mode uid gid nlink mtime filesize devmajor devminor * rdevmajor rdevminor namesize check * This is the equivalent of mode -H newc in other implementations. + * We always do --quiet, but accept it as a compatibility NOP. * * TODO: export/import linux file list text format ala gen_initramfs_list.sh @@ -100,7 +101,7 @@ void cpio_main(void) if (FLAG(d)) { if (!*toys.optargs) error_exit("need directory for -p"); if (mkdir(*toys.optargs, 0700) == -1 && errno != EEXIST) - perror_exit("mkdir %s", *toys.optargs); + perror_msg("mkdir %s", *toys.optargs); } if (toys.stacktop) { // xpopen() doesn't return from child due to vfork(), instead restarts @@ -173,7 +174,7 @@ void cpio_main(void) // properly aligned with next file. if (S_ISDIR(mode)) { - if (!test) err = mkdir(name, mode) && !FLAG(u); + if (!test) err = mkdir(name, mode) && (errno != EEXIST && !FLAG(u)); } else if (S_ISLNK(mode)) { data = strpad(afd, size, 0); if (!test) { -- 2.39.2