diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /coreutils/mkdir.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'coreutils/mkdir.c')
-rw-r--r-- | coreutils/mkdir.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index f003db99f..b018ac181 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c | |||
@@ -20,46 +20,50 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <errno.h> | 23 | /* BB_AUDIT SUSv3 compliant */ |
24 | #include <getopt.h> | 24 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/mkdir.html */ |
25 | #include <sys/stat.h> | 25 | |
26 | #include <sys/types.h> | 26 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) |
27 | #include <fcntl.h> | 27 | * |
28 | #include <unistd.h> | 28 | * Fixed broken permission setting when -p was used; especially in |
29 | #include <stdlib.h> | 29 | * conjunction with -m. |
30 | #include <string.h> | 30 | */ |
31 | 31 | ||
32 | #include <stdlib.h> | ||
33 | #include <unistd.h> | ||
32 | #include "busybox.h" | 34 | #include "busybox.h" |
33 | 35 | ||
34 | extern int mkdir_main (int argc, char **argv) | 36 | extern int mkdir_main (int argc, char **argv) |
35 | { | 37 | { |
36 | mode_t mode = -1; | 38 | mode_t mode = (mode_t)(-1); |
39 | int status = EXIT_SUCCESS; | ||
37 | int flags = 0; | 40 | int flags = 0; |
38 | int i, opt; | 41 | int opt; |
39 | 42 | ||
40 | while ((opt = getopt (argc, argv, "m:p")) != -1) { | 43 | while ((opt = getopt (argc, argv, "m:p")) > 0) { |
41 | switch (opt) { | 44 | if (opt == 'm') { |
42 | case 'm': | ||
43 | mode = 0777; | 45 | mode = 0777; |
44 | if (!parse_mode (optarg, &mode)) { | 46 | if (!bb_parse_mode (optarg, &mode)) { |
45 | error_msg_and_die ("invalid mode `%s'", optarg); | 47 | bb_error_msg_and_die ("invalid mode `%s'", optarg); |
46 | } | 48 | } |
47 | umask(0); | 49 | } else if (opt == 'p') { |
48 | break; | ||
49 | case 'p': | ||
50 | flags |= FILEUTILS_RECUR; | 50 | flags |= FILEUTILS_RECUR; |
51 | break; | 51 | } else { |
52 | default: | 52 | bb_show_usage(); |
53 | show_usage (); | ||
54 | } | 53 | } |
55 | } | 54 | } |
56 | 55 | ||
57 | if (optind == argc) | 56 | if (optind == argc) { |
58 | show_usage (); | 57 | bb_show_usage(); |
59 | |||
60 | for (i = optind; i < argc; i++) { | ||
61 | make_directory (argv[i], mode, flags); | ||
62 | } | 58 | } |
63 | 59 | ||
64 | return(EXIT_SUCCESS); | 60 | argv += optind; |
61 | |||
62 | do { | ||
63 | if (bb_make_directory(*argv, mode, flags)) { | ||
64 | status = EXIT_FAILURE; | ||
65 | } | ||
66 | } while (*++argv); | ||
67 | |||
68 | return status; | ||
65 | } | 69 | } |