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
This commit is contained in:
Thomas Cort 2013-04-10 10:41:57 +00:00 committed by Ben Gras
parent 3ae6c600a9
commit a0a1440a52
13 changed files with 9 additions and 118 deletions

View file

@ -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);

View file

@ -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.

View file

@ -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)

View file

@ -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

View file

@ -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 <utime.h> header file. */
#define HAVE_UTIME_H 1

View file

@ -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 <lzmadec.h> 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 <utime.h> header file. */
#define HAVE_UTIME_H 1

View file

@ -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

View file

@ -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

View file

@ -64,10 +64,6 @@ __RCSID("$NetBSD: fetch.c,v 1.202 2013/02/23 13:47:36 christos Exp $");
#include <unistd.h>
#include <time.h>
#ifdef __minix
#include <utime.h>
#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);

View file

@ -123,10 +123,6 @@ __RCSID("$NetBSD: ftp.c,v 1.164 2012/07/04 06:09:37 is Exp $");
#include <unistd.h>
#include <stdarg.h>
#ifdef __minix
#include <utime.h>
#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
}
}
}

View file

@ -1081,10 +1081,8 @@ copymodes(int fd, const struct stat *sbp, const char *file)
TIMESPEC_TO_TIMEVAL(&times[0], &sb.st_atimespec);
TIMESPEC_TO_TIMEVAL(&times[1], &sb.st_mtimespec);
#ifndef __minix
if (futimes(fd, times) < 0)
maybe_warn("couldn't utimes: %s", file);
#endif
}
#endif

View file

@ -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);

View file

@ -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