2 * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
5 * Make ranges of device files quickly.
6 * known bugs: can't deal with alpha ranges
15 #include <sys/types.h>
18 static const char makedevs_usage[] =
19 "makedevs 0.01 -- Create an entire range of device files\n\n"
20 "\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
21 "\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
24 makedevs_main(int argc, char * * argv)
27 const char *basedev = argv[1];
28 const char *type = argv[2];
29 int major = atoi(argv[3]);
30 int Sminor = atoi(argv[4]);
31 int S = atoi(argv[5]);
32 int E = atoi(argv[6]);
33 int sbase = argc == 8 ? 1 : 0;
42 mode = S_IFCHR; break;
44 mode = S_IFBLK; break;
46 mode = S_IFIFO; break;
48 usage( makedevs_usage);
55 dev = (major << 8) | Sminor;
56 strcpy(devname, basedev);
59 sprintf(buf, "%d", S);
65 if (mknod (devname, mode, dev))
66 printf("Failed to create: %s\n", devname);
75 And this is what this program replaces. The shell is too slow!
78 local basedev=$1; local S=$2; local E=$3
79 local major=$4; local Sminor=$5; local type=$6
82 if [ ! "$sbase" = "" ]; then
83 mknod "$basedev" $type $major $Sminor
85 Sminor=`expr $Sminor + 1`
88 while [ $S -le $E ]; do
89 mknod "$basedev$S" $type $major $Sminor
91 Sminor=`expr $Sminor + 1`