diff options
Diffstat (limited to 'mknod.c')
-rw-r--r-- | mknod.c | 39 |
1 files changed, 20 insertions, 19 deletions
@@ -1,3 +1,4 @@ +/* vi: set sw=4 ts=4: */ /* * Mini mknod implementation for busybox * @@ -28,22 +29,22 @@ #include <unistd.h> static const char mknod_usage[] = "mknod NAME TYPE MAJOR MINOR\n\n" -"Make block or character special files.\n\n" -"TYPEs include:\n" -"\tb:\tMake a block (buffered) device.\n" -"\tc or u:\tMake a character (un-buffered) device.\n" -"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; + "Make block or character special files.\n\n" + "TYPEs include:\n" + "\tb:\tMake a block (buffered) device.\n" -int -mknod_main(int argc, char** argv) + "\tc or u:\tMake a character (un-buffered) device.\n" + "\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n"; + +int mknod_main(int argc, char **argv) { - mode_t mode = 0; - dev_t dev = 0; + mode_t mode = 0; + dev_t dev = 0; - if ( argc != 5 || **(argv+1) == '-' ) { - usage (mknod_usage); + if (argc != 5 || **(argv + 1) == '-') { + usage(mknod_usage); } - switch(argv[2][0]) { + switch (argv[2][0]) { case 'c': case 'u': mode = S_IFCHR; @@ -55,21 +56,21 @@ mknod_main(int argc, char** argv) mode = S_IFIFO; break; default: - usage (mknod_usage); + usage(mknod_usage); } - if ( mode == S_IFCHR || mode == S_IFBLK ) { + if (mode == S_IFCHR || mode == S_IFBLK) { dev = (atoi(argv[3]) << 8) | atoi(argv[4]); - if ( argc != 5 ) { - usage (mknod_usage); + if (argc != 5) { + usage(mknod_usage); } } mode |= 0666; - if ( mknod(argv[1], mode, dev) != 0 ) { + if (mknod(argv[1], mode, dev) != 0) { perror(argv[1]); - return( FALSE); + return (FALSE); } - return( TRUE); + return (TRUE); } |