v4: merged utimensat implementation
Subsystems (3)
PATCH 1/1 v4: merged utimensat implementation
I took Alexey's lutimes patches and merged it with the utimensat patch. Fortunately Alexey already did most of the work, the conversion to timespec. I just changed the name of the syscall, made the flag part of the syscall parameters, and did away with the old do_utimes definition (the new do_utimes takes a timespec and a flag now). All five patches patches are rolled into one.
Note, at userlevel I don't intend to expose the flags parameter. We'll have separate utimensat and lutimensat interfaces. But there is no reason to duplicate all that code in the kernel.
I'll send the updated test program separately.
arch/alpha/kernel/osf_sys.c +12 -2
@@ -955,15 +955,25 @@ osf_setitimer(int which, struct itimerval32 __user *in, struct itimerval32 __use asmlinkage intosf_utimes (char __user *filename,struct timeval32 __user *tvs) { -struct timeval ktvs[2 ]; +struct timespec tv[2 ];if (tvs) { +struct timeval ktvs[2 ];if (get_tv32 (&ktvs[0 ], &tvs[0 ]) ||get_tv32 (&ktvs[1 ], &tvs[1 ]))return -EFAULT ; + +if (ktvs[0 ].tv_usec <0 || ktvs[0 ].tv_usec >=1000000 || + ktvs[1 ].tv_usec <0 || ktvs[1 ].tv_usec >=1000000 ) +return -EINVAL ; + + tv[0 ].tv_sec = ktvs[0 ].tv_sec; + tv[0 ].tv_nsec =1000 * ktvs[0 ].tv_usec; + tv[1 ].tv_sec = ktvs[1 ].tv_sec; + tv[1 ].tv_nsec =1000 * ktvs[1 ].tv_usec; } -return do_utimes (AT_FDCWD , filename, tvs ? ktvs :NULL ); +return do_utimes (AT_FDCWD , filename, tvs ? tv :NULL ,0 ); }#define MAX_SELECT_SECONDS \
arch/sparc64/kernel/sys_sparc32.c +12 -2
@@ -775,15 +775,25 @@ asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,asmlinkage long sys32_utimes (char __user *filename,struct compat_timeval __user *tvs) { -struct timeval ktvs[2 ]; +struct timespec tv[2 ];if (tvs) { +struct timeval ktvs[2 ];if (get_tv32 (&ktvs[0 ], tvs) ||get_tv32 (&ktvs[1 ],1 +tvs))return -EFAULT ; + +if (ktvs[0 ].tv_usec <0 || ktvs[0 ].tv_usec >=1000000 || + ktvs[1 ].tv_usec <0 || ktvs[1 ].tv_usec >=1000000 ) +return -EINVAL ; + + tv[0 ].tv_sec = ktvs[0 ].tv_sec; + tv[0 ].tv_nsec =1000 * ktvs[0 ].tv_usec; + tv[1 ].tv_sec = ktvs[1 ].tv_sec; + tv[1 ].tv_nsec =1000 * ktvs[1 ].tv_usec; } -return do_utimes (AT_FDCWD , filename, (tvs ? &ktvs[0 ] :NULL )); +return do_utimes (AT_FDCWD , filename, tvs ? tv :NULL ); }/* These are here just in case some old sparc32 binary calls it. */
arch/x86_64/ia32/ia32entry.S +2 -1
@@ -714,9 +714,10 @@ ia32_sys_call_table: .quad compat_sys_get_robust_list .quad sys_splice .quad sys_sync_file_range - .quad sys_tee + .quad sys_tee /* 315 */ .quad compat_sys_vmsplice .quad compat_sys_move_pages .quad sys_getcpu .quad sys_epoll_pwait + .quad compat_sys_utimensat /* 320 */ ia32_syscall_end:
fs/compat.c +35 -8
65 lines not on this page · raw message
fs/utimes.c +77 -55
178 lines not on this page · raw message
include/asm-i386/unistd.h +2 -1
@@ -325,10 +325,11 @@#define __NR_move_pages 317#define __NR_getcpu 318#define __NR_epoll_pwait 319 +#define __NR_utimensat 320#ifdef __KERNEL__ -#define NR_syscalls 320 +#define NR_syscalls 321#define __ARCH_WANT_IPC_PARSE_VERSION#define __ARCH_WANT_OLD_READDIR
include/asm-x86_64/unistd.h +3 -1
@@ -619,8 +619,10 @@ __SYSCALL(__NR_sync_file_range, sys_sync_file_range) __SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_move_pages 279 __SYSCALL(__NR_move_pages, sys_move_pages) +#define __NR_utimensat 280 +__SYSCALL(__NR_utimensat, sys_utimensat) -#define __NR_syscall_max __NR_move_pages +#define __NR_syscall_max __NR_utimensat#ifndef __NO_STUBS#define __ARCH_WANT_OLD_READDIR
include/linux/stat.h +3 -0
@@ -53,6 +53,9 @@#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) +#define UTIME_NOW ((1l << 30) - 1l) +#define UTIME_OMIT ((1l << 30) - 2l) +#include <linux/types.h> #include <linux/time.h>
include/linux/time.h +1 -1
@@ -109,7 +109,7 @@ extern void do_gettimeofday(struct timeval *tv);extern int do_settimeofday (struct timespec *tv);extern int do_sys_settimeofday (struct timespec *tv,struct timezone *tz);#define do_posix_clock_monotonic_gettime (ts) ktime_get_ts(ts) -extern long do_utimes (int dfd,char __user *filename,struct timeval *times); +extern long do_utimes (int dfd,char __user *filename,struct timespec *times,int flags);struct itimerval ;extern int do_setitimer (int which,struct itimerval *value,struct itimerval *ovalue);
Quoted 6 lines · Ulrich Drepper
I took Alexey's lutimes patches and merged it with the utimensat patch. Fortunately Alexey already did most of the work, the conversion to timespec. I just changed the name of the syscall, made the flag part of the syscall parameters, and did away with the old
do_utimesdefinition (the newdo_utimestakes a timespec and a flag now). All five patches patches are rolled into one.
erm, utime(2) cleanup is technically independent from all this nanosecond business, but ok.
arch/alpha/kernel/osf_sys.c osf_setitimer(int which, struct itimerval32 __user *in, struct itimerval32 __use · line 958
Quoted 8 lines
arch/alpha/kernel/osf_sys.c +1
-1@@ -955,15 +955,25 @@ osf_setitimer(int which, struct itimerval32 __user *in, struct itimerval32 __use asmlinkage intosf_utimes (char __user *filename,struct timeval32 __user *tvs) { -struct timeval ktvs[2 ]; +struct timespec tv[2 ];
It should be tiny little bit nicer to call them "ts[2]" because they're timeSpecs.
Quoted 2 lines · Alexey Dobriyan
It should be tiny little bit nicer to call them "ts[2]" because they're timeSpecs.
I always use tv since the prefix of the element names hasn't been changed. ts.tv_sec vs tv.tv_sec. The latter looks nicer.
Signature · 1 line
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
Quoted 10 lines · On Fri, 27 Apr 2007 11:23:58 -0400 Ulrich Drepper <[email protected]> wrote:
I took Alexey's lutimes patches and merged it with the utimensat patch. Fortunately Alexey already did most of the work, the conversion to timespec. I just changed the name of the syscall, made the flag part of the syscall parameters, and did away with the old
do_utimesdefinition (the newdo_utimestakes a timespec and a flag now). All five patches patches are rolled into one.Note, at userlevel I don't intend to expose the flags parameter. We'll have separate utimensat and lutimensat interfaces. But there is no reason to duplicate all that code in the kernel.
Could we please have a signoff for this work from Alexey and a changelog for the commit? I could grab the description from the initial utimensat email, but I guess it needs updating now.
Quoted 2 lines · Andrew Morton
Could we please have [...] a changelog
for the commit?
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime which already use do_utimes instead of duplicating the work.
Signature · 1 line
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