10f66f451Sopenharmony_ci/* mkfifo.c - Create FIFOs (named pipes) 20f66f451Sopenharmony_ci * 30f66f451Sopenharmony_ci * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org> 40f66f451Sopenharmony_ci * 50f66f451Sopenharmony_ci * See http://opengroup.org/onlinepubs/9699919799/utilities/mkfifo.html 60f66f451Sopenharmony_ci 70f66f451Sopenharmony_ciUSE_MKFIFO(NEWTOY(mkfifo, "<1"USE_MKFIFO_Z("Z:")"m:", TOYFLAG_USR|TOYFLAG_BIN)) 80f66f451Sopenharmony_ci 90f66f451Sopenharmony_ciconfig MKFIFO 100f66f451Sopenharmony_ci bool "mkfifo" 110f66f451Sopenharmony_ci default y 120f66f451Sopenharmony_ci help 130f66f451Sopenharmony_ci usage: mkfifo [NAME...] 140f66f451Sopenharmony_ci 150f66f451Sopenharmony_ci Create FIFOs (named pipes). 160f66f451Sopenharmony_ci 170f66f451Sopenharmony_ciconfig MKFIFO_Z 180f66f451Sopenharmony_ci bool 190f66f451Sopenharmony_ci default y 200f66f451Sopenharmony_ci depends on MKFIFO && !TOYBOX_LSM_NONE 210f66f451Sopenharmony_ci help 220f66f451Sopenharmony_ci usage: mkfifo [-Z CONTEXT] 230f66f451Sopenharmony_ci 240f66f451Sopenharmony_ci -Z Security context 250f66f451Sopenharmony_ci*/ 260f66f451Sopenharmony_ci 270f66f451Sopenharmony_ci#define FOR_mkfifo 280f66f451Sopenharmony_ci#include "toys.h" 290f66f451Sopenharmony_ci 300f66f451Sopenharmony_ciGLOBALS( 310f66f451Sopenharmony_ci char *m; 320f66f451Sopenharmony_ci char *Z; 330f66f451Sopenharmony_ci 340f66f451Sopenharmony_ci mode_t mode; 350f66f451Sopenharmony_ci) 360f66f451Sopenharmony_ci 370f66f451Sopenharmony_civoid mkfifo_main(void) 380f66f451Sopenharmony_ci{ 390f66f451Sopenharmony_ci char **s; 400f66f451Sopenharmony_ci 410f66f451Sopenharmony_ci TT.mode = 0666; 420f66f451Sopenharmony_ci if (toys.optflags & FLAG_m) TT.mode = string_to_mode(TT.m, 0); 430f66f451Sopenharmony_ci 440f66f451Sopenharmony_ci if (CFG_MKFIFO_Z && (toys.optflags&FLAG_Z)) 450f66f451Sopenharmony_ci if (0>lsm_set_create(TT.Z)) 460f66f451Sopenharmony_ci perror_exit("-Z '%s' failed", TT.Z); 470f66f451Sopenharmony_ci 480f66f451Sopenharmony_ci for (s = toys.optargs; *s; s++) 490f66f451Sopenharmony_ci if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) perror_msg_raw(*s); 500f66f451Sopenharmony_ci} 51