diff options
author | Charlie Shepherd <masterdriverz@gentoo.org> | 2007-11-07 00:11:20 +0000 |
---|---|---|
committer | Charlie Shepherd <masterdriverz@gentoo.org> | 2007-11-07 00:11:20 +0000 |
commit | 60c2e3eb81abfaeea2c893d8a69d9b9802877d04 (patch) | |
tree | 3481cd5528cc0966301caa83804ad1f0bfc0708e /toys/mkfifo.c | |
parent | 2c226859cfc911c4a1eea009897050a16714aeec (diff) | |
download | toybox-60c2e3eb81abfaeea2c893d8a69d9b9802877d04.tar.gz |
Add initial mkfifo implementation
Diffstat (limited to 'toys/mkfifo.c')
-rw-r--r-- | toys/mkfifo.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/toys/mkfifo.c b/toys/mkfifo.c new file mode 100644 index 00000000..f7cc5b6b --- /dev/null +++ b/toys/mkfifo.c @@ -0,0 +1,39 @@ +/* vi: set sw=4 ts=4: */ +/* + * mkfifo.c: Create a named pipe. + */ + +#include "toys.h" + +int mkfifo_main(void) +{ + char *arg; + int i; + mode_t mode; + + if (toys.optflags) { + long temp; + char *end; + int len = strlen(toy.mkfifo.mode); + temp = strtol(toy.mkfifo.mode, &end, 8); + switch (temp) { + case LONG_MAX: + case LONG_MIN: + case 0: + if (!errno) + break; + error_exit("Invalid mode"); + } + if (temp > 0777 || *end || len < 3 || len > 4) + error_exit("Invalid mode"); + mode = (mode_t)temp; + } else { + mode = 0644; + } + + for (i = 0; (arg = toys.optargs[i]); i++) + if (mkfifo(arg, mode)) + perror_exit(arg); + + return 0; +} |