Source-Changes-HG archive

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

[src/netbsd-7-0]: src Pull up following revision(s) (requested by nakayama in...



details:   https://anonhg.NetBSD.org/src/rev/c45d865cd248
branches:  netbsd-7-0
changeset: 801147:c45d865cd248
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Mar 03 14:27:54 2016 +0000

description:
Pull up following revision(s) (requested by nakayama in ticket #1096):
        bin/mv/mv.c: revision 1.44
        bin/cp/utils.c: revision 1.43-1.44
        lib/librumphijack/hijack.c: revision 1.112-1.115
        usr.bin/touch/touch.c: revision 1.33
        sbin/restore/tape.c: revision 1.68
        sbin/restore/dirs.c: revision 1.51
Don't truncate at sub-microsecond while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html

Fix the name of failed function in warning message.

Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call.  Linux also has this system call, but
not tested this on linux.

Also hijack futimens(2) so that t_sh test passes.

Define a generic ATCALL() and use it to implement utimensat()
Make ATCALL() behave for absolute paths too.

diffstat:

 bin/cp/utils.c             |  14 ++++----
 lib/librumphijack/hijack.c |  39 +++++++++++++++++++++++-
 sbin/restore/dirs.c        |  20 ++++++------
 sbin/restore/tape.c        |  30 +++++++++---------
 usr.bin/touch/touch.c      |  74 +++++++++++++++++++++++-----------------------
 5 files changed, 106 insertions(+), 71 deletions(-)

diffs (truncated from 478 to 300 lines):

diff -r f2bc88868a1f -r c45d865cd248 bin/cp/utils.c
--- a/bin/cp/utils.c    Sat Feb 27 21:38:59 2016 +0000
+++ b/bin/cp/utils.c    Thu Mar 03 14:27:54 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.42 2013/12/11 06:00:11 dholland Exp $ */
+/* $NetBSD: utils.c,v 1.42.6.1 2016/03/03 14:27:54 martin Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utils.c    8.3 (Berkeley) 4/1/94";
 #else
-__RCSID("$NetBSD: utils.c,v 1.42 2013/12/11 06:00:11 dholland Exp $");
+__RCSID("$NetBSD: utils.c,v 1.42.6.1 2016/03/03 14:27:54 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -62,13 +62,13 @@
 int
 set_utimes(const char *file, struct stat *fs)
 {
-    static struct timeval tv[2];
+    struct timespec ts[2];
 
-    TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
-    TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
+    ts[0] = fs->st_atimespec;
+    ts[1] = fs->st_mtimespec;
 
-    if (lutimes(file, tv)) {
-       warn("lutimes: %s", file);
+    if (lutimens(file, ts)) {
+       warn("lutimens: %s", file);
        return (1);
     }
     return (0);
diff -r f2bc88868a1f -r c45d865cd248 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Sat Feb 27 21:38:59 2016 +0000
+++ b/lib/librumphijack/hijack.c        Thu Mar 03 14:27:54 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.109.2.1 2014/12/09 20:13:38 martin Exp $ */
+/*      $NetBSD: hijack.c,v 1.109.2.1.2.1 2016/03/03 14:27:54 martin Exp $     */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include <rump/rumpuser_port.h>
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.109.2.1 2014/12/09 20:13:38 martin Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.109.2.1.2.1 2016/03/03 14:27:54 martin Exp $");
 #endif
 
 #include <sys/param.h>
@@ -107,6 +107,7 @@
        DUALCALL_LINK, DUALCALL_RENAME,
        DUALCALL_MKDIR, DUALCALL_RMDIR,
        DUALCALL_UTIMES, DUALCALL_LUTIMES, DUALCALL_FUTIMES,
+       DUALCALL_UTIMENSAT, DUALCALL_FUTIMENS,
        DUALCALL_TRUNCATE, DUALCALL_FTRUNCATE,
        DUALCALL_FSYNC,
        DUALCALL_ACCESS,
@@ -304,6 +305,8 @@
        { DUALCALL_UTIMES,      S(REALUTIMES),  RSYS_NAME(UTIMES)       },
        { DUALCALL_LUTIMES,     S(REALLUTIMES), RSYS_NAME(LUTIMES)      },
        { DUALCALL_FUTIMES,     S(REALFUTIMES), RSYS_NAME(FUTIMES)      },
+       { DUALCALL_UTIMENSAT,   "utimensat",    RSYS_NAME(UTIMENSAT)    },
+       { DUALCALL_FUTIMENS,    "futimens",     RSYS_NAME(FUTIMENS)     },
        { DUALCALL_OPEN,        "open",         RSYS_NAME(OPEN)         },
        { DUALCALL_CHDIR,       "chdir",        RSYS_NAME(CHDIR)        },
        { DUALCALL_FCHDIR,      "fchdir",       RSYS_NAME(FCHDIR)       },
@@ -525,6 +528,33 @@
 #define DPRINTF(x)
 #endif
 
+#define ATCALL(type, name, rcname, args, proto, vars)                  \
+type name args                                                         \
+{                                                                      \
+       type (*fun) proto;                                              \
+       int isrump = -1;                                                \
+                                                                       \
+       if (fd == AT_FDCWD || *path == '/') {                           \
+               isrump = path_isrump(path);                             \
+       } else {                                                        \
+               isrump = fd_isrump(fd);                                 \
+       }                                                               \
+                                                                       \
+       DPRINTF(("%s -> %d:%s (%s)\n", __STRING(name),                  \
+           fd, path, isrump ? "rump" : "host"));                       \
+                                                                       \
+       assert(isrump != -1);                                           \
+       if (isrump) {                                                   \
+               fun = syscalls[rcname].bs_rump;                         \
+               if (fd != AT_FDCWD)                                     \
+                       fd = fd_host2rump(fd);                          \
+               path = path_host2rump(path);                            \
+       } else {                                                        \
+               fun = syscalls[rcname].bs_host;                         \
+       }                                                               \
+       return fun vars;                                                \
+}
+
 #define FDCALL(type, name, rcname, args, proto, vars)                  \
 type name args                                                         \
 {                                                                      \
@@ -2238,6 +2268,11 @@
  * Rest are std type calls.
  */
 
+ATCALL(int, utimensat, DUALCALL_UTIMENSAT,                             \
+       (int fd, const char *path, const struct timespec t[2], int f),  \
+       (int, const char *, const struct timespec [2], int),
+       (fd, path, t, f))
+
 FDCALL(int, bind, DUALCALL_BIND,                                       \
        (int fd, const struct sockaddr *name, socklen_t namelen),       \
        (int, const struct sockaddr *, socklen_t),                      \
diff -r f2bc88868a1f -r c45d865cd248 sbin/restore/dirs.c
--- a/sbin/restore/dirs.c       Sat Feb 27 21:38:59 2016 +0000
+++ b/sbin/restore/dirs.c       Thu Mar 03 14:27:54 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dirs.c,v 1.50 2013/06/09 17:57:09 dholland Exp $       */
+/*     $NetBSD: dirs.c,v 1.50.8.1 2016/03/03 14:27:54 martin Exp $     */
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)dirs.c     8.7 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: dirs.c,v 1.50 2013/06/09 17:57:09 dholland Exp $");
+__RCSID("$NetBSD: dirs.c,v 1.50.8.1 2016/03/03 14:27:54 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -84,8 +84,8 @@
  */
 struct modeinfo {
        ino_t ino;
-       struct timeval ctimep[2];
-       struct timeval mtimep[2];
+       struct timespec ctimep[2];
+       struct timespec mtimep[2];
        mode_t mode;
        uid_t uid;
        gid_t gid;
@@ -625,8 +625,8 @@
                } else {
                        if (!Nflag) {
                                cp = myname(ep);
-                               (void) utimes(cp, node.ctimep);
-                               (void) utimes(cp, node.mtimep);
+                               (void) utimens(cp, node.ctimep);
+                               (void) utimens(cp, node.mtimep);
                                (void) chown(cp, node.uid, node.gid);
                                (void) chmod(cp, node.mode);
                                if (Mtreefile) {
@@ -723,13 +723,13 @@
                return (itp);
        node.ino = ctxp->ino;
        node.mtimep[0].tv_sec = ctxp->atime_sec;
-       node.mtimep[0].tv_usec = ctxp->atime_nsec / 1000;
+       node.mtimep[0].tv_nsec = ctxp->atime_nsec;
        node.mtimep[1].tv_sec = ctxp->mtime_sec;
-       node.mtimep[1].tv_usec = ctxp->mtime_nsec / 1000;
+       node.mtimep[1].tv_nsec = ctxp->mtime_nsec;
        node.ctimep[0].tv_sec = ctxp->atime_sec;
-       node.ctimep[0].tv_usec = ctxp->atime_nsec / 1000;
+       node.ctimep[0].tv_nsec = ctxp->atime_nsec;
        node.ctimep[1].tv_sec = ctxp->birthtime_sec;
-       node.ctimep[1].tv_usec = ctxp->birthtime_nsec / 1000;
+       node.ctimep[1].tv_nsec = ctxp->birthtime_nsec;
        node.mode = ctxp->mode;
        node.flags = ctxp->file_flags;
        node.uid = ctxp->uid;
diff -r f2bc88868a1f -r c45d865cd248 sbin/restore/tape.c
--- a/sbin/restore/tape.c       Sat Feb 27 21:38:59 2016 +0000
+++ b/sbin/restore/tape.c       Thu Mar 03 14:27:54 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tape.c,v 1.67 2013/01/22 09:39:13 dholland Exp $       */
+/*     $NetBSD: tape.c,v 1.67.10.1 2016/03/03 14:27:54 martin Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)tape.c     8.9 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: tape.c,v 1.67 2013/01/22 09:39:13 dholland Exp $");
+__RCSID("$NetBSD: tape.c,v 1.67.10.1 2016/03/03 14:27:54 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -624,24 +624,24 @@
        uid_t uid;
        gid_t gid;
        mode_t mode;
-       struct timeval mtimep[2], ctimep[2];
+       struct timespec mtimep[2], ctimep[2];
        struct entry *ep;
        int setbirth;
 
        curfile.name = name;
        curfile.action = USING;
        mtimep[0].tv_sec = curfile.atime_sec;
-       mtimep[0].tv_usec = curfile.atime_nsec / 1000;
+       mtimep[0].tv_nsec = curfile.atime_nsec;
        mtimep[1].tv_sec = curfile.mtime_sec;
-       mtimep[1].tv_usec = curfile.mtime_nsec / 1000;
+       mtimep[1].tv_nsec = curfile.mtime_nsec;
 
        setbirth = curfile.birthtime_sec != 0;
 
        if (setbirth) {
                ctimep[0].tv_sec = curfile.atime_sec;
-               ctimep[0].tv_usec = curfile.atime_nsec / 1000;
+               ctimep[0].tv_nsec = curfile.atime_nsec;
                ctimep[1].tv_sec = curfile.birthtime_sec;
-               ctimep[1].tv_usec = curfile.birthtime_nsec / 1000;
+               ctimep[1].tv_nsec = curfile.birthtime_nsec;
        }
        uid = curfile.uid;
        gid = curfile.gid;
@@ -683,8 +683,8 @@
                        (void) unlink(name);
                if (linkit(lnkbuf, name, SYMLINK) == GOOD) {
                        if (setbirth)
-                               (void) lutimes(name, ctimep);
-                       (void) lutimes(name, mtimep);
+                               (void) lutimens(name, ctimep);
+                       (void) lutimens(name, mtimep);
                        (void) lchown(name, uid, gid);
                        (void) lchmod(name, mode);
                        if (Mtreefile) {
@@ -714,8 +714,8 @@
                }
                skipfile();
                if (setbirth)
-                       (void) utimes(name, ctimep);
-               (void) utimes(name, mtimep);
+                       (void) utimens(name, ctimep);
+               (void) utimens(name, mtimep);
                (void) chown(name, uid, gid);
                (void) chmod(name, mode);
                if (Mtreefile) {
@@ -743,8 +743,8 @@
                }
                skipfile();
                if (setbirth)
-                       (void) utimes(name, ctimep);
-               (void) utimes(name, mtimep);
+                       (void) utimens(name, ctimep);
+               (void) utimens(name, mtimep);
                (void) chown(name, uid, gid);
                (void) chmod(name, mode);
                if (Mtreefile) {
@@ -779,8 +779,8 @@
                if (Nflag)
                        return (GOOD);
                if (setbirth)
-                       (void) futimes(ofile, ctimep);
-               (void) futimes(ofile, mtimep);
+                       (void) futimens(ofile, ctimep);
+               (void) futimens(ofile, mtimep);
                (void) fchown(ofile, uid, gid);
                (void) fchmod(ofile, mode);
                if (Mtreefile) {
diff -r f2bc88868a1f -r c45d865cd248 usr.bin/touch/touch.c
--- a/usr.bin/touch/touch.c     Sat Feb 27 21:38:59 2016 +0000
+++ b/usr.bin/touch/touch.c     Thu Mar 03 14:27:54 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: touch.c,v 1.32 2012/10/22 21:51:58 christos Exp $      */
+/*     $NetBSD: touch.c,v 1.32.10.1 2016/03/03 14:27:54 martin Exp $   */
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)touch.c    8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.32 2012/10/22 21:51:58 christos Exp $");
+__RCSID("$NetBSD: touch.c,v 1.32.10.1 2016/03/03 14:27:54 martin Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -59,10 +59,10 @@
 #include <util.h>
 #include <getopt.h>
 
-static void    stime_arg0(char *, struct timeval *);
-static void    stime_arg1(char *, struct timeval *);
-static void    stime_arg2(char *, int, struct timeval *);
-static void    stime_file(char *, struct timeval *);
+static void    stime_arg0(char *, struct timespec *);
+static void    stime_arg1(char *, struct timespec *);
+static void    stime_arg2(char *, int, struct timespec *);
+static void    stime_file(char *, struct timespec *);
 __dead static void     usage(void);
 



Home | Main Index | Thread Index | Old Index