diff options
author | Rob Landley <rob@landley.net> | 2012-08-25 14:25:22 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-08-25 14:25:22 -0500 |
commit | 3a9241add947cb6d24b5de7a8927517426a78795 (patch) | |
tree | d122ab6570439cd6b17c7d73ed8d4e085e0b8a95 /toys/mknod.c | |
parent | 689f095bc976417bf50810fe59a3b3ac32b21105 (diff) | |
download | toybox-3a9241add947cb6d24b5de7a8927517426a78795.tar.gz |
Move commands into "posix", "lsb", and "other" menus/directories.
Diffstat (limited to 'toys/mknod.c')
-rw-r--r-- | toys/mknod.c | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/toys/mknod.c b/toys/mknod.c deleted file mode 100644 index fb727bc3..00000000 --- a/toys/mknod.c +++ /dev/null @@ -1,51 +0,0 @@ -/* vi: set sw=4 ts=4: - * - * mknod.c - make block or character special file - * - * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> - * - * Not in SUSv3. - -USE_MKNOD(NEWTOY(mknod, "<2>4", TOYFLAG_BIN)) - -config MKNOD - bool "mknod" - default y - help - usage: mknod NAME TYPE [MAJOR MINOR] - - Create a special file NAME with a given type, possible types are - b create a block device with the given MAJOR/MINOR - c or u create a character device with the given MAJOR/MINOR - p create a named pipe ignoring MAJOR/MINOR -*/ - -#include "toys.h" - -static const char modes_char[] = {'p', 'c', 'u', 'b'}; -static const mode_t modes[] = {S_IFIFO, S_IFCHR, S_IFCHR, S_IFBLK}; - -void mknod_main(void) -{ - int major=0, minor=0, type; - char * tmp; - int mode = 0660; - - tmp = strchr(modes_char, toys.optargs[1][0]); - if (!tmp) - perror_exit("unknown special device type %c", toys.optargs[1][0]); - - type = modes[tmp-modes_char]; - - if (type == S_IFCHR || type == S_IFBLK) { - if (toys.optc != 4) - perror_exit("creating a block/char device requires major/minor"); - - major = atoi(toys.optargs[2]); - minor = atoi(toys.optargs[3]); - } - - if (mknod(toys.optargs[0], mode | type, makedev(major, minor))) - perror_exit("mknod %s failed", toys.optargs[0]); - -} |