Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add futimens(2) and part of utimnsat(2)



details:   https://anonhg.NetBSD.org/src/rev/973b03f45011
branches:  trunk
changeset: 768451:973b03f45011
user:      manu <manu%NetBSD.org@localhost>
date:      Wed Aug 17 07:22:33 2011 +0000

description:
Add futimens(2) and part of utimnsat(2)

diffstat:

 distrib/sets/lists/comp/mi |    8 +++-
 lib/libc/sys/Makefile.inc  |    5 +-
 lib/libc/sys/utimes.2      |   67 +++++++++++++++++++++++++++-
 sys/kern/syscalls.master   |    4 +-
 sys/kern/vfs_syscalls.c    |  105 +++++++++++++++++++++++++++++++++++++++------
 5 files changed, 167 insertions(+), 22 deletions(-)

diffs (truncated from 386 to 300 lines):

diff -r 32996fff9fe3 -r 973b03f45011 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Wed Aug 17 06:59:28 2011 +0000
+++ b/distrib/sets/lists/comp/mi        Wed Aug 17 07:22:33 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.1662 2011/08/15 15:14:00 wiz Exp $
+#      $NetBSD: mi,v 1.1663 2011/08/17 07:22:34 manu Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4680,6 +4680,7 @@
 ./usr/share/man/cat2/fsync_range.0             comp-c-catman           .cat
 ./usr/share/man/cat2/ftruncate.0               comp-c-catman           .cat
 ./usr/share/man/cat2/futimes.0                 comp-c-catman           .cat
+./usr/share/man/cat2/futimens.0                        comp-c-catman           .cat
 ./usr/share/man/cat2/getcontext.0              comp-c-catman           .cat
 ./usr/share/man/cat2/getdents.0                        comp-c-catman           .cat
 ./usr/share/man/cat2/getdirentries.0           comp-obsolete           obsolete
@@ -4865,6 +4866,7 @@
 ./usr/share/man/cat2/undelete.0                        comp-c-catman           .cat
 ./usr/share/man/cat2/unlink.0                  comp-c-catman           .cat
 ./usr/share/man/cat2/unmount.0                 comp-c-catman           .cat
+./usr/share/man/cat2/utimensat.0               comp-c-catman           .cat
 ./usr/share/man/cat2/utimes.0                  comp-c-catman           .cat
 ./usr/share/man/cat2/utrace.0                  comp-c-catman           .cat
 ./usr/share/man/cat2/uuidgen.0                 comp-c-catman           .cat
@@ -10864,6 +10866,7 @@
 ./usr/share/man/html2/fsync_range.html         comp-c-htmlman          html
 ./usr/share/man/html2/ftruncate.html           comp-c-htmlman          html
 ./usr/share/man/html2/futimes.html             comp-c-htmlman          html
+./usr/share/man/html2/futimens.html            comp-c-htmlman          html
 ./usr/share/man/html2/getcontext.html          comp-c-htmlman          html
 ./usr/share/man/html2/getdents.html            comp-c-htmlman          html
 ./usr/share/man/html2/getegid.html             comp-c-htmlman          html
@@ -11037,6 +11040,7 @@
 ./usr/share/man/html2/undelete.html            comp-c-htmlman          html
 ./usr/share/man/html2/unlink.html              comp-c-htmlman          html
 ./usr/share/man/html2/unmount.html             comp-c-htmlman          html
+./usr/share/man/html2/utimensat.html           comp-c-htmlman          html
 ./usr/share/man/html2/utimes.html              comp-c-htmlman          html
 ./usr/share/man/html2/utrace.html              comp-c-htmlman          html
 ./usr/share/man/html2/uuidgen.html             comp-c-htmlman          html
@@ -16822,6 +16826,7 @@
 ./usr/share/man/man2/fsync_range.2             comp-c-man              .man
 ./usr/share/man/man2/ftruncate.2               comp-c-man              .man
 ./usr/share/man/man2/futimes.2                 comp-c-man              .man
+./usr/share/man/man2/futimens.2                        comp-c-man              .man
 ./usr/share/man/man2/getcontext.2              comp-c-man              .man
 ./usr/share/man/man2/getdents.2                        comp-c-man              .man
 ./usr/share/man/man2/getegid.2                 comp-c-man              .man
@@ -17005,6 +17010,7 @@
 ./usr/share/man/man2/undelete.2                        comp-c-man              .man
 ./usr/share/man/man2/unlink.2                  comp-c-man              .man
 ./usr/share/man/man2/unmount.2                 comp-c-man              .man
