1 /* mknod - build a special file Author: Andy Tanenbaum */
6 #include <minix/minlib.h>
10 _PROTOTYPE(int main
, (int argc
, char *argv
[]));
11 _PROTOTYPE(void badcomm
, (void));
12 _PROTOTYPE(void badfifo
, (void));
13 _PROTOTYPE(void badchar
, (void));
14 _PROTOTYPE(void badblock
, (void));
20 /* Mknod name b/c major minor makes a node. */
22 int mode
, major
, minor
, dev
;
24 if (argc
< 3) badcomm();
25 if (*argv
[2] != 'b' && *argv
[2] != 'c' && *argv
[2] != 'p') badcomm();
26 if (*argv
[2] == 'p' && argc
!= 3) badfifo();
27 if (*argv
[2] == 'c' && argc
!= 5) badchar();
28 if (*argv
[2] == 'b' && argc
!= 5) badblock();
29 if (*argv
[2] == 'p') {
33 mode
= (*argv
[2] == 'b' ? 060666 : 020666);
34 major
= atoi(argv
[3]);
35 minor
= atoi(argv
[4]);
36 if (major
- 1 > 0xFE || minor
> 0xFF) badcomm();
37 dev
= (major
<< 8) | minor
;
39 if (mknod(argv
[1], mode
, dev
) < 0) {
50 std_err("Usage: mknod name b/c/p [major minor]\n");
56 std_err("Usage: mknod name p\n");
62 std_err("Usage: mknod name c major minor\n");
68 std_err("Usage: mknod name b major minor\n");