Use futimes(2).

Send microseconds over the wire, rather than just 0.
This commit is contained in:
mycroft 1997-10-19 13:12:04 +00:00
parent 2b6e02aa42
commit 2d6dc609e6
1 changed files with 14 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcp.c,v 1.17 1997/09/14 08:17:12 lukem Exp $ */ /* $NetBSD: rcp.c,v 1.18 1997/10/19 13:12:04 mycroft Exp $ */
/* /*
* Copyright (c) 1983, 1990, 1992, 1993 * Copyright (c) 1983, 1990, 1992, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1990, 1992, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94"; static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94";
#else #else
__RCSID("$NetBSD: rcp.c,v 1.17 1997/09/14 08:17:12 lukem Exp $"); __RCSID("$NetBSD: rcp.c,v 1.18 1997/10/19 13:12:04 mycroft Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -425,9 +425,11 @@ syserr: run_err("%s: %s", name, strerror(errno));
* Make it compatible with possible future * Make it compatible with possible future
* versions expecting microseconds. * versions expecting microseconds.
*/ */
(void)snprintf(buf, sizeof(buf), "T%ld 0 %ld 0\n", (void)snprintf(buf, sizeof(buf), "T%ld %ld %ld %ld\n",
(long)stb.st_mtimespec.tv_sec, (long)stb.st_mtimespec.tv_sec,
(long)stb.st_atimespec.tv_sec); (long)stb.st_mtimespec.tv_nsec / 1000,
(long)stb.st_atimespec.tv_sec,
(long)stb.st_atimespec.tv_nsec / 1000);
(void)write(rem, buf, strlen(buf)); (void)write(rem, buf, strlen(buf));
if (response() < 0) if (response() < 0)
goto next; goto next;
@ -490,9 +492,11 @@ rsource(name, statp)
else else
last++; last++;
if (pflag) { if (pflag) {
(void)snprintf(path, sizeof(path), "T%ld 0 %ld 0\n", (void)snprintf(path, sizeof(path), "T%ld %ld %ld %ld\n",
(long)statp->st_mtimespec.tv_sec, (long)statp->st_mtimespec.tv_sec,
(long)statp->st_atimespec.tv_sec); (long)statp->st_mtimespec.tv_nsec / 1000,
(long)statp->st_atimespec.tv_sec,
(long)statp->st_atimespec.tv_nsec / 1000);
(void)write(rem, path, strlen(path)); (void)write(rem, path, strlen(path));
if (response() < 0) { if (response() < 0) {
closedir(dirp); closedir(dirp);
@ -739,19 +743,19 @@ bad: run_err("%s: %s", np, strerror(errno));
run_err("%s: set mode: %s", run_err("%s: set mode: %s",
np, strerror(errno)); np, strerror(errno));
} }
(void)close(ofd);
(void)response();
if (setimes && wrerr == NO) { if (setimes && wrerr == NO) {
setimes = 0; setimes = 0;
if (utimes(np, tv) < 0) { if (futimes(ofd, tv) < 0) {
run_err("%s: set times: %s", run_err("%s: set times: %s",
np, strerror(errno)); np, strerror(errno));
wrerr = DISPLAYED; wrerr = DISPLAYED;
} }
} }
(void)close(ofd);
(void)response();
switch(wrerr) { switch(wrerr) {
case YES: case YES:
run_err("%s: %s", np, strerror(wrerrno)); run_err("%s: write: %s", np, strerror(wrerrno));
break; break;
case NO: case NO:
(void)write(rem, "", 1); (void)write(rem, "", 1);