s6-mkfifodir.c (843B)
1 /* ISC license. */ 2 3 #include <sys/types.h> 4 #include <skalibs/sgetopt.h> 5 #include <skalibs/types.h> 6 #include <skalibs/strerr.h> 7 #include <s6/ftrigw.h> 8 9 #define USAGE "s6-mkfifodir [ -f ] [ -g gid ] fifodir" 10 11 int main (int argc, char const *const *argv) 12 { 13 subgetopt l = SUBGETOPT_ZERO ; 14 gid_t gid = -1 ; 15 int force = 0 ; 16 PROG = "s6-mkfifodir" ; 17 for (;;) 18 { 19 int opt = subgetopt_r(argc, argv, "fg:", &l) ; 20 if (opt == -1) break ; 21 switch (opt) 22 { 23 case 'f' : force = 1 ; break ; 24 case 'g' : if (!gid0_scan(l.arg, &gid)) strerr_dieusage(100, USAGE) ; break ; 25 default : strerr_dieusage(100, USAGE) ; 26 } 27 } 28 argc -= l.ind ; argv += l.ind ; 29 if (argc < 1) strerr_dieusage(100, USAGE) ; 30 31 if (!ftrigw_fifodir_make(*argv, gid, force)) 32 strerr_diefu2sys(111, "create fifodir at ", *argv) ; 33 return 0 ; 34 }