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
16 #include <sys/types.h>
19 int makedevs_main(int argc, char **argv)
22 const char *basedev = argv[1];
23 const char *type = argv[2];
24 int major = atoi(argv[3]);
25 int Sminor = atoi(argv[4]);
26 int S = atoi(argv[5]);
27 int E = atoi(argv[6]);
28 int sbase = argc == 8 ? 1 : 0;
35 if (argc < 7 || *argv[1]=='-')
36 usage(makedevs_usage);
49 usage(makedevs_usage);
56 dev = (major << 8) | Sminor;
57 strcpy(devname, basedev);
60 sprintf(buf, "%d", S);
66 if (mknod(devname, mode, dev))
67 printf("Failed to create: %s\n", devname);
77 And this is what this program replaces. The shell is too slow!
80 local basedev=$1; local S=$2; local E=$3
81 local major=$4; local Sminor=$5; local type=$6
84 if [ ! "$sbase" = "" ]; then
85 mknod "$basedev" $type $major $Sminor
87 Sminor=`expr $Sminor + 1`
90 while [ $S -le $E ]; do
91 mknod "$basedev$S" $type $major $Sminor
93 Sminor=`expr $Sminor + 1`