Mercurial > hg > toybox
view toys/mkfifo.c @ 167:f16c8e5e9435
Replace strlcpy() with xstrcpy(), which exits if the string won't fit.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 19 Nov 2007 01:51:00 -0600 |
parents | 714f4c051594 |
children | 14fa82969ea3 |
line wrap: on
line source
/* 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; }