* lib/openat.h (statat, lstatat): Now deprecated.
All uses removed, and replaced with fstatat.
* modules/statat: Mark as obsolete, because it’s confusing:
it’s not clear whether it should use AT_NO_AUTOMOUNT,
which is implied by stat and by lstat, but not by fstatat.
* tests/test-statat.c: Disable deprecated-declarations warnings.
2022-03-09 Paul Eggert <eggert@cs.ucla.edu>
+ statat: now obsolete
+ * lib/openat.h (statat, lstatat): Now deprecated.
+ All uses removed, and replaced with fstatat.
+ * modules/statat: Mark as obsolete, because it’s confusing:
+ it’s not clear whether it should use AT_NO_AUTOMOUNT,
+ which is implied by stat and by lstat, but not by fstatat.
+ * tests/test-statat.c: Disable deprecated-declarations warnings.
+
fts: be consistent about AT_NO_AUTOMOUNT
* lib/fts.c (fts_stat): Use fstatat with AT_NO_AUTOMOUNT
consistently, instead of sometimes using stat (which implies
Date Modules Changes
+2022-03-09 statat This module is deprecated. Use fstatat instead,
+ to specify whether you want AT_NO_AUTOMOUNT.
+
2022-01-05 stack This module now uses idx_t instead of size_t
for indexes and counts.
struct stat st;
if (len && file[len - 1] == '/')
{
- if (statat (fd, file, &st))
+ if (fstatat (fd, file, &st, 0))
return -1;
if (flag == AT_SYMLINK_NOFOLLOW)
return fchownat (fd, file, owner, group, 0);
# define STATAT_INLINE _GL_INLINE
# endif
+_GL_ATTRIBUTE_DEPRECATED
STATAT_INLINE int
statat (int fd, char const *name, struct stat *st)
{
return fstatat (fd, name, st, 0);
}
+_GL_ATTRIBUTE_DEPRECATED
STATAT_INLINE int
lstatat (int fd, char const *name, struct stat *st)
{
break;
case RENAME_NOREPLACE:
- /* This has a race between the call to lstatat and the calls to
- renameat below. This lstatat is needed even if RENAME_EXCL
+ /* This has a race between the call to fstatat and the calls to
+ renameat below. This fstatat is needed even if RENAME_EXCL
is defined, because RENAME_EXCL is buggy on macOS 11.2:
renameatx_np (fd, "X", fd, "X", RENAME_EXCL) incorrectly
succeeds when X exists. */
- if (lstatat (fd2, dst, &dst_st) == 0 || errno == EOVERFLOW)
+ if (fstatat (fd2, dst, &dst_st, AT_SYMLINK_NOFOLLOW) == 0
+ || errno == EOVERFLOW)
return errno_fail (EEXIST);
if (errno != ENOENT)
return -1;
the source does not exist, or if the destination cannot be turned
into a directory, give up now. Otherwise, strip trailing slashes
before calling rename. */
- if (lstatat (fd1, src, &src_st))
+ if (fstatat (fd1, src, &src_st, AT_SYMLINK_NOFOLLOW))
return -1;
if (dst_found_nonexistent)
{
if (!S_ISDIR (src_st.st_mode))
return errno_fail (ENOENT);
}
- else if (lstatat (fd2, dst, &dst_st))
+ else if (fstatat (fd2, dst, &dst_st, AT_SYMLINK_NOFOLLOW))
{
if (errno != ENOENT || !S_ISDIR (src_st.st_mode))
return -1;
goto out;
}
strip_trailing_slashes (src_temp);
- if (lstatat (fd1, src_temp, &src_st))
+ if (fstatat (fd1, src_temp, &src_st, AT_SYMLINK_NOFOLLOW))
{
rename_errno = errno;
goto out;
goto out;
}
strip_trailing_slashes (dst_temp);
- if (lstatat (fd2, dst_temp, &dst_st))
+ if (fstatat (fd2, dst_temp, &dst_st, AT_SYMLINK_NOFOLLOW))
{
if (errno != ENOENT)
{
rule of letting unlink("link-to-dir/") attempt to unlink a
directory. */
struct stat st;
- result = lstatat (fd, name, &st);
+ result = fstatat (fd, name, &st, AT_SYMLINK_NOFOLLOW);
if (result == 0 || errno == EOVERFLOW)
{
/* Trailing NUL will overwrite the trailing slash. */
memcpy (short_name, name, len);
while (len && ISSLASH (short_name[len - 1]))
short_name[--len] = '\0';
- if (len && (lstatat (fd, short_name, &st) || S_ISLNK (st.st_mode)))
+ if (len && (fstatat (fd, short_name, &st, AT_SYMLINK_NOFOLLOW)
+ || S_ISLNK (st.st_mode)))
{
free (short_name);
errno = EPERM;
openat-die [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
openat-h [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
save-cwd [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
-statat [test $REPLACE_FCHOWNAT = 1]
configure.ac:
gl_FUNC_FCHOWNAT
fcntl-h
filenamecat-lgpl [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
openat-h [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
-statat [test $REPLACE_RENAMEAT = 1]
stdbool [test $REPLACE_RENAMEAT = 1]
at-internal [test $HAVE_RENAMEAT = 0]
filename [test $HAVE_RENAMEAT = 0]
Description:
statat() and lstatat() functions: Return info about a file at a directory.
+Status:
+obsolete
+
+Notice:
+This module is obsolete. Please use fstatat instead, and decide
+whether you want AT_NO_AUTOMOUNT in each fstatat call.
+
Files:
lib/statat.c
fcntl-h [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
openat-h [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
sys_stat [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
-statat [test $REPLACE_UNLINKAT = 1]
at-internal [test $HAVE_UNLINKAT = 0]
errno [test $HAVE_UNLINKAT = 0]
fchdir [test $HAVE_UNLINKAT = 0]
#include "openat.h"
+#if 4 < __GNUC__ + (3 <= __GNUC_MINOR__)
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
#include "signature.h"
SIGNATURE_CHECK (statat, int, (int, char const *, struct stat *));
SIGNATURE_CHECK (lstatat, int, (int, char const *, struct stat *));