diff options
author | Rob Landley <rob@landley.net> | 2015-03-10 14:37:03 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-03-10 14:37:03 -0500 |
commit | 4216f59cec17699298f5b4043db513e4859bd232 (patch) | |
tree | 94773bcc41d263f736de337fa193cf4b9d121dc5 | |
parent | c776bde13bb2767db2943bc3b02df737a465c035 (diff) | |
download | toybox-4216f59cec17699298f5b4043db513e4859bd232.tar.gz |
Add -m to mknod
-rw-r--r-- | toys/lsb/mknod.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c index bf9288ae..35a127d6 100644 --- a/toys/lsb/mknod.c +++ b/toys/lsb/mknod.c @@ -4,28 +4,32 @@ * * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/mknod.html -USE_MKNOD(NEWTOY(mknod, "<2>4", TOYFLAG_BIN)) +USE_MKNOD(NEWTOY(mknod, "<2>4m(mode):", TOYFLAG_BIN|TOYFLAG_UMASK)) config MKNOD bool "mknod" default y help - usage: mknod NAME TYPE [MAJOR MINOR] + usage: mknod [-m MODE] NAME TYPE [MAJOR MINOR] - Create a special file NAME with a given type, possible types are - b block device - c or u character device - p named pipe (ignores MAJOR/MINOR) + Create a special file NAME with a given type. TYPE is b for block device, + c or u for character device, p for named pipe (which ignores MAJOR/MINOR). + + -m Mode (file permissions) of new device, in octal or u+x format */ #define FOR_mknod #include "toys.h" +GLOBALS( + char *m; +) + void mknod_main(void) { mode_t modes[] = {S_IFIFO, S_IFCHR, S_IFCHR, S_IFBLK}; int major=0, minor=0, type; - int mode = 0660; + int mode = TT.m ? string_to_mode(TT.m, 0777) : 0660; type = stridx("pcub", *toys.optargs[1]); if (type == -1) perror_exit("bad type '%c'", *toys.optargs[1]); |