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