+./usr/share/man/man2/utimensat.2               comp-c-man              .man
 ./usr/share/man/man2/utimes.2                  comp-c-man              .man
 ./usr/share/man/man2/utrace.2                  comp-c-man              .man
 ./usr/share/man/man2/uuidgen.2                 comp-c-man              .man
diff -r 32996fff9fe3 -r 973b03f45011 lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc Wed Aug 17 06:59:28 2011 +0000
+++ b/lib/libc/sys/Makefile.inc Wed Aug 17 07:22:33 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.208 2011/08/08 12:08:53 manu Exp $
+#      $NetBSD: Makefile.inc,v 1.209 2011/08/17 07:22:33 manu Exp $
 #      @(#)Makefile.inc        8.3 (Berkeley) 10/24/94
 
 # sys sources
@@ -90,7 +90,7 @@
        faccessat.S fchdir.S fchflags.S fchmod.S fchmodat.S fchown.S \
                fchownat.S fchroot.S fexecve.S __fhopen40.S __fhstat50.S \
                __fhstatvfs140.S fktrace.S flock.S fpathconf.S __fstat50.S \
-               fstatvfs1.S fstatat.S  __futimes50.S \
+               fstatvfs1.S fstatat.S  __futimes50.S futimens.S \
        __getcwd.S __getdents30.S __getfh30.S getvfsstat.S getgroups.S\
                __getitimer50.S __getlogin.S getpeername.S getpgid.S getpgrp.S \
                getpriority.S getrlimit.S __getrusage50.S getsid.S \
@@ -315,6 +315,7 @@
 MLINKS+=syscall.2 __syscall.2
 MLINKS+=truncate.2 ftruncate.2
 MLINKS+=utimes.2 futimes.2 utimes.2 lutimes.2
+MLINKS+=utimes.2 futimens.2 utimes.2 utimensat.2
 MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2
 MLINKS+=write.2 writev.2 write.2 pwrite.2 write.2 pwritev.2
 MLINKS+=pipe.2 pipe2.2
diff -r 32996fff9fe3 -r 973b03f45011 lib/libc/sys/utimes.2
--- a/lib/libc/sys/utimes.2     Wed Aug 17 06:59:28 2011 +0000
+++ b/lib/libc/sys/utimes.2     Wed Aug 17 07:22:33 2011 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: utimes.2,v 1.26 2010/04/29 17:02:38 jruoho Exp $
+.\"    $NetBSD: utimes.2,v 1.27 2011/08/17 07:22:33 manu Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -35,7 +35,9 @@
 .Sh NAME
 .Nm utimes ,
 .Nm lutimes ,
-.Nm futimes
+.Nm futimes ,
+.Nm futimens ,
+.Nm utimensat
 .Nd set file access and modification times
 .Sh LIBRARY
 .Lb libc
@@ -47,6 +49,11 @@
 .Fn lutimes "const char *path" "const struct timeval times[2]"
 .Ft int
 .Fn futimes "int fd" "const struct timeval times[2]"
+.Ft int
+.Fn futimens "int fd" "const struct timespec times[2]"
+.Ft int
+.Fn utimensat "int fd" "const char *path" "const struct timespec times[2]" "\
+int flag"
 .Sh DESCRIPTION
 The access and modification times of the file named by
 .Fa path
@@ -93,15 +100,52 @@
 while
 .Fn utimes
 changes the times of the file the link references.
+.Pp
+.Fn futimens
+is like
+.Fn futimes
+except that time is specified with nanosecond instead of microseconds.
+.Pp
+.Fn utimensat 
+also allows time to be specifed with nanoseconds. When it operates on
+a symbolic link, it will change the target's time if 
+.Ar follow
+is unset.
+If
+.Ar follow
+is set to
+.Dv AT_SYMLINK_NOFOLLOW ,
+the symbolic link's dates are changed.
+.Pp
+The nanosecond fields for
+.Fn futimes
+and
+.Fn utimensat
+can be set to the special value 
+.Dv UTIME_NOW
+to set the current time, or to
+.Dv UTIME_OMIT
+to let the time unchanged (this allows changing access time but not
+modification time, and vice-versa).
+.Pp
+.Fn utimensat
+is partially implemented.
+It will return
+.Er ENOSYS
+for 
+.Fa fd
+values different than
+.Dv AT_FDCWD .
 .Sh RETURN VALUES
 Upon successful completion, a value of 0 is returned.
 Otherwise, a value of \-1 is returned and
 .Va errno
 is set to indicate the error.
 .Sh ERRORS
