X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Fmkdir.c;h=48a95badbc760419b3548a6683d55d6b287e481e;hb=e2e56c7c4129de7d20df42e8239fd304c81ef29b;hp=b018ac1814284e9daa61301a80ad78912ddf1a4d;hpb=cad5364599eb5062d59e0c397ed638ddd61a8d5d;p=oweals%2Fbusybox.git diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index b018ac181..48a95badb 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -31,27 +31,33 @@ #include #include +#include /* struct option */ #include "busybox.h" -extern int mkdir_main (int argc, char **argv) +static const struct option mkdir_long_options[] = { + { "mode", 1, NULL, 'm' }, + { "parents", 0, NULL, 'p' }, + { 0, 0, 0, 0 } +}; + +int mkdir_main (int argc, char **argv) { mode_t mode = (mode_t)(-1); int status = EXIT_SUCCESS; int flags = 0; - int opt; + unsigned long opt; + char *smode; - while ((opt = getopt (argc, argv, "m:p")) > 0) { - if (opt == 'm') { + bb_applet_long_options = mkdir_long_options; + opt = bb_getopt_ulflags(argc, argv, "m:p", &smode); + if(opt & 1) { mode = 0777; - if (!bb_parse_mode (optarg, &mode)) { - bb_error_msg_and_die ("invalid mode `%s'", optarg); - } - } else if (opt == 'p') { - flags |= FILEUTILS_RECUR; - } else { - bb_show_usage(); + if (!bb_parse_mode (smode, &mode)) { + bb_error_msg_and_die ("invalid mode `%s'", smode); } } + if(opt & 2) + flags |= FILEUTILS_RECUR; if (optind == argc) { bb_show_usage();