summary refs log tree commit diff
path: root/include/time.h
diff options
context:
space:
mode:
authorLukasz Majewski <lukma@denx.de>2020-02-16 09:32:42 +0100
committerLukasz Majewski <lukma@denx.de>2020-03-09 10:26:46 +0100
commitf072671cf50262cea93cfdc6f8a92ffc8d698e53 (patch)
tree30d9089f6c2c315c228bf0fd1717604375ba3520 /include/time.h
parent7975f9a48a83b95174503bda6c48124f08cb4f62 (diff)
downloadglibc-f072671cf50262cea93cfdc6f8a92ffc8d698e53.tar.gz
glibc-f072671cf50262cea93cfdc6f8a92ffc8d698e53.tar.xz
glibc-f072671cf50262cea93cfdc6f8a92ffc8d698e53.zip
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.
Diffstat (limited to 'include/time.h')
-rw-r--r--include/time.h3
1 files changed, 3 insertions, 0 deletions
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