Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site whuxle.UUCP
Path: utzoo!watmath!clyde!burl!we13!ihnp4!whuxle!mp
From: mp@whuxle.UUCP (Mark Plotnick)
Newsgroups: net.bugs.4bsd
Subject: cpio zaps mod times under 4.2bsd
Message-ID: <244@whuxle.UUCP>
Date: Thu, 16-Feb-84 11:11:12 EST
Article-I.D.: whuxle.244
Posted: Thu Feb 16 11:11:12 1984
Date-Received: Fri, 17-Feb-84 03:17:53 EST
Organization: Bell Labs, Whippany
Lines: 66

When cpio is run under 4.2bsd, specifying the -a option causes the mod
times on all the selected input files to be set to 0 (which we all know by
now is "Feb  6  2^A06" eastern, "Feb  5  2^A06" pacific; check local
lstings for exact time in your area).  Files with 0 mod times cause
programs like "make" to get indigestion.

The problem is that cpio assumes that, in the stat structure, st_mtime
is adjacent to st_atime.  Not so in 4.2bsd, where a word of zeroes
(st_spare1) follows st_atime.  Such is the price of progress.

Fixes follow.  Line numbers are for comparison purposes only; actual
line numbers may vary, depending on what model cpio you own.

*** 280,287
  				Cflag? writehdr(BBuf,ct): bwrite(Buf,ct);
  			}
  			close(Ifile);
! 			if(Acc_time)
! 				utime(Hdr.h_name, &Statb.st_atime);
  			if(Verbose)
  				err("%s\n", Hdr.h_name);
  		}

--- 280,291 -----
  				Cflag? writehdr(BBuf,ct): bwrite(Buf,ct);
  			}
  			close(Ifile);
! 			if(Acc_time) {
! 				time_t timevec[2];
! 				timevec[0] = Statb.st_atime;
! 				timevec[1] = Statb.st_mtime;
! 				utime(Hdr.h_name, timevec);
! 			}
  			if(Verbose)
  				err("%s\n", Hdr.h_name);
  		}
***************
*** 378,385
  				++Blocks;
  			}
  			close(Ifile);
! 			if(Acc_time)
! 				utime(Hdr.h_name, &Statb.st_atime);
  			if(Ofile) {
  				close(Ofile);
  				set_time(Fullname, Statb.st_atime, mklong(Hdr.h_mtime));

--- 382,393 -----
  				++Blocks;
  			}
  			close(Ifile);
! 			if(Acc_time) {
! 				time_t timevec[2];
! 				timevec[0] = Statb.st_atime;
! 				timevec[1] = Statb.st_mtime;
! 				utime(Hdr.h_name, timevec);
! 			}
  			if(Ofile) {
  				close(Ofile);
  				set_time(Fullname, Statb.st_atime, mklong(Hdr.h_mtime));

Cpio also doesn't understand symbolic links.  But then again, neither
does "cp -r".


	Mark Plotnick WH 1C-244 x6955