[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] faccessat, etc.: support AT_FDCWD-only use
From: |
Paul Eggert |
Subject: |
[PATCH 3/3] faccessat, etc.: support AT_FDCWD-only use |
Date: |
Sun, 14 Oct 2012 22:57:19 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 |
* lib/at-func.c: If GNULIB_SUPPORT_ONLY_AT_FDCWD, then support
this function only if its first argument is AT_FDCWD.
Emacs wants faccessat for AT_EACCESS but not for any first-arg
values other than AT_FDCWD, so it doesn't want all the openat
machinery with fchdir etc.
* modules/faccessat, modules/fchmodat, modules/fchownat (Files):
* modules/fstatat, modules/mkdirat, modules/openat (Files):
* modules/unlinkat (Files):
Remove lib/openat-priv.h, as at-internal supplies this file.
Removing this file here allows us to support programs like Emacs
that avoid at-internal.
---
ChangeLog | 13 +++++++++++++
lib/at-func.c | 31 +++++++++++++++++++++++--------
modules/faccessat | 1 -
modules/fchmodat | 1 -
modules/fchownat | 1 -
modules/fstatat | 1 -
modules/mkdirat | 1 -
modules/openat | 1 -
modules/unlinkat | 1 -
9 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e340e84..45637f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2012-10-14 Paul Eggert <address@hidden>
+ faccessat, etc.: support AT_FDCWD-only use
+ * lib/at-func.c: If GNULIB_SUPPORT_ONLY_AT_FDCWD, then support
+ this function only if its first argument is AT_FDCWD.
+ Emacs wants faccessat for AT_EACCESS but not for any first-arg
+ values other than AT_FDCWD, so it doesn't want all the openat
+ machinery with fchdir etc.
+ * modules/faccessat, modules/fchmodat, modules/fchownat (Files):
+ * modules/fstatat, modules/mkdirat, modules/openat (Files):
+ * modules/unlinkat (Files):
+ Remove lib/openat-priv.h, as at-internal supplies this file.
+ Removing this file here allows us to support programs like Emacs
+ that avoid at-internal.
+
faccessat: speed up 'configure' on mainstream hosts
* m4/faccessat.m4 (gl_PREREQ_FACCESSAT):
Use AT_CHECK_FUNCS for 'access', not AC_CHECK_FUNCS_ONCE,
diff --git a/lib/at-func.c b/lib/at-func.c
index b25bc4d..481eea4 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -17,9 +17,17 @@
/* written by Jim Meyering */
#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
-#include "openat.h"
-#include "openat-priv.h"
-#include "save-cwd.h"
+
+#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
+# include <errno.h>
+# ifndef ENOTSUP
+# define ENOTSUP EINVAL
+# endif
+#else
+# include "openat.h"
+# include "openat-priv.h"
+# include "save-cwd.h"
+#endif
#ifdef AT_FUNC_USE_F1_COND
# define CALL_FUNC(F) \
@@ -61,17 +69,22 @@
FUNC_RESULT
AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
{
+ VALIDATE_FLAG (flag);
+
+ if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
+ return CALL_FUNC (file);
+
+#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
+ errno = ENOTSUP;
+ return FUNC_FAIL;
+#else
+ {
/* Be careful to choose names unlikely to conflict with
AT_FUNC_POST_FILE_PARAM_DECLS. */
struct saved_cwd saved_cwd;
int saved_errno;
FUNC_RESULT err;
- VALIDATE_FLAG (flag);
-
- if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
- return CALL_FUNC (file);
-
{
char proc_buf[OPENAT_BUFFER_SIZE];
char *proc_file = openat_proc_name (proc_buf, fd, file);
@@ -125,6 +138,8 @@ AT_FUNC_NAME (int fd, char const *file
AT_FUNC_POST_FILE_PARAM_DECLS)
if (saved_errno)
errno = saved_errno;
return err;
+ }
+#endif
}
#undef CALL_FUNC
#undef FUNC_RESULT
diff --git a/modules/faccessat b/modules/faccessat
index 768ec13..ee4f2a5 100644
--- a/modules/faccessat
+++ b/modules/faccessat
@@ -4,7 +4,6 @@ faccessat() function: check user's permissions for a file.
Files:
lib/faccessat.c
lib/at-func.c
-lib/openat-priv.h
m4/faccessat.m4
Depends-on:
diff --git a/modules/fchmodat b/modules/fchmodat
index 94fad77..44cc919 100644
--- a/modules/fchmodat
+++ b/modules/fchmodat
@@ -4,7 +4,6 @@ fchmodat() function: Change access permissions of a file at a
directory.
Files:
lib/fchmodat.c
lib/at-func.c
-lib/openat-priv.h
m4/fchmodat.m4
Depends-on:
diff --git a/modules/fchownat b/modules/fchownat
index 7fba3ed..0b16be8 100644
--- a/modules/fchownat
+++ b/modules/fchownat
@@ -4,7 +4,6 @@ fchownat() function: Change the owner of a file at a directory.
Files:
lib/fchownat.c
lib/at-func.c
-lib/openat-priv.h
m4/fchownat.m4
Depends-on:
diff --git a/modules/fstatat b/modules/fstatat
index 69e9a7b..9b260d4 100644
--- a/modules/fstatat
+++ b/modules/fstatat
@@ -4,7 +4,6 @@ fstatat() function: Return information about a file at a
directory.
Files:
lib/fstatat.c
lib/at-func.c
-lib/openat-priv.h
m4/fstatat.m4
m4/lstat.m4
diff --git a/modules/mkdirat b/modules/mkdirat
index 0108920..0fe638a 100644
--- a/modules/mkdirat
+++ b/modules/mkdirat
@@ -4,7 +4,6 @@ mkdirat() function: Create a directory relative to a given
directory.
Files:
lib/mkdirat.c
lib/at-func.c
-lib/openat-priv.h
m4/mkdirat.m4
Depends-on:
diff --git a/modules/openat b/modules/openat
index 7846401..0db086a 100644
--- a/modules/openat
+++ b/modules/openat
@@ -3,7 +3,6 @@ openat() function: Open a file at a directory.
Files:
lib/openat.c
-lib/openat-priv.h
m4/openat.m4
m4/lstat.m4
m4/mode_t.m4
diff --git a/modules/unlinkat b/modules/unlinkat
index 4a7b87e..97e201c 100644
--- a/modules/unlinkat
+++ b/modules/unlinkat
@@ -4,7 +4,6 @@ unlinkat() function: Remove a file at a directory.
Files:
lib/unlinkat.c
lib/at-func.c
-lib/openat-priv.h
m4/unlinkat.m4
m4/lstat.m4
--
1.7.11.7
- [PATCH 3/3] faccessat, etc.: support AT_FDCWD-only use,
Paul Eggert <=