From 371b64d00f74ac9cc243c8c40ee451878228add4 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Fri, 16 May 2008 16:26:31 +0000 Subject: [PATCH] change the file times to the original values before archiving the objects --- WEGA/src/uts/Makefile | 2 + WEGA/src/uts/dev/Makefile | 3 +- WEGA/src/uts/dev_times | 24 +++++ WEGA/src/uts/touch.c | 193 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 WEGA/src/uts/Makefile create mode 100644 WEGA/src/uts/dev_times create mode 100644 WEGA/src/uts/touch.c diff --git a/WEGA/src/uts/Makefile b/WEGA/src/uts/Makefile new file mode 100644 index 0000000..c19783b --- /dev/null +++ b/WEGA/src/uts/Makefile @@ -0,0 +1,2 @@ +all: touch + cd dev/ && make diff --git a/WEGA/src/uts/dev/Makefile b/WEGA/src/uts/dev/Makefile index 7dc3d18..0bca88a 100644 --- a/WEGA/src/uts/dev/Makefile +++ b/WEGA/src/uts/dev/Makefile @@ -28,7 +28,8 @@ install: LIB2 chmog $(MOD) $(OWN) $(GRP) $(IDIR)/$$file ; \ done -LIB2: $(OBJ) +LIB2: $(OBJ) ../dev_times ../touch + sh -c 'while read line ; do ../touch $$line ; done < ../dev_times' ar cr LIB2 $(OBJ) # use dummy objects diff --git a/WEGA/src/uts/dev_times b/WEGA/src/uts/dev_times new file mode 100644 index 0000000..8a75d25 --- /dev/null +++ b/WEGA/src/uts/dev_times @@ -0,0 +1,24 @@ +121609432888 bio.o +040709363389 siok.o +060114274088 koppel.o +012508262788 ud.o +090815530288 fd.o +082722551983 mem.o +082722565383 sys.o +020818134084 tty.o +092915045583 tt0.o +082723101183 partab.o +123007241988 md.o +051110215688 disk.o +050410262089 lp.o +072813564288 rd.o +072813532388 mt.o +031613285089 cpu2.o +102813530786 udev1.o +102813531986 udev2.o +102813533386 udev3.o +102813534586 udev4.o +102813535686 udev5.o +102813540886 udev6.o +091612431983 clist.o +101515305786 dump.o diff --git a/WEGA/src/uts/touch.c b/WEGA/src/uts/touch.c new file mode 100644 index 0000000..9ee03bd --- /dev/null +++ b/WEGA/src/uts/touch.c @@ -0,0 +1,193 @@ +#include +#include +#include +#include +#include + +struct stat stbuf; +int status; + +char *tzname[2]; +char *cbp; +int dmsize[]; +long timbuf; +extern int *localtime(); +long time(); + +struct { + int hi; + int lo; +}; + +gtime() +{ + register int i; + register int y, t; + int d, h, m, s; + long nt; + + tzset(); + + t = gpair(); + if(t<1 || t>12) + return(1); + d = gpair(); + if(d<1 || d>31) + return(1); + h = gpair(); + if(h == 24) { + h = 0; + d++; + } + m = gpair(); + if(m<0 || m>59) + return(1); + s = gpair(); + if(s<0 || s>59) + return(1); + y = gpair(); + if (y<0) { + time(&nt); + y = localtime(&nt)[5]; + } + if (*cbp == 'p') + h += 12; + if (h<0 || h>23) + return(1); + timbuf = 0; + y += 1900; + for(i=1970; i= 3) + timbuf += 1; + while(--t) + timbuf += dmsize[t-1]; + timbuf += (d-1); + timbuf *= 24; + timbuf += h; + timbuf *= 60; + timbuf += m; + timbuf *= 60; + timbuf += s; + + return(0); +} + + +gpair() +{ + register int c, d; + register char *cp; + + cp = cbp; + if(*cp == 0) + return(-1); + c = (*cp++ - '0') * 10; + if (c<0 || c>100) + return(-1); + if(*cp == 0) + return(-1); + if ((d = *cp++ - '0') < 0 || d > 9) + return(-1); + cbp = cp; + return (c+d); +} +main(argc, argv) +char *argv[]; +{ + register c; + extern long timezone; + struct utimbuf { + long actime; + long modtime; + } times; + + int mflg=1, aflg=1, cflg=0, nflg=0, errflg=0, optc, fd; + extern char *optarg; + extern int optind; + + while ((optc=getopt(argc, argv, "amc")) != EOF) + switch(optc) { + case 'm': + mflg++; + aflg--; + break; + case 'a': + aflg++; + mflg--; + break; + case 'c': + cflg++; + break; + case '?': + errflg++; + } + + if(((argc-optind) < 1) || errflg) { + fprintf(stderr, "usage: touch [-amc] [date] file ...\n"); + exit(2); + } + status = 0; + if(!isnumber(argv[optind])) + if((aflg <= 0) || (mflg <= 0)) + timbuf = time((long *) 0); + else + nflg++; + else { + cbp = (char *)argv[optind++]; + if(gtime()) { + fprintf(stderr, "date: bad conversion\n"); + exit(2); + } + timbuf += timezone; + if (localtime(&timbuf)[8]) + timbuf += -1*60*60; + } + for(c=optind; c