aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2017-11-13 10:54:20 -0800
committerPaul Eggert2017-11-13 10:54:20 -0800
commit99ceefa8ec4f9993663492cfcce6bb82a94569c1 (patch)
tree507f76715b3086f34672b7c984dc09befaa57fc6 /lib
parenta7b7b85567f766ff510a5eaaaf32dbbbec15efd0 (diff)
parent79108894dbcd642121466bb6af6c98c6a56e9233 (diff)
downloademacs-99ceefa8ec4f9993663492cfcce6bb82a94569c1.tar.gz
emacs-99ceefa8ec4f9993663492cfcce6bb82a94569c1.zip
Merge from origin/emacs-26
79108894db Port to IBM xlc 12.01 d14956099d Simplify by removing HAVE_STRUCT_ATTRIBUTE_ALIGNED b1573a97e1 Use alignas to fix GCALIGN-related bugs 5d68dc9a2f Change vectorlike from struct to union 6aa0a26b46 Don't enable cursor-sensor-mode in mhtml-mode 2b8ef8dddf * lisp/files.el (abbreviate-file-name): Doc fix. (Bug#29267) fe85ce1e16 Unbreak interactive run of a flymake test (bug#29267) 48ad00390d Fix Bug#29225 42daf83f08 CC Mode: Fix defun-open being recognized as brace-list-ope... 7775c47298 Merge from Gnulib e470d16448 Pacify GCC when configured --with-x-toolkit=no 49450d0951 * lisp/find-dired.el (find-grep-dired): Doc fix. (Bug#29262) e286b3381f Fix more flymake-diag-region eob corner cases and add test... # Conflicts: # src/lisp.h
Diffstat (limited to 'lib')
-rw-r--r--lib/faccessat.c60
-rw-r--r--lib/fstatat.c2
-rw-r--r--lib/gnulib.mk.in2
-rw-r--r--lib/unistd.in.h16
4 files changed, 70 insertions, 10 deletions
diff --git a/lib/faccessat.c b/lib/faccessat.c
index 6cf9c99df20..fa9235820dc 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -16,10 +16,31 @@
16 16
17/* written by Eric Blake */ 17/* written by Eric Blake */
18 18
19/* If the user's config.h happens to include <unistd.h>, let it include only
20 the system's <unistd.h> here, so that orig_faccessat doesn't recurse to
21 rpl_faccessat. */
22#define _GL_INCLUDING_UNISTD_H
19#include <config.h> 23#include <config.h>
20 24
21#include <unistd.h> 25#include <unistd.h>
26#include <errno.h>
22#include <fcntl.h> 27#include <fcntl.h>
28#include <string.h>
29#include <sys/stat.h>
30#undef _GL_INCLUDING_UNISTD_H
31
32#if HAVE_FACCESSAT
33static int
34orig_faccessat (int fd, char const *name, int mode, int flag)
35{
36 return faccessat (fd, name, mode, flag);
37}
38#endif
39
40/* Write "unistd.h" here, not <unistd.h>, otherwise OSF/1 5.1 DTK cc
41 eliminates this include because of the preliminary #include <unistd.h>
42 above. */
43#include "unistd.h"
23 44
24#ifndef HAVE_ACCESS 45#ifndef HAVE_ACCESS
25/* Mingw lacks access, but it also lacks real vs. effective ids, so 46/* Mingw lacks access, but it also lacks real vs. effective ids, so
@@ -28,6 +49,29 @@
28# define access euidaccess 49# define access euidaccess
29#endif 50#endif
30 51
52#if HAVE_FACCESSAT
53
54int
55rpl_faccessat (int fd, char const *file, int mode, int flag)
56{
57 int result = orig_faccessat (fd, file, mode, flag);
58
59 if (result == 0 && file[strlen (file) - 1] == '/')
60 {
61 struct stat st;
62 result = fstatat (fd, file, &st, 0);
63 if (result == 0 && !S_ISDIR (st.st_mode))
64 {
65 errno = ENOTDIR;
66 return -1;
67 }
68 }
69
70 return result;
71}
72
73#else /* !HAVE_FACCESSAT */
74
31/* Invoke access or euidaccess on file, FILE, using mode MODE, in the directory 75/* Invoke access or euidaccess on file, FILE, using mode MODE, in the directory
32 open on descriptor FD. If possible, do it without changing the 76 open on descriptor FD. If possible, do it without changing the
33 working directory. Otherwise, resort to using save_cwd/fchdir, then 77 working directory. Otherwise, resort to using save_cwd/fchdir, then
@@ -36,10 +80,12 @@
36 Note that this implementation only supports AT_EACCESS, although some 80 Note that this implementation only supports AT_EACCESS, although some
37 native versions also support AT_SYMLINK_NOFOLLOW. */ 81 native versions also support AT_SYMLINK_NOFOLLOW. */
38 82
39#define AT_FUNC_NAME faccessat 83# define AT_FUNC_NAME faccessat
40#define AT_FUNC_F1 euidaccess 84# define AT_FUNC_F1 euidaccess
41#define AT_FUNC_F2 access 85# define AT_FUNC_F2 access
42#define AT_FUNC_USE_F1_COND AT_EACCESS 86# define AT_FUNC_USE_F1_COND AT_EACCESS
43#define AT_FUNC_POST_FILE_PARAM_DECLS , int mode, int flag 87# define AT_FUNC_POST_FILE_PARAM_DECLS , int mode, int flag
44#define AT_FUNC_POST_FILE_ARGS , mode 88# define AT_FUNC_POST_FILE_ARGS , mode
45#include "at-func.c" 89# include "at-func.c"
90
91#endif
diff --git a/lib/fstatat.c b/lib/fstatat.c
index 67e48d95d71..294861f51b1 100644
--- a/lib/fstatat.c
+++ b/lib/fstatat.c
@@ -28,7 +28,7 @@
28#include <sys/stat.h> 28#include <sys/stat.h>
29#undef __need_system_sys_stat_h 29#undef __need_system_sys_stat_h
30 30
31#if HAVE_FSTATAT 31#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG
32static int 32static int
33orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) 33orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
34{ 34{
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index e9358a6855d..a7b33ba34e8 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -689,6 +689,7 @@ REPLACE_DIRFD = @REPLACE_DIRFD@
689REPLACE_DPRINTF = @REPLACE_DPRINTF@ 689REPLACE_DPRINTF = @REPLACE_DPRINTF@
690REPLACE_DUP = @REPLACE_DUP@ 690REPLACE_DUP = @REPLACE_DUP@
691REPLACE_DUP2 = @REPLACE_DUP2@ 691REPLACE_DUP2 = @REPLACE_DUP2@
692REPLACE_FACCESSAT = @REPLACE_FACCESSAT@
692REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@ 693REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
693REPLACE_FCLOSE = @REPLACE_FCLOSE@ 694REPLACE_FCLOSE = @REPLACE_FCLOSE@
694REPLACE_FCNTL = @REPLACE_FCNTL@ 695REPLACE_FCNTL = @REPLACE_FCNTL@
@@ -2997,6 +2998,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2997 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ 2998 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
2998 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ 2999 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
2999 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ 3000 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
3001 -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
3000 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ 3002 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
3001 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ 3003 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
3002 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 3004 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index ca8090a3526..91447835811 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -461,13 +461,25 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
461 461
462 462
463#if @GNULIB_FACCESSAT@ 463#if @GNULIB_FACCESSAT@
464# if !@HAVE_FACCESSAT@ 464# if @REPLACE_FACCESSAT@
465# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466# undef faccessat
467# define faccessat rpl_faccessat
468# endif
469_GL_FUNCDECL_RPL (faccessat, int,
470 (int fd, char const *name, int mode, int flag)
471 _GL_ARG_NONNULL ((2)));
472_GL_CXXALIAS_RPL (faccessat, int,
473 (int fd, char const *name, int mode, int flag));
474# else
475# if !@HAVE_FACCESSAT@
465_GL_FUNCDECL_SYS (faccessat, int, 476_GL_FUNCDECL_SYS (faccessat, int,
466 (int fd, char const *file, int mode, int flag) 477 (int fd, char const *file, int mode, int flag)
467 _GL_ARG_NONNULL ((2))); 478 _GL_ARG_NONNULL ((2)));
468# endif 479# endif
469_GL_CXXALIAS_SYS (faccessat, int, 480_GL_CXXALIAS_SYS (faccessat, int,
470 (int fd, char const *file, int mode, int flag)); 481 (int fd, char const *file, int mode, int flag));
482# endif
471_GL_CXXALIASWARN (faccessat); 483_GL_CXXALIASWARN (faccessat);
472#elif defined GNULIB_POSIXCHECK 484#elif defined GNULIB_POSIXCHECK
473# undef faccessat 485# undef faccessat