cpio zaps mod times under 4.2bsd
Mark Plotnick
mp at whuxle.UUCP
Fri Feb 17 02:11:12 AEST 1984
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
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list