mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-05-13 15:13:36 +00:00
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define _GL_UNUSED as an alias of _GL_ATTRIBUTE_MAYBE_UNUSED, not of _GL_ATTRIBUTE_UNUSED. * lib/binary-io.h (__gl_setmode): Put _GL_UNUSED before, not after, the declaration. * lib/c-stack.c (null_action, segv_handler, overflow_handler, c_stack_action): Likewise. * lib/chown.c (chown): Likewise. * lib/clean-temp-simple.c (cleanup_action): Likewise. * lib/fts.c (dirent_inode_sort_may_be_useful, leaf_optimization, fts_set): Likewise. * lib/getgroups.c (getgroups): Likewise. * lib/getopt.c (_getopt_initialize): Likewise. * lib/getugroups.c (getugroups): Likewise. * lib/localename.c (gl_locale_name_thread_unsafe, gl_locale_name_thread, gl_locale_name_posix, gl_locale_name_environ): Likewise. * lib/mkdir.c (rpl_mkdir): Likewise. * lib/mkfifo.c (mkfifo): Likewise. * lib/mkfifoat.c (mkfifoat): Likewise. * lib/mknod.c (mknod): Likewise. * lib/mknodat.c (mknodat): Likewise. * lib/mountlist.c (me_remote): Likewise. * lib/openpty.c (openpty): Likewise. * lib/parse-datetime.y (yyerror): Likewise. * lib/passfd.c (sendfd, recvfd): Likewise. * lib/pthread-cond.c (pthread_condattr_destroy, pthread_cond_init, pthread_cond_wait, pthread_cond_timedwait, pthread_cond_signal, pthread_cond_broadcast, pthread_cond_destroy): Likewise. * lib/pthread-mutex.c (pthread_mutexattr_destroy, pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_timedlock, pthread_mutex_unlock, pthread_mutex_destroy): Likewise. * lib/pthread-rwlock.c (pthread_rwlockattr_destroy, pthread_rwlock_init, pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock): Likewise. * lib/pthread-spin.c (pthread_spin_init, pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy): Likewise. * lib/pthread-thread.c (pthread_attr_destroy): Likewise. * lib/readlink.c (readlink): Likewise. * lib/rename.c (rpl_rename): Likewise. * lib/set-permissions.c (set_permissions): Likewise. * lib/sockets.c (gl_sockets_startup): Likewise. * lib/stat-time.h (get_stat_birthtime_ns, get_stat_birthtime, stat_time_normalize): Likewise. * lib/strptime.c (__strptime_internal): Likewise. * lib/strtod.c (LDEXP): Likewise. * lib/symlink.c (symlink): Likewise. * lib/symlinkat.c (symlinkat): Likewise. * lib/tempname.c (try_dir, try_nocreate): Likewise. * lib/textstyle.in.h (styled_ostream_begin_use_class, styled_ostream_end_use_class, styled_ostream_get_hyperlink_ref, styled_ostream_get_hyperlink_id, styled_ostream_set_hyperlink, styled_ostream_flush_to_current_style, fd_ostream_create, term_ostream_get_color, term_ostream_set_color, term_ostream_get_bgcolor, term_ostream_set_bgcolor, term_ostream_get_weight, term_ostream_set_weight, term_ostream_get_posture, term_ostream_set_posture, term_ostream_get_underline, term_ostream_set_underline, term_ostream_get_hyperlink_ref, term_ostream_get_hyperlink_id, term_ostream_set_hyperlink, term_ostream_create, term_styled_ostream_create, html_styled_ostream_create, handle_color_option, handle_style_option, style_file_prepare, styled_ostream_create, libtextstyle_set_failure_exit_code): Likewise. * lib/unicodeio.c (exit_failure_callback, fallback_failure_callback): Likewise. * lib/wait-process.c (cleanup_slaves_action): Likewise. * tests/signature.h (SIGNATURE_CHECK2): Likewise. * tests/test-areadlink.c (do_areadlink): Likewise. * tests/test-areadlinkat.c (do_areadlinkat): Likewise. * tests/test-ceilf-ieee.c (main): Likewise. * tests/test-ceilf1.c (main): Likewise. * tests/test-dirent.c (dir): Likewise. * tests/test-fchownat.c (main): Likewise. * tests/test-fdopendir.c (main): Likewise. * tests/test-filenamecat.c (main): Likewise. * tests/test-floor1.c (main): Likewise. * tests/test-floorf-ieee.c (main): Likewise. * tests/test-floorf1.c (main): Likewise. * tests/test-fseeko.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-ftello.c (main): Likewise. * tests/test-getdomainname.c (main): Likewise. * tests/test-getgroups.c (main): Likewise. * tests/test-gethostname.c (main): Likewise. * tests/test-math-c++.cc (OVERLOADED_CHECK): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-openat.c (main): Likewise. * tests/test-parse-datetime.c (main): Likewise. * tests/test-quotearg-simple.c (main): Likewise. * tests/test-quotearg.c (main): Likewise. * tests/test-sethostname2.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-version-etc.c (main): Likewise. * tests/test-xalloc-die.c (main): Likewise. * tests/test-xfprintf-posix.c (main): Likewise. * tests/test-xprintf-posix.c (main): Likewise. * tests/test-xvasprintf.c (main): Likewise.
97 lines
2.5 KiB
C
97 lines
2.5 KiB
C
/* Create a named fifo relative to an open directory.
|
|
Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
/* written by Eric Blake */
|
|
|
|
#include <config.h>
|
|
|
|
/* Specification. */
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#if HAVE_MKFIFOAT
|
|
|
|
# include <errno.h>
|
|
# include <fcntl.h>
|
|
# include <string.h>
|
|
|
|
int
|
|
rpl_mkfifoat (int fd, char const *file, mode_t mode)
|
|
#undef mkfifoat
|
|
{
|
|
/* Use the original mkfifoat(), but correct the trailing slash handling. */
|
|
size_t len = strlen (file);
|
|
if (len && file[len - 1] == '/')
|
|
{
|
|
struct stat st;
|
|
|
|
if (fstatat (fd, file, &st, AT_SYMLINK_NOFOLLOW) < 0)
|
|
{
|
|
if (errno == EOVERFLOW)
|
|
/* It's surely a file, not a directory. */
|
|
errno = ENOTDIR;
|
|
}
|
|
else
|
|
{
|
|
/* It's a directory, otherwise fstatat() would have reported an error
|
|
ENOTDIR. */
|
|
errno = EEXIST;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
return mkfifoat (fd, file, mode);
|
|
}
|
|
|
|
#else
|
|
|
|
# if !HAVE_MKFIFO
|
|
|
|
# include <errno.h>
|
|
|
|
/* Mingw lacks mkfifo, so this wrapper is trivial. */
|
|
|
|
int
|
|
mkfifoat (_GL_UNUSED int fd, _GL_UNUSED char const *path,
|
|
_GL_UNUSED mode_t mode)
|
|
{
|
|
errno = ENOSYS;
|
|
return -1;
|
|
}
|
|
|
|
# else /* HAVE_MKFIFO */
|
|
|
|
/* Create a named fifo FILE relative to directory FD, with access
|
|
permissions in MODE. If possible, do it without changing the
|
|
working directory. Otherwise, resort to using save_cwd/fchdir,
|
|
then mkfifo/restore_cwd. If either the save_cwd or the restore_cwd
|
|
fails, then give a diagnostic and exit nonzero. */
|
|
|
|
# define AT_FUNC_NAME mkfifoat
|
|
# define AT_FUNC_F1 mkfifo
|
|
# define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode
|
|
# define AT_FUNC_POST_FILE_ARGS , mode
|
|
# include "at-func.c"
|
|
# undef AT_FUNC_NAME
|
|
# undef AT_FUNC_F1
|
|
# undef AT_FUNC_POST_FILE_PARAM_DECLS
|
|
# undef AT_FUNC_POST_FILE_ARGS
|
|
|
|
# endif /* HAVE_MKFIFO */
|
|
|
|
#endif /* HAVE_MKFIFOAT */
|