annotate toys/pending/makedevs.c @ 1372:d46baa9adb5f draft

Bugfixes for cleaned up makedevs. Newline after table = <stdin>, move start/increment/count loop around entire device creation if/else staircase including chmod/chown code and use ptr to record node vs toybuf.
author Rob Landley <rob@landley.net>
date Mon, 30 Jun 2014 04:58:37 -0500
parents b9605ebd3af4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
1 /* makedevs.c - Make ranges of device files.
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
2 *
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
3 * Copyright 2014 Bilal Qureshi <bilal.jmi@gmail.com>
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Kyungwan Han <asura321@gmail.com>
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
5 *
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
6 * No Standard
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
7
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
8 USE_MAKEDEVS(NEWTOY(makedevs, "<1>1d:", TOYFLAG_USR|TOYFLAG_BIN))
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
9
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
10 config MAKEDEVS
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
11 bool "makedevs"
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
12 default n
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
13 help
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
14 usage: makedevs [-d device_table] rootdir
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
15
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
16 Create a range of special files as specified in a device table.
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
17
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
18 -d file containing device table (default reads from stdin)
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
19
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
20 Each line of of the device table has the fields:
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
21 <name> <type> <mode> <uid> <gid> <major> <minor> <start> <increment> <count>
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
22 Where name is the file name, and type is one of the following:
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
23
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
24 b Block device
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
25 c Character device
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
26 d Directory
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
27 f Regular file
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
28 p Named pipe (fifo)
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
29
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
30 Other fields specify permissions, user and group id owning the file,
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
31 and additional fields for device special files. Use '-' for blank entries,
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
32 unspecified fields are treated as '-'.
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
33 */
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
34
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
35 #define FOR_makedevs
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
36 #include "toys.h"
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
37
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
38 GLOBALS(
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
39 char *fname;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
40 )
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
41
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
42 void makedevs_main()
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
43 {
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
44 int value, fd = 0, line_no, i;
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
45 char *line = NULL;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
46
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
47 // Open file and chdir, verbosely
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
48 xprintf("rootdir = %s\n", *toys.optargs);
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
49 if (toys.optflags & FLAG_d && strcmp(TT.fname, "-")) {
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
50 fd = xopen(TT.fname, O_RDONLY);
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
51 xprintf("table = %s\n", TT.fname);
1372
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
52 } else xprintf("table = <stdin>\n");
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
53 xchdir(*toys.optargs);
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
54
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
55 for (line_no = 0; (line = get_line(fd)); free(line)) {
1372
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
56 char type=0, user[64], group[64], *node, *ptr = line;
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
57 unsigned int mode = 0755, major = 0, minor = 0, cnt = 0, incr = 0,
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
58 st_val = 0;
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
59 uid_t uid;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
60 gid_t gid;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
61 struct stat st;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
62
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
63 line_no++;
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
64 while (isspace(*ptr)) ptr++;
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
65 if (!*ptr || *ptr == '#') continue;
1372
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
66 node = ptr;
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
67
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
68 while (*ptr && !isspace(*ptr)) ptr++;
1372
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
69 if (*ptr) *(ptr++) = 0;
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
70 *user = *group = 0;
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
71 sscanf(ptr, "%c %o %63s %63s %u %u %u %u %u", &type, &mode,
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
72 user, group, &major, &minor, &st_val, &incr, &cnt);
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
73
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
74 // type order here needs to line up with actions[] order.
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
75 i = stridx("pcbdf", type);
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
76 if (i == -1) {
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
77 error_msg("line %d: bad type %c", line_no, type);
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
78 continue;
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
79 } else mode |= (mode_t[]){S_IFIFO, S_IFCHR, S_IFBLK, 0, 0}[i];
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
80
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
81 if (*user) {
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
82 struct passwd *usr;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
83
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
84 if (!(usr = getpwnam(user)) && isdigit(*user)) {
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
85 sscanf(user, "%u", &value);
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
86 usr = xgetpwuid(value);
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
87 }
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
88 if (!usr) error_exit("bad user '%s'", user);
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
89 uid = usr->pw_uid;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
90 } else uid = getuid();
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
91
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
92 if (*group) {
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
93 struct group *grp;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
94
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
95 if (!(grp = getgrnam(group)) && isdigit(*group)) {
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
96 sscanf (group, "%u", &value);
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
97 grp = getgrgid(value);
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
98 }
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
99 if (!grp) error_exit("bad group '%s'", group);
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
100 gid = grp->gr_gid;
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
101 } else gid = getgid();
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
102
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
103 while (*node == '/') node++; // using relative path
1372
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
104
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
105 for (i = 0; (!cnt && !i) || i < cnt; i++) {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
106 if (cnt) {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
107 snprintf(toybuf, sizeof(toybuf), "%s%u", node, st_val + i);
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
108 ptr = toybuf;
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
109 } else ptr = node;
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
110
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
111 if (type == 'd') {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
112 if (mkpathat(AT_FDCWD, ptr, mode, 3)) {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
113 perror_msg("can't create directory '%s'", ptr);
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
114 continue;
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
115 }
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
116 } else if (type == 'f') {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
117 if (stat(ptr, &st) || !S_ISREG(st.st_mode)) {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
118 perror_msg("line %d: file '%s' does not exist", line_no, ptr);
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
119 continue;
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
120 }
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
121 } else if (mknod(ptr, mode, makedev(major, minor + i*incr))) {
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
122 perror_msg("line %d: can't create node '%s'", line_no, ptr);
1362
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
123 continue;
b9605ebd3af4 Cleanup pass on makedevs. Need to test it before promoting.
Rob Landley <rob@landley.net>
parents: 1325
diff changeset
124 }
1372
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
125
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
126 if (chown(ptr, uid, gid) || chmod(ptr, mode))
d46baa9adb5f Bugfixes for cleaned up makedevs.
Rob Landley <rob@landley.net>
parents: 1362
diff changeset
127 perror_msg("line %d: can't chown/chmod '%s'", line_no, ptr);
1325
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
128 }
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
129 }
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
130 xclose(fd);
41fc44c76ade makedevs - making devices/nodes in a range. Supports reading the tabled entry from file.
Ashwini Sharma <ak.ashwini1981@gmail.com>
parents:
diff changeset
131 }