137130Sbostic /* 237130Sbostic * Copyright (c) 1989 The Regents of the University of California. 337130Sbostic * All rights reserved. 437130Sbostic * 537130Sbostic * This code is derived from software contributed to Berkeley by 637130Sbostic * Kevin Fall. 737130Sbostic * 8*42702Sbostic * %sccs.include.redist.c% 937130Sbostic */ 1037130Sbostic 1124467Smckusick #ifndef lint 1237130Sbostic char copyright[] = 1337130Sbostic "@(#) Copyright (c) 1989 The Regents of the University of California.\n\ 1437130Sbostic All rights reserved.\n"; 1537130Sbostic #endif /* not lint */ 1624467Smckusick 1737130Sbostic #ifndef lint 18*42702Sbostic static char sccsid[] = "@(#)mknod.c 4.4 (Berkeley) 06/01/90"; 1937130Sbostic #endif /* not lint */ 2037130Sbostic 2137130Sbostic #include <sys/types.h> 2237130Sbostic #include <sys/stat.h> 2324467Smckusick #include <stdio.h> 2424467Smckusick 251053Sbill main(argc, argv) 2624467Smckusick int argc; 2724467Smckusick char **argv; 281053Sbill { 2937130Sbostic extern int errno; 3037130Sbostic u_short mode; 3137130Sbostic char *strerror(); 321053Sbill 3337130Sbostic if (argc != 5) { 3437130Sbostic (void)fprintf(stderr, 3537130Sbostic "usage: mknod name [b | c] major minor\n"); 3637130Sbostic exit(1); 371053Sbill } 3837130Sbostic 3937130Sbostic mode = 0666; 4037130Sbostic if (argv[2][0] == 'c') 4137130Sbostic mode |= S_IFCHR; 4237130Sbostic else if (argv[2][0] == 'b') 4337130Sbostic mode |= S_IFBLK; 4437130Sbostic else { 4537130Sbostic (void)fprintf(stderr, 4637130Sbostic "mknod: node must be type 'b' or 'c'.\n"); 4737130Sbostic exit(1); 4824467Smckusick } 491053Sbill 5037130Sbostic if (mknod(argv[1], mode, makedev(atoi(argv[3]), atoi(argv[4]))) < 0) { 5137130Sbostic (void)fprintf(stderr, 5237130Sbostic "mknod: %s: %s\n", argv[1], strerror(errno)); 5337130Sbostic exit(1); 541053Sbill } 5537130Sbostic exit(0); 561053Sbill } 57