diff options
Diffstat (limited to 'coreutils/mknod.c')
-rw-r--r-- | coreutils/mknod.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/coreutils/mknod.c b/coreutils/mknod.c index ee539e387..55f531033 100644 --- a/coreutils/mknod.c +++ b/coreutils/mknod.c @@ -28,23 +28,29 @@ int mknod_main(int argc, char **argv) argv += optind; argc -= optind; - if ((argc >= 2) && ((name = strchr(modes_chars, argv[1][0])) != NULL)) { - mode |= modes_cubp[(int)(name[4])]; - - dev = 0; - if ((*name != 'p') && ((argc -= 2) == 2)) { - /* Autodetect what the system supports; these macros should - * optimize out to two constants. */ - dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)), - xatoul_range(argv[3], 0, minor(UINT_MAX))); - } + if (argc >= 2) { + name = strchr(modes_chars, argv[1][0]); + if (name != NULL) { + mode |= modes_cubp[(int)(name[4])]; + + dev = 0; + if (*name != 'p') { + argc -= 2; + if (argc == 2) { + /* Autodetect what the system supports; these macros should + * optimize out to two constants. */ + dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)), + xatoul_range(argv[3], 0, minor(UINT_MAX))); + } + } - if (argc == 2) { - name = *argv; - if (mknod(name, mode, dev) == 0) { - return EXIT_SUCCESS; + if (argc == 2) { + name = *argv; + if (mknod(name, mode, dev) == 0) { + return EXIT_SUCCESS; + } + bb_simple_perror_msg_and_die(name); } - bb_simple_perror_msg_and_die(name); } } bb_show_usage(); |