From cd7937db8b67502f3262414463050e65528f6e0d Mon Sep 17 00:00:00 2001 From: Antoine Leca Date: Wed, 28 Mar 2012 01:30:19 +0200 Subject: [PATCH] Use utimes & co for our userland 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/gzip/gzip.c | 2 -- usr.bin/xinstall/xinstall.c | 5 ---- usr.sbin/mtree/compare.c | 6 ----- 11 files changed, 8 insertions(+), 74 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 f02b55582..36d44392d 100644 --- a/external/bsd/file/include/config.h +++ b/external/bsd/file/include/config.h @@ -159,10 +159,8 @@ /* Define to 1 if you have the `utime' function. */ #define HAVE_UTIME 1 -#ifndef __minix /* Define to 1 if you have the `utimes' function. */ #define HAVE_UTIMES 1 -#endif /* 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/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 7686f4242..e2ccbf016 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -140,12 +140,6 @@ lchown(const char *path, uid_t owner, gid_t group) return -1; } #endif - -static int -utimes(const char *path, const struct timeval times[2]) -{ - return -1; -} #endif int