-.Fn utimes
+.Fn utimes ,
+.Fn lutimes ,
 and
-.Fn lutimes
+.Fn utimensat
 will fail if:
 .Bl -tag -width Er
 .It Bq Er EACCES
@@ -144,6 +188,8 @@
 .El
 .Pp
 .Fn futimes
+and
+.Fn futimens
 will fail if:
 .Bl -tag -width Er
 .It Bq Er EACCES
@@ -184,6 +230,11 @@
 It was however marked as legacy in the
 .St -p1003.1-2004
 revision.
+.Fn futimens 
+and
+.Fn utmensat 
+functions conform to
+.St -p1003.1-2008 .
 .Sh HISTORY
 The
 .Fn utimes
@@ -199,3 +250,11 @@
 .Nx 1.3 .
 Birthtime setting support was added in
 .Nx 5.0 .
+.Fn futimens
+and
+.Fn utimensat
+functions calls appreared in
+.Nx 6.0
+.Sh BUGS
+.Fn utimensat
+is partially implemented.
diff -r 32996fff9fe3 -r 973b03f45011 sys/kern/syscalls.master
--- a/sys/kern/syscalls.master  Wed Aug 17 06:59:28 2011 +0000
+++ b/sys/kern/syscalls.master  Wed Aug 17 07:22:33 2011 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.251 2011/08/08 12:08:53 manu Exp $
+       $NetBSD: syscalls.master,v 1.252 2011/08/17 07:22:34 manu Exp $
 
 ;      @(#)syscalls.master     8.2 (Berkeley) 1/13/94
 
@@ -923,3 +923,5 @@
                            const char *path2); }
 471    STD  RUMP       { int|sys||unlinkat(int fd, const char *path, \
                            int flag); }
+472    STD  RUMP       { int|sys||futimens(int fd, \
+                           const struct timespec *tptr); }
diff -r 32996fff9fe3 -r 973b03f45011 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Wed Aug 17 06:59:28 2011 +0000
+++ b/sys/kern/vfs_syscalls.c   Wed Aug 17 07:22:33 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.433 2011/08/08 12:08:53 manu Exp $  */
+/*     $NetBSD: vfs_syscalls.c,v 1.434 2011/08/17 07:22:34 manu Exp $  */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.433 2011/08/08 12:08:53 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.434 2011/08/17 07:22:34 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -3031,6 +3031,26 @@
        return (error);
 }
 
+int
+sys_futimens(struct lwp *l, const struct sys_futimens_args *uap,
+    register_t *retval)
+{
+       /* {
+               syscallarg(int) fd;
+               syscallarg(const struct timespec *) tptr;
+       } */
+       int error;
+       file_t *fp;
+
+       /* fd_getvnode() will use the descriptor for us */
+       if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
+               return (error);
+       error = do_sys_utimens(l, fp->f_data, NULL, 0, SCARG(uap, tptr),
+           UIO_USERSPACE);
+       fd_putfile(SCARG(uap, fd));
+       return (error);
+}
+
 /*
  * Set the access and modification times given a path name; this
  * version does not follow links.
@@ -3058,6 +3078,20 @@
                syscallarg(const struct timespec *) tptr;
                syscallarg(int) flag;
        } */
+       int follow;
+       const struct timespec *tptr;
+
+       /*
+        * Specified fd is not yet implemented
+        */ 
+       if (SCARG(uap, fd) != AT_FDCWD)
+               return ENOSYS;
+
+       tptr = SCARG(uap, tptr);
+       follow = (SCARG(uap, flag) & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
+
+       return do_sys_utimens(l, NULL, SCARG(uap, path), follow,
+           tptr, UIO_USERSPACE);
 
        return ENOSYS;
 }
@@ -3066,8 +3100,8 @@
  * Common routine to set access and modification times given a vnode.
  */
 int
-do_sys_utimes(struct lwp *l, struct vnode *vp, const char *path, int flag,
-    const struct timeval *tptr, enum uio_seg seg)
+do_sys_utimens(struct lwp *l, struct vnode *vp, const char *path, int flag,
+    const struct timespec *tptr, enum uio_seg seg)
 {
        struct vattr vattr;
        int error, dorele = 0;
@@ -3092,19 +3126,20 @@
                nanotime(&ts[0]);
                ts[1] = ts[0];
        } else {
-               struct timeval tv[2];



Home | Main Index | Thread Index | Old Index