From ecb6f39d331114f8ffe475a1d23299330a34954e Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Oct 2023 19:16:01 +0300 Subject: [PATCH] . --- coreutils/cp.c | 7 ++++++- coreutils/mknod.c | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/coreutils/cp.c b/coreutils/cp.c index 71265e6..ca6d7bc 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -88,7 +88,7 @@ int cptree(const char *src, const char *dst) { if (get_stat(src, &stat_path)) return 1; - if (!S_ISDIR(stat_path.st_mode)) { + if (S_ISDIR(stat_path.st_mode) == 0) { if (copy(src, dst)) { fprintf(stderr, "cp: %s: copy() failed (%s)\n", src, strerror(errno)); return 1; @@ -147,6 +147,11 @@ int main(const int argc, char **argv) { ret = cptree(argv[i], argv[argc - 1]); else { + if (mkdir(argv[argc - 1], 0777) < 0) { + fprintf(stderr, "cp: %s\n", strerror(errno)); + return 1; + } + for (; i < argc - 1; i++) { char *new_path = make_path(argv[argc - 1], basename(argv[i])); if (new_path == NULL) diff --git a/coreutils/mknod.c b/coreutils/mknod.c index 3bfde42..f365d9c 100644 --- a/coreutils/mknod.c +++ b/coreutils/mknod.c @@ -1,4 +1,7 @@ +#ifdef __linux__ #include +#endif + #include #include #include