-#define struct_stat struct stat
#include "tst-futimens.c"
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_futimens_helper (const char *file, int fd, const struct timespec *ts)
{
int result = futimens (fd, ts);
TEST_VERIFY_EXIT (result == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, ts[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, ts[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, ts[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, ts[1].tv_sec);
return 0;
}
-#define struct_stat struct stat
#include "tst-futimes.c"
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_futimens_helper (const char *file, int fd, const struct timeval *tv)
{
int r = futimes (fd, tv);
TEST_VERIFY_EXIT (r == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, tv[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, tv[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec);
return 0;
}
-#define struct_stat struct stat
-#define fstat fstat
-#define fstatat fstatat
#include "io/tst-futimesat.c"
#include <support/temp_file.h>
#include <support/xunistd.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-# define fstat fstat64
-# define fstatat fstatat64
-#endif
-
static int dir_fd;
static void
xwrite (fd, "hello", 5);
puts ("file created");
- struct_stat st1;
- if (fstat (fd, &st1) != 0)
- {
- puts ("fstat64 failed");
- return 1;
- }
+ struct statx st1;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st1);
close (fd);
struct timeval tv[2];
- tv[0].tv_sec = st1.st_atime + 1;
+ tv[0].tv_sec = st1.stx_atime.tv_sec + 1;
tv[0].tv_usec = 0;
- tv[1].tv_sec = st1.st_mtime + 1;
+ tv[1].tv_sec = st1.stx_mtime.tv_sec + 1;
tv[1].tv_usec = 0;
if (futimesat (dir_fd, "some-file", tv) != 0)
{
return 1;
}
- struct_stat st2;
- if (fstatat (dir_fd, "some-file", &st2, 0) != 0)
- {
- puts ("fstatat64 failed");
- return 1;
- }
+ struct statx st2;
+ xstatx (dir_fd, "some-file", 0, STATX_BASIC_STATS, &st2);
- if (st2.st_mtime != tv[1].tv_sec
+ if (st2.stx_mtime.tv_sec != tv[1].tv_sec
#ifdef _STATBUF_ST_NSEC
- || st2.st_mtim.tv_nsec != 0
+ || st2.stx_mtime.tv_nsec != 0
#endif
)
{
-#define struct_stat struct stat
#include "tst-lutimes.c"
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_lutimes_helper (const char *testfile, int fd, const char *testlink,
const struct timeval *tv)
{
- struct_stat stfile_orig;
- xlstat (testfile, &stfile_orig);
+ struct statx stfile_orig;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stfile_orig);
TEST_VERIFY_EXIT (lutimes (testlink, tv) == 0);
- struct_stat stlink;
- xlstat (testlink, &stlink);
+ struct statx stlink;
+ xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stlink);
- TEST_COMPARE (stlink.st_atime, tv[0].tv_sec);
- TEST_COMPARE (stlink.st_mtime, tv[1].tv_sec);
+ TEST_COMPARE (stlink.stx_atime.tv_sec, tv[0].tv_sec);
+ TEST_COMPARE (stlink.stx_mtime.tv_sec, tv[1].tv_sec);
/* Check if the timestamp from original file is not changed. */
- struct_stat stfile;
- xlstat (testfile, &stfile);
+ struct statx stfile;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS, &stfile);
- TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
- TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime);
+ TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec);
+ TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec);
return 0;
}
-#define struct_stat struct stat
#include "tst-utime.c"
#include <utime.h>
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_utime_helper (const char *file, int fd, const struct utimbuf *ut)
{
int result = utime (file, ut);
TEST_VERIFY_EXIT (result == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for actime match */
- TEST_COMPARE (st.st_atime, ut->actime);
+ TEST_COMPARE (st.stx_atime.tv_sec, ut->actime);
/* Check if seconds for modtime match */
- TEST_COMPARE (st.st_mtime, ut->modtime);
+ TEST_COMPARE (st.stx_mtime.tv_sec, ut->modtime);
return 0;
}
-#define struct_stat struct stat
#include "tst-utimensat.c"
#include <sys/stat.h>
#include <sys/time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_utimesat_helper (const char *testfile, int fd, const char *testlink,
const struct timespec *ts)
{
TEST_VERIFY_EXIT (utimensat (fd, testfile, ts, 0) == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, ts[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, ts[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, ts[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, ts[1].tv_sec);
}
{
- struct_stat stfile_orig;
- xlstat (testfile, &stfile_orig);
+ struct statx stfile_orig;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stfile_orig);
TEST_VERIFY_EXIT (utimensat (0 /* ignored */, testlink, ts,
AT_SYMLINK_NOFOLLOW)
== 0);
- struct_stat stlink;
- xlstat (testlink, &stlink);
+ struct statx stlink;
+ xstatx (AT_FDCWD, testlink, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stlink);
- TEST_COMPARE (stlink.st_atime, ts[0].tv_sec);
- TEST_COMPARE (stlink.st_mtime, ts[1].tv_sec);
+ TEST_COMPARE (stlink.stx_atime.tv_sec, ts[0].tv_sec);
+ TEST_COMPARE (stlink.stx_mtime.tv_sec, ts[1].tv_sec);
/* Check if the timestamp from original file is not changed. */
- struct_stat stfile;
- xlstat (testfile, &stfile);
+ struct statx stfile;
+ xstatx (AT_FDCWD, testfile, AT_SYMLINK_NOFOLLOW, STATX_BASIC_STATS,
+ &stfile);
- TEST_COMPARE (stfile_orig.st_atime, stfile.st_atime);
- TEST_COMPARE (stfile_orig.st_mtime, stfile.st_mtime);
+ TEST_COMPARE (stfile_orig.stx_atime.tv_sec, stfile.stx_atime.tv_sec);
+ TEST_COMPARE (stfile_orig.stx_mtime.tv_sec, stfile.stx_mtime.tv_sec);
}
return 0;
-#define struct_stat struct stat
#include "tst-utimes.c"
#include <support/check.h>
#include <support/xunistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
-#ifndef struct_stat
-# define struct_stat struct stat64
-#endif
-
static int
test_utimes_helper (const char *file, int fd, const struct timeval *tv)
{
int result = utimes (file, tv);
TEST_VERIFY_EXIT (result == 0);
- struct_stat st;
- xfstat (fd, &st);
+ struct statx st;
+ xstatx (fd, "", AT_EMPTY_PATH, STATX_BASIC_STATS, &st);
/* Check if seconds for atime match */
- TEST_COMPARE (st.st_atime, tv[0].tv_sec);
+ TEST_COMPARE (st.stx_atime.tv_sec, tv[0].tv_sec);
/* Check if seconds for mtime match */
- TEST_COMPARE (st.st_mtime, tv[1].tv_sec);
+ TEST_COMPARE (st.stx_mtime.tv_sec, tv[1].tv_sec);
return 0;
}