From a0a1440a5273b00d1b8ae58f81baed0aca9f17ca Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Wed, 10 Apr 2013 10:41:57 +0000 Subject: [PATCH] remove utimes() workarounds With the addition of utimes(), we can remove the workarounds and use the original NetBSD code for timestamping files. Also restore use of -p & -r for install while building --- bin/pax/file_subs.c | 10 -------- bin/pax/pax.h | 4 ++- commands/fetch/fetch.c | 14 ----------- commands/touch/touch.c | 25 ------------------- external/bsd/file/include/config.h | 2 +- .../bsd/libarchive/include/config_netbsd.h | 6 ++--- external/public-domain/xz/include/config.h | 4 +-- share/mk/bsd.own.mk | 4 --- usr.bin/ftp/fetch.c | 24 ------------------ usr.bin/ftp/ftp.c | 19 -------------- usr.bin/gzip/gzip.c | 2 -- usr.bin/xinstall/xinstall.c | 5 ---- usr.sbin/mtree/compare.c | 8 ------ 13 files changed, 9 insertions(+), 118 deletions(-) diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index e6ba65e49..f4e598dfd 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -846,18 +846,8 @@ set_ftime(char *fnm, time_t mtime, time_t atime, int frc, int slk) #endif if (slk) return; -#ifdef __minix - { - struct utimbuf timp; - timp.actime = atime; - timp.modtime = mtime; - if (utime(fnm, &timp) < 0) - goto bad; - } -#else if (utimes(fnm, tv) == -1) goto bad; -#endif return; bad: syswarn(1, errno, "Access/modification time set failed on: %s", fnm); diff --git a/bin/pax/pax.h b/bin/pax/pax.h index eb09e39e6..7e8ab1a21 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -35,10 +35,12 @@ * @(#)pax.h 8.2 (Berkeley) 4/18/94 */ -#if ! HAVE_NBTOOL_CONFIG_H && !defined(__minix) +#if ! HAVE_NBTOOL_CONFIG_H #define HAVE_LUTIMES 1 +#ifndef __minix #define HAVE_STRUCT_STAT_ST_FLAGS 1 #endif +#endif /* * BSD PAX global data structures and constants. diff --git a/commands/fetch/fetch.c b/commands/fetch/fetch.c index 03028da71..5b51d49f7 100644 --- a/commands/fetch/fetch.c +++ b/commands/fetch/fetch.c @@ -779,7 +779,6 @@ fetch(char *URL, const char *path) */ signal: /* set mtime of local file */ -#ifndef __minix if (!n_flag && us.mtime && !o_stdout && of != NULL && (stat(path, &sb) != -1) && sb.st_mode & S_IFREG) { struct timeval tv[2]; @@ -791,19 +790,6 @@ fetch(char *URL, const char *path) if (utimes(tmppath ? tmppath : path, tv)) warn("%s: utimes()", tmppath ? tmppath : path); } -#else - if (!n_flag && us.mtime && !o_stdout && of != NULL && - (stat(path, &sb) != -1) && sb.st_mode & S_IFREG) { - struct utimbuf ut; - - fflush(of); - ut.actime = (us.atime ? us.atime : us.mtime); - ut.modtime = us.mtime; - - if (utime(tmppath ? tmppath : path, &ut)) - warn("%s: utime()", tmppath ? tmppath : path); - } -#endif /* timed out or interrupted? */ if (fetchLastErrCode == FETCH_TIMEOUT) diff --git a/commands/touch/touch.c b/commands/touch/touch.c index efedae1e0..c5d941939 100644 --- a/commands/touch/touch.c +++ b/commands/touch/touch.c @@ -59,7 +59,6 @@ main(int argc, char *argv[]) { struct stat sb; struct timeval tv[2]; - struct utimbuf timbuf; int aflag, cflag, mflag, ch, fd, len, rval, timeset; char *p; @@ -141,28 +140,14 @@ main(int argc, char *argv[]) continue; } -#if 0 if (!aflag) TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec); if (!mflag) TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec); -#else - if (!aflag) - tv[0].tv_sec = sb.st_atime; - if (!mflag) - tv[1].tv_sec = sb.st_mtime; -#endif /* Try utimes(2). */ -#if 0 if (!utimes(*argv, tv)) continue; -#else - timbuf.actime = tv[0].tv_sec; - timbuf.modtime = tv[1].tv_sec; - if (!utime(*argv, &timbuf)) - continue; -#endif /* If the user specified a time, nothing else we can do. */ if (timeset) { @@ -176,13 +161,8 @@ main(int argc, char *argv[]) * The permission checks are different, too, in that the * ability to write the file is sufficient. Take a shot. */ -#if 0 if (!utimes(*argv, NULL)) continue; -#else - if (!utime(*argv, NULL)) - continue; -#endif rval = 1; warn("%s", *argv); @@ -310,13 +290,8 @@ stime_file(char *fname, struct timeval *tvp) if (stat(fname, &sb)) err(1, "%s", fname); -#if 0 TIMESPEC_TO_TIMEVAL(tvp, &sb.st_atimespec); TIMESPEC_TO_TIMEVAL(tvp + 1, &sb.st_mtimespec); -#else - (tvp + 0)->tv_sec = sb.st_atime; - (tvp + 1)->tv_sec = sb.st_mtime; -#endif } __dead void diff --git a/external/bsd/file/include/config.h b/external/bsd/file/include/config.h index ebdf098a2..6d5522537 100644 --- a/external/bsd/file/include/config.h +++ b/external/bsd/file/include/config.h @@ -172,7 +172,7 @@ #define HAVE_UTIME 1 /* Define to 1 if you have the `utimes' function. */ -/* #undef HAVE_UTIMES */ +#define HAVE_UTIMES 1 /* Define to 1 if you have the header file. */ #define HAVE_UTIME_H 1 diff --git a/external/bsd/libarchive/include/config_netbsd.h b/external/bsd/libarchive/include/config_netbsd.h index f0432c28d..75645ae98 100644 --- a/external/bsd/libarchive/include/config_netbsd.h +++ b/external/bsd/libarchive/include/config_netbsd.h @@ -242,7 +242,7 @@ /* #undef HAVE_FUTIMENS */ /* Define to 1 if you have the `futimes' function. */ -/* #define HAVE_FUTIMES 1 */ +#define HAVE_FUTIMES 1 /* Define to 1 if you have the `geteuid' function. */ #define HAVE_GETEUID 1 @@ -351,7 +351,7 @@ /* #undef HAVE_LSTAT_EMPTY_STRING_BUG */ /* Define to 1 if you have the `lutimes' function. */ -/* #define HAVE_LUTIMES 1 */ +#define HAVE_LUTIMES 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_LZMADEC_H */ @@ -570,7 +570,7 @@ /* #undef HAVE_UTIMENSAT */ /* Define to 1 if you have the `utimes' function. */ -/* #define HAVE_UTIMES 1 */ +#define HAVE_UTIMES 1 /* Define to 1 if you have the header file. */ #define HAVE_UTIME_H 1 diff --git a/external/public-domain/xz/include/config.h b/external/public-domain/xz/include/config.h index 33544c5ea..764d036aa 100644 --- a/external/public-domain/xz/include/config.h +++ b/external/public-domain/xz/include/config.h @@ -90,7 +90,7 @@ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the `futimens' function. */ -/* #undef HAVE_FUTIMENS */ +#define HAVE_FUTIMENS 1 /* Define to 1 if you have the `futimes' function. */ #define HAVE_FUTIMES 1 @@ -186,7 +186,7 @@ /* #undef HAVE_UTIME */ /* Define to 1 if you have the `utimes' function. */ -/* #undef HAVE_UTIMES */ +#define HAVE_UTIMES 1 /* Define to 1 if you have the `wcwidth' function. */ #define HAVE_WCWIDTH 1 diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index c67e9a417..c7e5190ae 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -1053,16 +1053,12 @@ MKTRACE:= no # install(1) parameters. # COPY?= -c -.if ${HOST_OSTYPE:C/\-.*//} != "Minix" .if ${MKUPDATE} == "no" PRESERVE?= .else -#LSC: Not supported by MINIX install PRESERVE?= -p .endif -#XXX: Not supported by MINIX install RENAME?= -r -.endif # != "Minix" HRDLINK?= -l h SYMLINK?= -l s diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 418476542..e837d8f19 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -64,10 +64,6 @@ __RCSID("$NetBSD: fetch.c,v 1.202 2013/02/23 13:47:36 christos Exp $"); #include #include -#ifdef __minix -#include -#endif - #include "ssl.h" #include "ftp_var.h" #include "version.h" @@ -1322,39 +1318,19 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) progressmeter(1); (void)fflush(fout); if (closefunc == fclose && mtime != -1) { -#ifdef __minix - struct utimbuf utb; -#endif /* __minix */ - struct timeval tval[2]; (void)gettimeofday(&tval[0], NULL); - -#ifdef __minix - utb.actime = tval[0].tv_sec; - utb.modtime = mtime; -#else /* !__minix */ tval[1].tv_sec = mtime; tval[1].tv_usec = 0; -#endif /* !__minix */ - (*closefunc)(fout); fout = NULL; -#ifdef __minix - if (utime(savefile, &utb) == -1) { - fprintf(ttyout, - "Can't change modification time to %s", - rfc2822time(localtime(&mtime))); - } -#else /* !__minix */ if (utimes(savefile, tval) == -1) { fprintf(ttyout, "Can't change modification time to %s", rfc2822time(localtime(&mtime))); } -#endif /* !__minix */ - } if (bytes > 0) ptransfer(0); diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c index 88bc905b2..d4a5f8f5d 100644 --- a/usr.bin/ftp/ftp.c +++ b/usr.bin/ftp/ftp.c @@ -123,10 +123,6 @@ __RCSID("$NetBSD: ftp.c,v 1.164 2012/07/04 06:09:37 is Exp $"); #include #include -#ifdef __minix -#include -#endif - #include "ftp_var.h" volatile sig_atomic_t abrtflag; @@ -914,10 +910,6 @@ recvrequest(const char *cmd, const char *volatile local, const char *remote, int oprogress; int opreserve; -#ifdef __minix - struct utimbuf utb; -#endif - fout = NULL; din = NULL; hashbytes = mark; @@ -1156,16 +1148,6 @@ recvrequest(const char *cmd, const char *volatile local, const char *remote, mtime = remotemodtime(remote, 0); if (mtime != -1) { (void)gettimeofday(&tval[0], NULL); -#ifdef __minix - utb.actime = tval[0].tv_sec; - utb.modtime = mtime; - if (utime(local, &utb) == -1) { - fprintf(ttyout, - "Can't change modification time on %s to %s", - local, - rfc2822time(localtime(&mtime))); - } -#else tval[1].tv_sec = mtime; tval[1].tv_usec = 0; if (utimes(local, tval) == -1) { @@ -1174,7 +1156,6 @@ recvrequest(const char *cmd, const char *volatile local, const char *remote, local, rfc2822time(localtime(&mtime))); } -#endif } } } diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index fdbdbc537..cd4837807 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -1081,10 +1081,8 @@ copymodes(int fd, const struct stat *sbp, const char *file) TIMESPEC_TO_TIMEVAL(×[0], &sb.st_atimespec); TIMESPEC_TO_TIMEVAL(×[1], &sb.st_mtimespec); -#ifndef __minix if (futimes(fd, times) < 0) maybe_warn("couldn't utimes: %s", file); -#endif } #endif diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 1d479fd65..47e6b2c78 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -251,9 +251,6 @@ main(int argc, char *argv[]) break; case 'p': dopreserve = 1; -#ifdef __minix - warn("Minix lacks support for futimes(3)/utimes(2)"); -#endif break; case 'r': dorename = 1; @@ -774,7 +771,6 @@ install(char *from_name, char *to_name, u_int flags) /* * Preserve the date of the source file. */ -#ifndef __minix if (dopreserve) { #if HAVE_FUTIMES if (futimes(to_fd, tv) == -1) @@ -784,7 +780,6 @@ install(char *from_name, char *to_name, u_int flags) warn("%s: utimes", to_name); #endif } -#endif (void)close(to_fd); diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index 0de6fcdcc..e2ccbf016 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -140,14 +140,6 @@ lchown(const char *path, uid_t owner, gid_t group) return -1; } #endif - -static int -fake_utimes(const char *path, const struct timeval times[2]) -{ - return -1; -} -#undef utimes -#define utimes(path, times) fake_utimes(path, times) #endif int