1 /* @(#)mkfifo.c 1.1 13/10/27 Copyright 2013 J. Schilling */ 2 /* 3 * Emulate the behavior of mkfifo(const char *name, mode_t mode) 4 * 5 * Copyright (c) 2013 J. Schilling 6 */ 7 /* 8 * The contents of this file are subject to the terms of the 9 * Common Development and Distribution License, Version 1.0 only 10 * (the "License"). You may not use this file except in compliance 11 * with the License. 12 * 13 * See the file CDDL.Schily.txt in this distribution for details. 14 * A copy of the CDDL is also available via the Internet at 15 * http://www.opensource.org/licenses/cddl1.txt 16 * 17 * When distributing Covered Code, include this CDDL HEADER in each 18 * file and include the License file CDDL.Schily.txt from this distribution. 19 */ 20 21 #include <schily/unistd.h> 22 #include <schily/types.h> 23 #include <schily/time.h> 24 #include <schily/fcntl.h> 25 #include <schily/stat.h> 26 #include <schily/errno.h> 27 #include <schily/standard.h> 28 #include <schily/schily.h> 29 30 #ifndef HAVE_MKFIFO 31 32 #define S_ALLPERM (S_IRWXU|S_IRWXG|S_IRWXO) 33 #define S_ALLFLAGS (S_ISUID|S_ISGID|S_ISVTX) 34 #define S_ALLMODES (S_ALLFLAGS | S_ALLPERM) 35 36 #ifdef PROTOTYPES 37 EXPORT int mkfifo(const char * name,mode_t mode)38mkfifo(const char *name, mode_t mode) 39 #else 40 EXPORT int 41 mkfifo(name, mode) 42 const char *name; 43 mode_t mode; 44 #endif 45 { 46 #ifdef HAVE_MKNOD 47 return (mknod(name, S_IFIFO | (mode & S_ALLMODES), 0)); 48 #else 49 #ifdef ENOSYS 50 seterrno(ENOSYS); 51 #else 52 seterrno(EINVAL); 53 #endif 54 return (-1); 55 #endif 56 } 57 58 #endif /* HAVE_MKFIFO */ 59