2012-10-14 Paul Eggert <eggert@cs.ucla.edu>
+ 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,
/* 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) \
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);
if (saved_errno)
errno = saved_errno;
return err;
+ }
+#endif
}
#undef CALL_FUNC
#undef FUNC_RESULT