1 /* mknod - build a special file Author: Andy Tanenbaum */
6 #include <minix/minlib.h>
13 int main(int argc
, char *argv
[]);
23 /* Mknod name b/c major minor makes a node. */
25 int mode
, major
, minor
, dev
;
27 if (argc
< 3) badcomm();
28 if (*argv
[2] != 'b' && *argv
[2] != 'c' && *argv
[2] != 'p') badcomm();
29 if (*argv
[2] == 'p' && argc
!= 3) badfifo();
30 if (*argv
[2] == 'c' && argc
!= 5) badchar();
31 if (*argv
[2] == 'b' && argc
!= 5) badblock();
32 if (*argv
[2] == 'p') {
36 mode
= (*argv
[2] == 'b' ? 060666 : 020666);
37 major
= atoi(argv
[3]);
38 minor
= atoi(argv
[4]);
39 if (major
- 1 > 0xFE || minor
> 0xFF) badcomm();
40 dev
= (major
<< 8) | minor
;
42 if (mknod(argv
[1], mode
, dev
) < 0) {
53 std_err("Usage: mknod name b/c/p [major minor]\n");
59 std_err("Usage: mknod name p\n");
65 std_err("Usage: mknod name c major minor\n");
71 std_err("Usage: mknod name b major minor\n");