3 # ----------------------------------------------------------------------------
4 # "THE BEER-WARE LICENSE" (Revision 42):
5 # <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
6 # can do whatever you want with this stuff. If we meet some day, and you think
7 # this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
8 # ----------------------------------------------------------------------------
10 # $FreeBSD: src/release/sysinstall/dev2c.sh,v 1.4.2.1 2002/07/02 21:27:28 jhb Exp $
11 # $DragonFly: src/release/sysinstall/Attic/dev2c.sh,v 1.2 2003/06/17 04:27:21 dillon Exp $
13 # During installation, we suffer badly of we have to run MAKEDEV. MAKEDEV
14 # need sh, ln, chown, mknod, awk, rm, test and probably emacs too when
15 # we come down to it. So instead this script will make a C-procedure which
16 # makes all the B & C nodes of a specified directory.
20 (cd $1; ls -li ) | sed 's/,//' | awk '
22 while (getline < "/etc/passwd") {
26 while (getline < "/etc/group") {
31 printf(" * This file is generated from the contents of /dev\n");
33 printf("#define CHK(foo) {i = foo;}\n");
34 printf("#include <unistd.h>\n");
35 printf("#include <sys/types.h>\n");
36 printf("#include <sys/stat.h>\n");
37 printf("int makedevs()\n{\n\tint i=0;\n");
40 printf ("/* %s */\n",$0)
43 if (substr($2,1,1) == "b") {
45 } else if (substr($2,1,1) == "c") {
47 } else if (substr($2,1,1) == "d") {
49 } else if (substr($2,1,1) == "-") {
55 if (substr($2,2,1) == "r") m += 400;
56 if (substr($2,3,1) == "w") m += 200;
57 if (substr($2,4,1) == "x") m += 100;
58 if (substr($2,5,1) == "r") m += 40;
59 if (substr($2,6,1) == "w") m += 20;
60 if (substr($2,7,1) == "x") m += 10;
61 if (substr($2,8,1) == "r") m += 4;
62 if (substr($2,9,1) == "w") m += 2;
63 if (substr($2,10,1) == "x") m += 1;
66 printf ("\tCHK(link(\"%s\",\"%s\"));\n", \
69 printf ("\tCHK(mknod(\"%s\",%s,makedev(%d,%d)));\n", \
71 printf ("\tCHK(chmod(\"%s\",0%d));\n", \
73 printf ("\tCHK(chown(\"%s\",%d,%d));\n", \
79 printf("\treturn i;\n}\n");