mkfifo.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 source tree.
  8. */
  9. /* BB_AUDIT SUSv3 compliant */
  10. /* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
  11. //usage:#define mkfifo_trivial_usage
  12. //usage: "[-m MODE] " IF_SELINUX("[-Z] ") "NAME"
  13. //usage:#define mkfifo_full_usage "\n\n"
  14. //usage: "Create named pipe\n"
  15. //usage: "\n -m MODE Mode (default a=rw)"
  16. //usage: IF_SELINUX(
  17. //usage: "\n -Z Set security context"
  18. //usage: )
  19. #include "libbb.h"
  20. #include "libcoreutils/coreutils.h"
  21. /* This is a NOEXEC applet. Be very careful! */
  22. int mkfifo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  23. int mkfifo_main(int argc UNUSED_PARAM, char **argv)
  24. {
  25. mode_t mode;
  26. int retval = EXIT_SUCCESS;
  27. mode = getopt_mk_fifo_nod(argv);
  28. argv += optind;
  29. if (!*argv) {
  30. bb_show_usage();
  31. }
  32. do {
  33. if (mkfifo(*argv, mode) < 0) {
  34. bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
  35. retval = EXIT_FAILURE;
  36. }
  37. } while (*++argv);
  38. return retval;
  39. }