changeset 11969:25d12bf7e5bf

openat: provide more convenience names * modules/faccessat (configure.ac): Add C witness. * lib/unistd.in.h (readlinkat): Fix typo. * lib/openat.h (statat, lstatat, accessat, euidaccessat): New convenience wrappers. * top/maint.mk (sc_prohibit_openat_without_use): Allow these wrappers in syntax checks. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Mon, 07 Sep 2009 05:28:13 -0600
parents 98e4db1661cc
children 63e8cd4fe93a
files ChangeLog lib/openat.h lib/unistd.in.h modules/faccessat top/maint.mk
diffstat 5 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-09-07  Eric Blake  <ebb9@byu.net>
+
+	openat: provide more convenience names
+	* modules/faccessat (configure.ac): Add C witness.
+	* lib/unistd.in.h (readlinkat): Fix typo.
+	* lib/openat.h (statat, lstatat, accessat, euidaccessat): New
+	convenience wrappers.
+	* top/maint.mk (sc_prohibit_openat_without_use): Allow these
+	wrappers in syntax checks.
+
 2009-09-06  Eric Blake  <ebb9@byu.net>
 
 	doc: fix comments in recent patches
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -81,4 +81,34 @@
   return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
 }
 
+static inline int
+statat (int fd, char const *name, struct stat *st)
+{
+  return fstatat (fd, name, st, 0);
+}
+
+static inline int
+lstatat (int fd, char const *name, struct stat *st)
+{
+  return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
+}
+
+#if GNULIB_FACCESSAT
+/* For now, there are no wrappers named laccessat or leuidaccessat,
+   since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
+   since access rights on symlinks are of limited utility.  */
+
+static inline int
+accessat (int fd, char const *file, int mode)
+{
+  return faccessat (fd, file, mode, 0);
+}
+
+static inline int
+euidaccessat (int fd, char const *file, int mode)
+{
+  return faccessat (fd, file, mode, AT_EACCESS);
+}
+#endif
+
 #endif /* _GL_HEADER_OPENAT */
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -208,7 +208,7 @@
 #elif defined GNULIB_POSIXCHECK
 # undef readlinkat
 # define readlinkat(d,n,b,l)			     \
-    (GL_LINK_WARNING ("faccessat is not portable - " \
+    (GL_LINK_WARNING ("readlinkat is not portable - " \
                       "use gnulib module symlinkat for portability"), \
      readlinkat (d, n, b, l))
 #endif
--- a/modules/faccessat
+++ b/modules/faccessat
@@ -14,6 +14,7 @@
 
 configure.ac:
 gl_FUNC_FACCESSAT
+gl_MODULE_INDICATOR([faccessat])
 gl_UNISTD_MODULE_INDICATOR([faccessat])
 
 Makefile.am:
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -295,7 +295,7 @@
 
 sc_prohibit_openat_without_use:
 	@h='"openat.h"' \
-	re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?ch(own|mod)at)\>' \
+	re='\<(openat_(permissive|needs_fchdir|(save|restore)_fail)|l?(stat|ch(own|mod))at|(euid)?accessat)\>' \
 	  $(_header_without_use)
 
 # Prohibit the inclusion of c-ctype.h without an actual use.