mkfifo.c 802 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * mkfifo implementation for busybox
  4. *
  5. * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  8. */
  9. /* BB_AUDIT SUSv3 compliant */
  10. /* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
  11. #include "libbb.h"
  12. #include "libcoreutils/coreutils.h"
  13. int mkfifo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  14. int mkfifo_main(int argc UNUSED_PARAM, char **argv)
  15. {
  16. mode_t mode;
  17. int retval = EXIT_SUCCESS;
  18. mode = getopt_mk_fifo_nod(argv);
  19. argv += optind;
  20. if (!*argv) {
  21. bb_show_usage();
  22. }
  23. do {
  24. if (mkfifo(*argv, mode) < 0) {
  25. bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
  26. retval = EXIT_FAILURE;
  27. }
  28. } while (*++argv);
  29. return retval;
  30. }