Commit | Line | Data |
---|---|---|
cef488fd KB |
1 | /* |
2 | * Copyright (c) 1989 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * This code is derived from software contributed to Berkeley by | |
6 | * Kevin Fall. | |
7 | * | |
1c15e888 C |
8 | * Redistribution and use in source and binary forms are permitted |
9 | * provided that: (1) source distributions retain this entire copyright | |
10 | * notice and comment, and (2) distributions including binaries display | |
11 | * the following acknowledgement: ``This product includes software | |
12 | * developed by the University of California, Berkeley and its contributors'' | |
13 | * in the documentation or other materials provided with the distribution | |
14 | * and in all advertising materials mentioning features or use of this | |
15 | * software. Neither the name of the University nor the names of its | |
16 | * contributors may be used to endorse or promote products derived | |
17 | * from this software without specific prior written permission. | |
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
19 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
cef488fd KB |
21 | */ |
22 | ||
23 | #ifndef lint | |
24 | char copyright[] = | |
25 | "@(#) Copyright (c) 1989 The Regents of the University of California.\n\ | |
26 | All rights reserved.\n"; | |
27 | #endif /* not lint */ | |
28 | ||
63e3f3c6 | 29 | #ifndef lint |
1c15e888 | 30 | static char sccsid[] = "@(#)mknod.c 4.4 (Berkeley) 6/1/90"; |
cef488fd | 31 | #endif /* not lint */ |
63e3f3c6 | 32 | |
cef488fd KB |
33 | #include <sys/types.h> |
34 | #include <sys/stat.h> | |
63e3f3c6 KM |
35 | #include <stdio.h> |
36 | ||
f20a0651 | 37 | main(argc, argv) |
63e3f3c6 KM |
38 | int argc; |
39 | char **argv; | |
f20a0651 | 40 | { |
cef488fd KB |
41 | extern int errno; |
42 | u_short mode; | |
43 | char *strerror(); | |
f20a0651 | 44 | |
cef488fd KB |
45 | if (argc != 5) { |
46 | (void)fprintf(stderr, | |
47 | "usage: mknod name [b | c] major minor\n"); | |
48 | exit(1); | |
f20a0651 | 49 | } |
f20a0651 | 50 | |
cef488fd KB |
51 | mode = 0666; |
52 | if (argv[2][0] == 'c') | |
53 | mode |= S_IFCHR; | |
54 | else if (argv[2][0] == 'b') | |
55 | mode |= S_IFBLK; | |
56 | else { | |
57 | (void)fprintf(stderr, | |
58 | "mknod: node must be type 'b' or 'c'.\n"); | |
59 | exit(1); | |
60 | } | |
f20a0651 | 61 | |
cef488fd KB |
62 | if (mknod(argv[1], mode, makedev(atoi(argv[3]), atoi(argv[4]))) < 0) { |
63 | (void)fprintf(stderr, | |
64 | "mknod: %s: %s\n", argv[1], strerror(errno)); | |
65 | exit(1); | |
f20a0651 | 66 | } |
cef488fd | 67 | exit(0); |
f20a0651 | 68 | } |