Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Nov 2002 09:48:10 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 21071 for review
Message-ID:  <200211151748.gAFHmAcH007411@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=21071

Change 21071 by peter@peter_precision on 2002/11/15 09:47:48

	Dont use utime(3) (obsolete anyway).  It is sizeof(time_t) sensitive
	and is asking for trouble if you get includes out of sync with
	the emulation of utime() in libc/gen/utime.c.  utimes(2) uses
	struct timeval, which has explicit 'long' values for times.

Affected files ...

.. //depot/projects/ia64/usr.bin/xinstall/xinstall.c#12 edit

Differences ...

==== //depot/projects/ia64/usr.bin/xinstall/xinstall.c#12 (text+ko) ====

@@ -64,7 +64,6 @@
 #include <string.h>
 #include <sysexits.h>
 #include <unistd.h>
-#include <utime.h>
 
 #include "pathnames.h"
 
@@ -262,7 +261,7 @@
 install(const char *from_name, const char *to_name, u_long fset, u_int flags)
 {
 	struct stat from_sb, temp_sb, to_sb;
-	struct utimbuf utb;
+	struct timeval tvb[2];
 	int devnull, files_match, from_fd, serrno, target;
 	int tempcopy, temp_fd, to_fd;
 	char backup[MAXPATHLEN], *p, pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN];
@@ -377,9 +376,11 @@
 			 * Need to preserve target file times, though.
 			 */
 			if (to_sb.st_nlink != 1) {
-				utb.actime = to_sb.st_atime;
-				utb.modtime = to_sb.st_mtime;
-				(void)utime(tempfile, &utb);
+				tvb[0].tv_sec = to_sb.st_atime;
+				tvb[0].tv_usec = 0;
+				tvb[1].tv_sec = to_sb.st_mtime;
+				tvb[1].tv_usec = 0;
+				(void)utimes(tempfile, tvb);
 			} else {
 				files_match = 1;
 				(void)unlink(tempfile);
@@ -433,9 +434,11 @@
 	 * Preserve the timestamp of the source file if necessary.
 	 */
 	if (dopreserve && !files_match && !devnull) {
-		utb.actime = from_sb.st_atime;
-		utb.modtime = from_sb.st_mtime;
-		(void)utime(to_name, &utb);
+		tvb[0].tv_sec = from_sb.st_atime;
+		tvb[0].tv_usec = 0;
+		tvb[1].tv_sec = from_sb.st_mtime;
+		tvb[1].tv_usec = 0;
+		(void)utimes(to_name, tvb);
 	}
 
 	if (fstat(to_fd, &to_sb) == -1) {

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211151748.gAFHmAcH007411>