openat: provide more convenience names
[gnulib.git] / lib / openat.h
index 1d8596f..433b998 100644 (file)
@@ -81,4 +81,34 @@ lchmodat (int fd, char const *file, mode_t mode)
   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 */