- 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; thexe 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;
- }
- bb_perror_msg_and_die("%s", name);
- }
+ //argc -= optind;
+
+ if (!argv[0] || !argv[1])
+ bb_show_usage();
+ type = strchr(modes_chars, argv[1][0]);
+ if (!type)
+ bb_show_usage();
+
+ mode |= modes_cubp[(int)(type[4])];
+
+ dev = 0;
+ arg = argv[2];
+ if (*type != 'p') {
+ if (!argv[2] || !argv[3])
+ bb_show_usage();
+ /* 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)));
+ arg = argv[4];
+ }
+ if (arg)
+ bb_show_usage();
+
+ if (mknod(argv[0], mode, dev) != 0) {
+ bb_simple_perror_msg_and_die(argv[0]);