From f072671cf50262cea93cfdc6f8a92ffc8d698e53 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Sun, 16 Feb 2020 09:32:42 +0100 Subject: y2038: linux: Provide __futimes64 implementation This patch provides new __futimes64 explicit 64 bit function for setting file's 64 bit attributes for access and modification time (by specifying file descriptor number). Internally, the __utimensat64_helper function is used. This patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe. Moreover, a 32 bit version - __futimes has been refactored to internally use __futimes64. The __futimes is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion of struct timeval to 64 bit struct __timeval64. The check if struct timevals' usec fields are in the range between 0 and 1000000 has been removed as Linux kernel performs it internally in the implementation of utimensat (the conversion between struct __timeval64 and __timespec64 is not relevant for this particular check). Last but not least, checks for tvp{64} not being NULL have been preserved from the original code as some legacy user space programs may rely on it. Build tests: ./src/scripts/build-many-glibcs.py glibcs Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master Above tests were performed with Y2038 redirection applied as well as without to test the proper usage of both __futimes64 and __futimes. --- include/time.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/time.h b/include/time.h index 7737be1f7d..30c8e3d296 100644 --- a/include/time.h +++ b/include/time.h @@ -206,8 +206,11 @@ extern int __utimensat64_helper (int fd, const char *file, libc_hidden_proto (__utimensat64_helper); #if __TIMESIZE == 64 +# define __futimes64 __futimes # define __futimens64 __futimens #else +extern int __futimes64 (int fd, const struct __timeval64 tvp64[2]); +libc_hidden_proto (__futimes64); extern int __futimens64 (int fd, const struct __timespec64 tsp[2]); libc_hidden_proto (__futimens64); #endif -- cgit v1.2.3