1 /* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kevin Fall. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11 #ifndef lint 12 static char copyright[] = 13 "@(#) Copyright (c) 1989, 1993\n\ 14 The Regents of the University of California. All rights reserved.\n"; 15 #endif /* not lint */ 16 17 #ifndef lint 18 static char sccsid[] = "@(#)mknod.c 8.1 (Berkeley) 06/05/93"; 19 #endif /* not lint */ 20 21 #include <sys/types.h> 22 #include <sys/stat.h> 23 #include <stdio.h> 24 25 main(argc, argv) 26 int argc; 27 char **argv; 28 { 29 extern int errno; 30 u_short mode; 31 char *strerror(); 32 33 if (argc != 5) { 34 (void)fprintf(stderr, 35 "usage: mknod name [b | c] major minor\n"); 36 exit(1); 37 } 38 39 mode = 0666; 40 if (argv[2][0] == 'c') 41 mode |= S_IFCHR; 42 else if (argv[2][0] == 'b') 43 mode |= S_IFBLK; 44 else { 45 (void)fprintf(stderr, 46 "mknod: node must be type 'b' or 'c'.\n"); 47 exit(1); 48 } 49 50 if (mknod(argv[1], mode, makedev(atoi(argv[3]), atoi(argv[4]))) < 0) { 51 (void)fprintf(stderr, 52 "mknod: %s: %s\n", argv[1], strerror(errno)); 53 exit(1); 54 } 55 exit(0); 56 } 57