summaryrefslogtreecommitdiff
path: root/usr.bin/unzip
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit98e0ffaefb0f241cda3a72395d3be04192ae0d47 (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.bin/unzip
parentb17ff922d4072ae132ece458f5b5d74a236880ac (diff)
parente81032ad243db32b8fd615b2d55ee94b9f6a5b6a (diff)
downloadsrc-test-98e0ffaefb0f241cda3a72395d3be04192ae0d47.tar.gz
src-test-98e0ffaefb0f241cda3a72395d3be04192ae0d47.zip
Merge sync of head
Notes
Notes: svn path=/projects/bmake/; revision=283595
Diffstat (limited to 'usr.bin/unzip')
-rw-r--r--usr.bin/unzip/Makefile3
-rw-r--r--usr.bin/unzip/Makefile.depend1
-rw-r--r--usr.bin/unzip/unzip.c28
3 files changed, 15 insertions, 17 deletions
diff --git a/usr.bin/unzip/Makefile b/usr.bin/unzip/Makefile
index ef8a69072686c..9ed1a950c77d5 100644
--- a/usr.bin/unzip/Makefile
+++ b/usr.bin/unzip/Makefile
@@ -2,7 +2,6 @@
PROG = unzip
CSTD = c99
-DPADD = ${LIBARCHIVE} ${LIBZ}
-LDADD = -larchive -lz
+LIBADD= archive
.include <bsd.prog.mk>
diff --git a/usr.bin/unzip/Makefile.depend b/usr.bin/unzip/Makefile.depend
index 7f1d5315141e2..52fc11f8bcb10 100644
--- a/usr.bin/unzip/Makefile.depend
+++ b/usr.bin/unzip/Makefile.depend
@@ -14,6 +14,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libexpat \
lib/liblzma \
+ lib/libthr \
lib/libz \
secure/lib/libcrypto \
diff --git a/usr.bin/unzip/unzip.c b/usr.bin/unzip/unzip.c
index 89677a2f0e06c..841c9fb203b0b 100644
--- a/usr.bin/unzip/unzip.c
+++ b/usr.bin/unzip/unzip.c
@@ -67,9 +67,6 @@ static int u_opt; /* update */
static int v_opt; /* verbose/list */
static int Z1_opt; /* zipinfo mode list files only */
-/* time when unzip started */
-static time_t now;
-
/* debug flag */
static int unzip_debug;
@@ -470,9 +467,9 @@ static void
extract_file(struct archive *a, struct archive_entry *e, char **path)
{
int mode;
- time_t mtime;
+ struct timespec mtime;
struct stat sb;
- struct timeval tv[2];
+ struct timespec ts[2];
int cr, fd, text, warn, check;
ssize_t len;
unsigned char *p, *q, *end;
@@ -480,14 +477,18 @@ extract_file(struct archive *a, struct archive_entry *e, char **path)
mode = archive_entry_mode(e) & 0777;
if (mode == 0)
mode = 0644;
- mtime = archive_entry_mtime(e);
+ mtime.tv_sec = archive_entry_mtime(e);
+ mtime.tv_nsec = archive_entry_mtime_nsec(e);
/* look for existing file of same name */
recheck:
if (lstat(*path, &sb) == 0) {
if (u_opt || f_opt) {
/* check if up-to-date */
- if (S_ISREG(sb.st_mode) && sb.st_mtime >= mtime)
+ if (S_ISREG(sb.st_mode) &&
+ (sb.st_mtim.tv_sec > mtime.tv_sec ||
+ (sb.st_mtim.tv_sec == mtime.tv_sec &&
+ sb.st_mtim.tv_nsec >= mtime.tv_nsec)))
return;
(void)unlink(*path);
} else if (o_opt) {
@@ -593,12 +594,11 @@ recheck:
info("\n");
/* set access and modification time */
- tv[0].tv_sec = now;
- tv[0].tv_usec = 0;
- tv[1].tv_sec = mtime;
- tv[1].tv_usec = 0;
- if (futimes(fd, tv) != 0)
- error("utimes('%s')", *path);
+ ts[0].tv_sec = 0;
+ ts[0].tv_nsec = UTIME_NOW;
+ ts[1] = mtime;
+ if (futimens(fd, ts) != 0)
+ error("futimens('%s')", *path);
if (close(fd) != 0)
error("close('%s')", *path);
}
@@ -1065,8 +1065,6 @@ main(int argc, char *argv[])
if (n_opt + o_opt + u_opt > 1)
errorx("-n, -o and -u are contradictory");
- time(&now);
-
unzip(zipfile);
exit(0);