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>
18 int makedevs_main(int argc, char **argv)
21 const char *basedev = argv[1];
22 const char *type = argv[2];
23 int major = atoi(argv[3]);
24 int Sminor = atoi(argv[4]);
25 int S = atoi(argv[5]);
26 int E = atoi(argv[6]);
27 int sbase = argc == 8 ? 1 : 0;
34 if (argc < 7 || *argv[1]=='-')
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);
76 And this is what this program replaces. The shell is too slow!
79 local basedev=$1; local S=$2; local E=$3
80 local major=$4; local Sminor=$5; local type=$6
83 if [ ! "$sbase" = "" ]; then
84 mknod "$basedev" $type $major $Sminor
86 Sminor=`expr $Sminor + 1`
89 while [ $S -le $E ]; do
90 mknod "$basedev$S" $type $major $Sminor
92 Sminor=`expr $Sminor + 1`