# HG changeset patch # User Eric Blake # Date 1252322893 21600 # Node ID 25d12bf7e5bf6ef682a3c8250829e3d574587c61 # Parent 98e4db1661ccd1ec8f7b5be1ac6df41a2036f8f2 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 diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-09-07 Eric Blake + + 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 doc: fix comments in recent patches diff --git a/lib/openat.h b/lib/openat.h --- 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 */ diff --git a/lib/unistd.in.h b/lib/unistd.in.h --- 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 diff --git a/modules/faccessat b/modules/faccessat --- 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: diff --git a/top/maint.mk b/top/maint.mk --- 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.