summaryrefslogtreecommitdiff
path: root/sbin/restore
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-08-25 04:18:44 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-08-25 04:18:44 +0000
commitedc1f7374f8deb0b8b31ed5ec5d679ccbd643dcd (patch)
tree1f1cd1d74c167ee631f50a299a0c11699a57f307 /sbin/restore
parente9f37c36b5e31af9528bbfb2a4d1ef289feb0b41 (diff)
Switch from utimes() to utimensat() to $estore full nanosecond granularity
ok millert@ deraadt@
Diffstat (limited to 'sbin/restore')
-rw-r--r--sbin/restore/dirs.c18
-rw-r--r--sbin/restore/tape.c24
2 files changed, 21 insertions, 21 deletions
diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c
index ba63b8dad80..174185615e2 100644
--- a/sbin/restore/dirs.c
+++ b/sbin/restore/dirs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dirs.c,v 1.40 2015/01/20 18:22:21 deraadt Exp $ */
+/* $OpenBSD: dirs.c,v 1.41 2015/08/25 04:18:43 guenther Exp $ */
/* $NetBSD: dirs.c,v 1.26 1997/07/01 05:37:49 lukem Exp $ */
/*
@@ -75,8 +75,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;
@@ -618,8 +618,8 @@ setdirmodes(int flags)
(void)chown(cp, node.uid, node.gid);
(void)chmod(cp, node.mode);
(void)chflags(cp, node.flags);
- (void)utimes(cp, node.ctimep);
- (void)utimes(cp, node.mtimep);
+ (void)utimensat(AT_FDCWD, cp, node.ctimep, 0);
+ (void)utimensat(AT_FDCWD, cp, node.mtimep, 0);
}
ep->e_flags &= ~NEW;
}
@@ -696,13 +696,13 @@ allocinotab(FILE *mf, struct context *ctxp, long seekpt)
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 --git a/sbin/restore/tape.c b/sbin/restore/tape.c
index eac5ce3d9f6..213551d5d2b 100644
--- a/sbin/restore/tape.c
+++ b/sbin/restore/tape.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tape.c,v 1.45 2015/01/16 06:40:00 deraadt Exp $ */
+/* $OpenBSD: tape.c,v 1.46 2015/08/25 04:18:43 guenther Exp $ */
/* $NetBSD: tape.c,v 1.26 1997/04/15 07:12:25 lukem Exp $ */
/*
@@ -505,23 +505,23 @@ extractfile(char *name)
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;
@@ -583,8 +583,8 @@ extractfile(char *name)
(void)chflags(name, flags);
skipfile();
if (setbirth)
- (void)utimes(name, ctimep);
- (void)utimes(name, mtimep);
+ (void)utimensat(AT_FDCWD, name, ctimep, 0);
+ (void)utimensat(AT_FDCWD, name, mtimep, 0);
return (GOOD);
case IFIFO:
@@ -603,8 +603,8 @@ extractfile(char *name)
(void)chflags(name, flags);
skipfile();
if (setbirth)
- (void)utimes(name, ctimep);
- (void)utimes(name, mtimep);
+ (void)utimensat(AT_FDCWD, name, ctimep, 0);
+ (void)utimensat(AT_FDCWD, name, mtimep, 0);
return (GOOD);
case IFREG:
@@ -625,8 +625,8 @@ extractfile(char *name)
getfile(xtrfile, xtrskip);
(void)close(ofile);
if (setbirth)
- (void)utimes(name, ctimep);
- (void)utimes(name, mtimep);
+ (void)utimensat(AT_FDCWD, name, ctimep, 0);
+ (void)utimensat(AT_FDCWD, name, mtimep, 0);
return (GOOD);
}
/* NOTREACHED */