klibc-bot for Ben Hutchings
2023-Jan-26 16:12 UTC
[klibc] [klibc:time64] utimes: Make all utimes calls wrappers for utimensat()
Commit-ID: 7f1bb1793de86d0534e8e50084b18466fdb8563b Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=7f1bb1793de86d0534e8e50084b18466fdb8563b Author: Ben Hutchings <ben at decadent.org.uk> AuthorDate: Sat, 14 Jan 2023 02:02:49 +0100 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sun, 15 Jan 2023 21:28:18 +0100 [klibc] utimes: Make all utimes calls wrappers for utimensat() futimesat(), utime(), and utimes() don't have direct replacements that use 64-bit time on 32-bit architectures. Instead, we have to use the utimensat() system call which uses a different buffer structure. In preparation for using a 64-bit time everywhere: - Make utimensat() a required system call - Make futimesat(), utime(), and utimes() wrappers for utimensat() Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/klibc/Kbuild | 5 +++-- usr/klibc/SYSCALLS.def | 5 +---- usr/klibc/{utimes.c => futimesat.c} | 8 ++------ usr/klibc/utime.c | 4 ---- usr/klibc/utimes.c | 4 ---- 5 files changed, 6 insertions(+), 20 deletions(-) diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index 85ebb25a..02a18e64 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -53,7 +53,8 @@ klib-y += vsnprintf.o snprintf.o vsprintf.o sprintf.o \ clearenv.o nullenv.o \ getopt.o getopt_long.o readdir.o scandir.o alphasort.o remove.o \ syslog.o closelog.o pty.o isatty.o reboot.o \ - time.o utime.o lseek.o nice.o getpriority.o \ + time.o lseek.o nice.o getpriority.o \ + futimesat.o utime.o utimes.o \ qsort.o bsearch.o \ lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \ inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \ @@ -61,7 +62,7 @@ klib-y += vsnprintf.o snprintf.o vsprintf.o sprintf.o \ accept.o send.o recv.o \ access.o chmod.o chown.o dup2.o mknod.o poll.o rename.o renameat.o \ fstat.o fstatat.o lstat.o stat.o \ - lchown.o link.o rmdir.o unlink.o utimes.o mkdir.o \ + lchown.o link.o rmdir.o unlink.o mkdir.o \ readlink.o realpath.o select.o symlink.o pipe.o \ ctype/isalnum.o ctype/isalpha.o ctype/isascii.o \ ctype/isblank.o ctype/iscntrl.o ctype/isdigit.o \ diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def index 00c52e02..2b23200a 100644 --- a/usr/klibc/SYSCALLS.def +++ b/usr/klibc/SYSCALLS.def @@ -140,10 +140,7 @@ int fchown32,fchown::fchown(int, uid_t, gid_t); <?> int fchownat(int, const char *, uid_t, gid_t, int); <?> int lchown32,lchown::lchown(const char *, uid_t, gid_t); int getcwd::__getcwd(char *, size_t); -<?> int utime(const char *, const struct utimbuf *); -<?> int utimes(const char *, const struct timeval *); -<?> int futimesat(int, const char *, const struct timeval *); -<?> int utimensat(int, const char *, const struct timespec *, int); +int utimensat(int, const char *, const struct timespec *, int); <?> int inotify_init(); <?> int inotify_add_watch(int, const char *, __u32); <?> int inotify_rm_watch(int, __u32); diff --git a/usr/klibc/utimes.c b/usr/klibc/futimesat.c similarity index 64% copy from usr/klibc/utimes.c copy to usr/klibc/futimesat.c index ce6d2f81..f4da4bad 100644 --- a/usr/klibc/utimes.c +++ b/usr/klibc/futimesat.c @@ -3,9 +3,7 @@ #include <sys/stat.h> #include <sys/syscall.h> -#ifndef __NR_utimes - -int utimes(const char *file, const struct timeval tvp[2]) +int futimesat(int dirfd, const char *filename, const struct timeval tvp[2]) { struct timespec ts[2]; @@ -16,7 +14,5 @@ int utimes(const char *file, const struct timeval tvp[2]) ts[1].tv_nsec = tvp[1].tv_usec * 1000; } - return utimensat(AT_FDCWD, file, &ts[0], 0); + return utimensat(dirfd, filename, &ts[0], 0); } - -#endif /* __NR_utimes */ diff --git a/usr/klibc/utime.c b/usr/klibc/utime.c index cb8f50a0..bfae2d9e 100644 --- a/usr/klibc/utime.c +++ b/usr/klibc/utime.c @@ -7,8 +7,6 @@ #include <sys/types.h> #include <sys/syscall.h> -#ifndef __NR_utime - int utime(const char *filename, const struct utimbuf *buf) { struct timeval tvp[2]; @@ -20,5 +18,3 @@ int utime(const char *filename, const struct utimbuf *buf) return utimes(filename, tvp); } - -#endif diff --git a/usr/klibc/utimes.c b/usr/klibc/utimes.c index ce6d2f81..74cb8226 100644 --- a/usr/klibc/utimes.c +++ b/usr/klibc/utimes.c @@ -3,8 +3,6 @@ #include <sys/stat.h> #include <sys/syscall.h> -#ifndef __NR_utimes - int utimes(const char *file, const struct timeval tvp[2]) { struct timespec ts[2]; @@ -18,5 +16,3 @@ int utimes(const char *file, const struct timeval tvp[2]) return utimensat(AT_FDCWD, file, &ts[0], 0); } - -#endif /* __NR_utimes */