svn commit: r279986 - head/sbin/restore
Jilles Tjoelker
jilles at FreeBSD.org
Sat Mar 14 13:45:45 UTC 2015
Author: jilles
Date: Sat Mar 14 13:45:43 2015
New Revision: 279986
URL: https://svnweb.freebsd.org/changeset/base/279986
Log:
restore: Preserve timestamps to the nanosecond.
The restore utility already knows the full-resolution timestamps, so the
only thing to do is to stop converting the timespecs to timevals and use
futimens() and utimensat().
Differential Revision: https://reviews.freebsd.org/D2020
Reviewed by: jhb
Modified:
head/sbin/restore/dirs.c
head/sbin/restore/tape.c
Modified: head/sbin/restore/dirs.c
==============================================================================
--- head/sbin/restore/dirs.c Sat Mar 14 13:08:00 2015 (r279985)
+++ head/sbin/restore/dirs.c Sat Mar 14 13:45:43 2015 (r279986)
@@ -80,8 +80,8 @@ static struct inotab *inotab[HASHSIZE];
*/
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;
@@ -656,8 +656,8 @@ setdirmodes(int flags)
else
(void) chown(cp, node.uid, node.gid);
(void) chmod(cp, node.mode);
- utimes(cp, node.ctimep);
- utimes(cp, node.mtimep);
+ utimensat(AT_FDCWD, cp, node.ctimep, 0);
+ utimensat(AT_FDCWD, cp, node.mtimep, 0);
(void) chflags(cp, node.flags);
}
ep->e_flags &= ~NEW;
@@ -746,13 +746,13 @@ allocinotab(struct context *ctxp, long s
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.extsize = ctxp->extsize;
node.mode = ctxp->mode;
node.flags = ctxp->file_flags;
Modified: head/sbin/restore/tape.c
==============================================================================
--- head/sbin/restore/tape.c Sat Mar 14 13:08:00 2015 (r279985)
+++ head/sbin/restore/tape.c Sat Mar 14 13:45:43 2015 (r279986)
@@ -569,20 +569,20 @@ extractfile(char *name)
gid_t gid;
mode_t mode;
int extsize;
- struct timeval mtimep[2], ctimep[2];
+ struct timespec mtimep[2], ctimep[2];
struct entry *ep;
char *buf;
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;
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;
extsize = curfile.extsize;
uid = getuid();
if (uid == 0)
@@ -628,8 +628,10 @@ extractfile(char *name)
set_extattr_link(name, buf, extsize);
(void) lchown(name, uid, gid);
(void) lchmod(name, mode);
- (void) lutimes(name, ctimep);
- (void) lutimes(name, mtimep);
+ (void) utimensat(AT_FDCWD, name, ctimep,
+ AT_SYMLINK_NOFOLLOW);
+ (void) utimensat(AT_FDCWD, name, mtimep,
+ AT_SYMLINK_NOFOLLOW);
(void) lchflags(name, flags);
return (GOOD);
}
@@ -658,8 +660,8 @@ extractfile(char *name)
}
(void) chown(name, uid, gid);
(void) chmod(name, mode);
- (void) utimes(name, ctimep);
- (void) utimes(name, mtimep);
+ (void) utimensat(AT_FDCWD, name, ctimep, 0);
+ (void) utimensat(AT_FDCWD, name, mtimep, 0);
(void) chflags(name, flags);
return (GOOD);
@@ -688,8 +690,8 @@ extractfile(char *name)
}
(void) chown(name, uid, gid);
(void) chmod(name, mode);
- (void) utimes(name, ctimep);
- (void) utimes(name, mtimep);
+ (void) utimensat(AT_FDCWD, name, ctimep, 0);
+ (void) utimensat(AT_FDCWD, name, mtimep, 0);
(void) chflags(name, flags);
return (GOOD);
@@ -714,8 +716,8 @@ extractfile(char *name)
set_extattr_fd(ofile, name, buf, extsize);
(void) fchown(ofile, uid, gid);
(void) fchmod(ofile, mode);
- (void) futimes(ofile, ctimep);
- (void) futimes(ofile, mtimep);
+ (void) futimens(ofile, ctimep);
+ (void) futimens(ofile, mtimep);
(void) fchflags(ofile, flags);
(void) close(ofile);
return (GOOD);
More information about the svn-src-head
mailing list