]> git.cworth.org Git - tar/blob - gnu/mkfifo.c
Imported Upstream version 1.24
[tar] / gnu / mkfifo.c
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Create a named fifo.
4    Copyright (C) 2009, 2010 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 /* written by Eric Blake */
20
21 #include <config.h>
22
23 #include <sys/stat.h>
24
25 #include <errno.h>
26 #include <string.h>
27
28 #if !HAVE_MKFIFO
29 /* Mingw lacks mkfifo; always fail with ENOSYS.  */
30
31 int
32 mkfifo (char const *name _GL_UNUSED, mode_t mode _GL_UNUSED)
33 {
34   errno = ENOSYS;
35   return -1;
36 }
37
38 #else /* HAVE_MKFIFO */
39
40 # undef mkfifo
41
42 /* Create a named fifo FILE, with access permissions in MODE.  Work
43 around trailing slash bugs.  */
44
45 int
46 rpl_mkfifo (char const *name, mode_t mode)
47 {
48 # if MKFIFO_TRAILING_SLASH_BUG
49   size_t len = strlen (name);
50   if (len && name[len - 1] == '/')
51     {
52       struct stat st;
53       if (stat (name, &st) == 0)
54         errno = EEXIST;
55       return -1;
56     }
57 # endif
58   return mkfifo (name, mode);
59 }
60 #endif /* HAVE_MKFIFO */