1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Create a device inode.
4 Copyright (C) 2009-2011 Free Software Foundation, Inc.
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.
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.
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/>. */
19 /* written by Eric Blake */
29 /* Mingw lacks mknod; always fail with ENOSYS. */
32 mknod (char const *name _GL_UNUSED, mode_t mode _GL_UNUSED,
39 #else /* HAVE_MKNOD */
43 /* Create a file system node FILE, with access permissions and file
44 type in MODE, and device type in DEV. Usually, non-root
45 applications can only create named fifos (mode includes S_IFIFO),
46 with DEV set to 0. Also work around trailing slash bugs. */
49 rpl_mknod (char const *name, mode_t mode, dev_t dev)
51 # if MKFIFO_TRAILING_SLASH_BUG
52 /* Trailing slash only makes sense for directories. Of course,
53 using mknod to create a directory is not very portable, so it may
54 still fail later on. */
57 size_t len = strlen (name);
58 if (len && name[len - 1] == '/')
61 if (stat (name, &st) == 0)
68 /* POSIX requires mknod to create fifos for non-privileged
69 processes, but BSD implementations fail with EPERM. */
70 if (S_ISFIFO (mode) && dev == 0)
71 return mkfifo (name, mode & ~S_IFIFO);
73 return mknod (name, mode, dev);
76 #endif /* HAVE_MKNOD */