support_capture_subprocess_check (&result, "execv", 0, sc_allow_none);
support_capture_subprocess_free (&result);
- xstat (path, &fs);
+ xstat64 (path, &fs);
size = fs.st_size;
/* Run 3 tests, each truncating aux-cache shorter and shorter. */
TEST_COMPARE (xlseek (outfd, 0, SEEK_CUR), 6 + length);
struct stat64 st;
- xfstat (outfd, &st);
+ xfstat64 (outfd, &st);
if (length > 0)
TEST_COMPARE (st.st_size, out_skipped + length);
else
struct statx stx = { 0, };
TEST_COMPARE (statx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &stx), 0);
struct stat64 st;
- xfstat (fd, &st);
+ xfstat64 (fd, &st);
TEST_COMPARE (stx.stx_mode, st.st_mode);
TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
TEST_COMPARE (statx (AT_FDCWD, "/dev/null", 0, STATX_BASIC_STATS, &stx),
0);
struct stat64 st;
- xstat ("/dev/null", &st);
+ xstat64 ("/dev/null", &st);
TEST_COMPARE (stx.stx_mode, st.st_mode);
TEST_COMPARE (stx.stx_dev_major, major (st.st_dev));
TEST_COMPARE (stx.stx_dev_minor, minor (st.st_dev));
support_capture_subprocess_free (&result);
/* Verify path is present and is a directory. */
- xstat (path, &fs);
+ xstat64 (path, &fs);
if (!S_ISDIR (fs.st_mode))
{
support_record_failure ();
char *output;
output = xasprintf ("%s/%s", support_complocaledir_prefix, step.output);
- xstat (output, &locale);
+ xstat64 (output, &locale);
free (output);
TEST_COMPARE (locale.st_nlink, step.st_nlink);
}
tmp_sh = xasprintf ("%s/tmp_sh", tmp_dir);
add_temp_file (tmp_sh);
fd_out = xopen (symlink_name, O_CREAT | O_WRONLY, 0);
- xstat ("/bin/sh", &st);
+ xstat64 ("/bin/sh", &st);
fd = xopen ("/bin/sh", O_RDONLY, 0);
xcopy_file_range (fd, 0, fd_out, 0, st.st_size, 0);
xfchmod (fd_out, 0700);
check_size (const char *path, off64_t expected_size)
{
struct stat64 st;
- xstat (path, &st);
+ xstat64 (path, &st);
if (st.st_size != expected_size)
FAIL_EXIT1 ("file \"%s\": expected size %lld, actual size %lld",
path, (unsigned long long int) expected_size,
{
struct stat64 st;
- xstat (_PATH_BSHELL, &st);
+ xstat64 (_PATH_BSHELL, &st);
mode_t mode = st.st_mode;
xchmod (_PATH_BSHELL, mode & ~(S_IXUSR | S_IXGRP | S_IXOTH));
resolv_test \
set_fortify_handler \
support-open-dev-null-range \
- support-xfstat \
- support-xfstat-time64 \
- support-xstat \
- support-xstat-time64 \
support_become_root \
support_can_chroot \
support_capture_subprocess \
support_capture_subprocess_check \
+ support_check_stat_fd \
+ support_check_stat_path \
support_chroot \
support_copy_file \
support_copy_file_range \
xgetsockname \
xlisten \
xlseek \
- xlstat \
- xlstat-time64 \
xmalloc \
xmemstream \
xmkdir \
+++ /dev/null
-/* 64-bit time_t stat with error checking.
- Copyright (C) 2021-2024 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-#if __TIMESIZE != 64
-void
-xfstat_time64 (int fd, struct __stat64_t64 *result)
-{
- if (__fstat64_time64 (fd, result) != 0)
- FAIL_EXIT1 ("__fstat64_time64 (%d): %m", fd);
-}
-#endif
+++ /dev/null
-/* 64-bit time_t stat with error checking.
- Copyright (C) 2021-2024 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-#if __TIMESIZE != 64
-void
-xstat_time64 (const char *path, struct __stat64_t64 *result)
-{
- if (__stat64_time64 (path, result) != 0)
- FAIL_EXIT1 ("__stat64_time64 (\"%s\"): %m", path);
-}
-#endif
+++ /dev/null
-/* stat64 with error checking.
- Copyright (C) 2017-2024 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-void
-xstat (const char *path, struct stat64 *result)
-{
- if (stat64 (path, result) != 0)
- FAIL_EXIT1 ("stat64 (\"%s\"): %m", path);
-}
-/* lstat64 with error checking.
- Copyright (C) 2017-2024 Free Software Foundation, Inc.
+/* Error checking for descriptor-based stat functions.
+ Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#include <support/check.h>
#include <support/xunistd.h>
-#include <sys/stat.h>
void
-xlstat (const char *path, struct stat64 *result)
+support_check_stat_fd (const char *name, int fd, int result)
{
- if (lstat64 (path, result) != 0)
- FAIL_EXIT1 ("lstat64 (\"%s\"): %m", path);
+ if (result != 0)
+ FAIL_EXIT1 ("%s (%d): %m", name, fd);
}
-/* fstat64 with error checking.
+/* Error checking for path-based stat functions.
Copyright (C) 2017-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
#include <support/check.h>
#include <support/xunistd.h>
-#include <sys/stat.h>
void
-xfstat (int fd, struct stat64 *result)
+support_check_stat_path (const char *name, const char *path, int result)
{
- if (fstat64 (fd, result) != 0)
- FAIL_EXIT1 ("fstat64 (%d): %m", fd);
+ if (result != 0)
+ FAIL_EXIT1 ("%s (\"%s\"): %m", name, path);
}
+++ /dev/null
-/* 64-bit time_t stat with error checking.
- Copyright (C) 2021-2024 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* NB: Non-standard file name to avoid sysdeps override for xstat. */
-
-#include <support/check.h>
-#include <support/xunistd.h>
-#include <sys/stat.h>
-
-#if __TIMESIZE != 64
-void
-xlstat_time64 (const char *path, struct __stat64_t64 *result)
-{
- if (__lstat64_time64 (path, result) != 0)
- FAIL_EXIT1 ("__lstat64_time64 (\"%s\"): %m", path);
-}
-#endif
__BEGIN_DECLS
-struct stat64;
struct statx;
pid_t xfork (void);
void xpipe (int[2]);
void xdup2 (int, int);
int xopen (const char *path, int flags, mode_t);
-#ifndef __USE_TIME64_REDIRECTS
-# ifdef __USE_FILE_OFFSET64
-void xstat (const char *path, struct stat *);
-void xlstat (const char *path, struct stat *);
-void xfstat (int fd, struct stat *);
-# else
-void xstat (const char *path, struct stat64 *);
-void xlstat (const char *path, struct stat64 *);
-void xfstat (int fd, struct stat64 *);
-# endif
-#else
-void __REDIRECT (xstat, (const char *path, struct stat *), xstat_time64);
-void __REDIRECT (xlstat, (const char *path, struct stat *), xlstat_time64);
-void __REDIRECT (xfstat, (int fd, struct stat *), xfstat_time64);
-#endif
+void support_check_stat_fd (const char *name, int fd, int result);
+void support_check_stat_path (const char *name, const char *path, int result);
+#define xstat(path, st) \
+ (support_check_stat_path ("stat", (path), stat ((path), (st))))
+#define xfstat(fd, st) \
+ (support_check_stat_fd ("fstat", (fd), fstat ((fd), (st))))
+#define xlstat(path, st) \
+ (support_check_stat_path ("lstat", (path), lstat ((path), (st))))
+#define xstat64(path, st) \
+ (support_check_stat_path ("stat64", (path), stat64 ((path), (st))))
+#define xfstat64(fd, st) \
+ (support_check_stat_fd ("fstat64", (fd), fstat64 ((fd), (st))))
+#define xlstat64(path, st) \
+ (support_check_stat_path ("lstat64", (path), lstat64 ((path), (st))))
void xstatx (int, const char *, int, unsigned int, struct statx *);
void xmkdir (const char *path, mode_t);
void xchroot (const char *path);