* known bugs: can't deal with alpha ranges
*/
+//usage:#if ENABLE_FEATURE_MAKEDEVS_LEAF
+//usage:#define makedevs_trivial_usage
+//usage: "NAME TYPE MAJOR MINOR FIRST LAST [s]"
+//usage:#define makedevs_full_usage "\n\n"
+//usage: "Create a range of block or character special files"
+//usage: "\n"
+//usage: "\nTYPE is:"
+//usage: "\n b Block device"
+//usage: "\n c Character device"
+//usage: "\n f FIFO, MAJOR and MINOR are ignored"
+//usage: "\n"
+//usage: "\nFIRST..LAST specify numbers appended to NAME."
+//usage: "\nIf 's' is the last argument, the base device is created as well."
+//usage: "\n"
+//usage: "\nExamples:"
+//usage: "\n makedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63"
+//usage: "\n makedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8"
+//usage:
+//usage:#define makedevs_example_usage
+//usage: "# makedevs /dev/ttyS c 4 66 2 63\n"
+//usage: "[creates ttyS2-ttyS63]\n"
+//usage: "# makedevs /dev/hda b 3 0 0 8 s\n"
+//usage: "[creates hda,hda1-hda8]\n"
+//usage:#endif
+//usage:
+//usage:#if ENABLE_FEATURE_MAKEDEVS_TABLE
+//usage:#define makedevs_trivial_usage
+//usage: "[-d device_table] rootdir"
+//usage:#define makedevs_full_usage "\n\n"
+//usage: "Create a range of special files as specified in a device table.\n"
+//usage: "Device table entries take the form of:\n"
+//usage: "<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>\n"
+//usage: "Where name is the file name, type can be one of:\n"
+//usage: " f Regular file\n"
+//usage: " d Directory\n"
+//usage: " c Character device\n"
+//usage: " b Block device\n"
+//usage: " p Fifo (named pipe)\n"
+//usage: "uid is the user id for the target file, gid is the group id for the\n"
+//usage: "target file. The rest of the entries (major, minor, etc) apply to\n"
+//usage: "to device special files. A '-' may be used for blank entries."
+//usage:
+//usage:#define makedevs_example_usage
+//usage: "For example:\n"
+//usage: "<name> <type> <mode><uid><gid><major><minor><start><inc><count>\n"
+//usage: "/dev d 755 0 0 - - - - -\n"
+//usage: "/dev/console c 666 0 0 5 1 - - -\n"
+//usage: "/dev/null c 666 0 0 1 3 0 0 -\n"
+//usage: "/dev/zero c 666 0 0 1 5 0 0 -\n"
+//usage: "/dev/hda b 640 0 0 3 0 0 0 -\n"
+//usage: "/dev/hda b 640 0 0 3 1 1 1 15\n\n"
+//usage: "Will Produce:\n"
+//usage: "/dev\n"
+//usage: "/dev/console\n"
+//usage: "/dev/null\n"
+//usage: "/dev/zero\n"
+//usage: "/dev/hda\n"
+//usage: "/dev/hda[0-15]\n"
+//usage:#endif
+
#include "libbb.h"
#if ENABLE_FEATURE_MAKEDEVS_LEAF
if ((2 > sscanf(line, "%40s %c %o %40s %40s %u %u %u %u %u",
name, &type, &mode, user, group,
- &major, &minor, &start, &increment, &count))
+ &major, &minor, &start, &increment, &count))
|| ((unsigned)(major | minor | start | count | increment) > 255)
) {
bb_error_msg("invalid line %d: '%s'", linenum, line);