Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 Add a new get_utimens32() helper functio...



details:   https://anonhg.NetBSD.org/src/rev/c8d58e750a3a
branches:  trunk
changeset: 788949:c8d58e750a3a
user:      njoly <njoly%NetBSD.org@localhost>
date:      Tue Jul 30 17:22:31 2013 +0000

description:
Add a new get_utimens32() helper function that fetch struct timespec
data if not NULL, to be used by netbsd32_utimensat() and
netbsd32_futimens().

diffstat:

 sys/compat/netbsd32/netbsd32_fs.c |  58 ++++++++++++++++++++++++--------------
 1 files changed, 36 insertions(+), 22 deletions(-)

diffs (114 lines):

diff -r efd45b5567f2 -r c8d58e750a3a sys/compat/netbsd32/netbsd32_fs.c
--- a/sys/compat/netbsd32/netbsd32_fs.c Tue Jul 30 16:02:23 2013 +0000
+++ b/sys/compat/netbsd32/netbsd32_fs.c Tue Jul 30 17:22:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_fs.c,v 1.67 2013/07/18 14:14:00 matt Exp $    */
+/*     $NetBSD: netbsd32_fs.c,v 1.68 2013/07/30 17:22:31 njoly Exp $   */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.67 2013/07/18 14:14:00 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.68 2013/07/30 17:22:31 njoly Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -319,7 +319,7 @@
 }
 
 /*
- * Common routine to set access and modification times given a vnode.
+ * Common routines to set access and modification times given a vnode.
  */
 static int
 get_utimes32(const netbsd32_timevalp_t *tptr, struct timeval *tv,
@@ -343,6 +343,28 @@
        return 0;
 }
 
+static int
+get_utimens32(const netbsd32_timespecp_t *tptr, struct timespec *ts,
+    struct timespec **tsp)
+{
+       int error;
+       struct netbsd32_timespec ts32[2];
+
+       if (tptr == NULL) {
+               *tsp = NULL;
+               return 0;
+       }
+
+       error = copyin(tptr, ts32, sizeof(ts32));
+       if (error)
+               return error;
+       netbsd32_to_timespec(&ts32[0], &ts[0]);
+       netbsd32_to_timespec(&ts32[1], &ts[1]);
+
+       *tsp = ts;
+       return 0;
+}
+
 int
 netbsd32___utimes50(struct lwp *l, const struct netbsd32___utimes50_args *uap, register_t *retval)
 {
@@ -1168,23 +1190,18 @@
                syscallarg(netbsd32_timespecp_t) tptr;
                syscallarg(int) flag;
        } */
-       struct netbsd32_timespec ts32[2];
-       struct timespec ts[2];
+       struct timespec ts[2], *tsp;
        int follow;
        int error;
 
-       if ((error = copyin(SCARG_P32(uap, tptr), ts32, sizeof(ts32))) != 0)
-               return (error);
-
-       netbsd32_to_timespec(&ts32[0], &ts[0]);
-       netbsd32_to_timespec(&ts32[1], &ts[1]);
+       error = get_utimens32(SCARG_P32(uap, tptr), ts, &tsp);
+       if (error != 0)
+               return error;
 
        follow = (SCARG(uap, flag) & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
 
-       error = do_sys_utimensat(l, SCARG(uap, fd), NULL, 
-           SCARG_P32(uap, path), follow, ts, UIO_SYSSPACE);
-
-       return error;
+       return do_sys_utimensat(l, SCARG(uap, fd), NULL, 
+           SCARG_P32(uap, path), follow, tsp, UIO_SYSSPACE);
 }
 
 int
@@ -1271,22 +1288,19 @@
                syscallarg(int) fd;
                syscallarg(netbsd32_timespecp_t) tptr;
        } */
-       struct netbsd32_timespec ts32[2];
-       struct timespec ts[2];
+       struct timespec ts[2], *tsp;
        file_t *fp;
        int error;
 
-       if ((error = copyin(SCARG_P32(uap, tptr), ts32, sizeof(ts32))) != 0)
-               return (error);
-
-       netbsd32_to_timespec(&ts32[0], &ts[0]);
-       netbsd32_to_timespec(&ts32[1], &ts[1]);
+       error = get_utimens32(SCARG_P32(uap, tptr), ts, &tsp);
+       if (error != 0)
+               return error;
 
        /* fd_getvnode() will use the descriptor for us */
        if ((error = fd_getvnode(SCARG(uap, fd), &fp)) != 0)
                return (error);
        error = do_sys_utimensat(l, AT_FDCWD, fp->f_data, NULL, 0,
-           ts, UIO_SYSSPACE);
+           tsp, UIO_SYSSPACE);
        fd_putfile(SCARG(uap, fd));
        return (error);
 }



Home | Main Index | Thread Index | Old Index