1 /* vi: set sw=4 ts=4: */
3 * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
6 * Make ranges of device files quickly.
7 * known bugs: can't deal with alpha ranges
15 #include <sys/types.h>
16 #include <sys/sysmacros.h> /* major() and minor() */
19 int makedevs_main(int argc, char **argv)
22 char *basedev, *type, *nodname, buf[255];
23 int Smajor, Sminor, S, E;
25 if (argc < 7 || *argv[1]=='-')
30 Smajor = atoi(argv[3]);
31 Sminor = atoi(argv[4]);
34 nodname = argc == 8 ? basedev : buf;
55 sz = snprintf(buf, sizeof(buf), "%s%d", basedev, S);
56 if(sz<0 || sz>=sizeof(buf)) /* libc different */
57 bb_error_msg_and_die("%s too large", basedev);
59 /* if mode != S_IFCHR and != S_IFBLK third param in mknod() ignored */
61 if (mknod(nodname, mode, makedev(Smajor, Sminor)))
62 bb_error_msg("Failed to create: %s", nodname);
64 if (nodname == basedev) /* ex. /dev/hda - to /dev/hda1 ... */
74 And this is what this program replaces. The shell is too slow!
77 local basedev=$1; local S=$2; local E=$3
78 local major=$4; local Sminor=$5; local type=$6
81 if [ ! "$sbase" = "" ]; then
82 mknod "$basedev" $type $major $Sminor
84 Sminor=`expr $Sminor + 1`
87 while [ $S -le $E ]; do
88 mknod "$basedev$S" $type $major $Sminor
90 Sminor=`expr $Sminor + 1`