[net.sources] dump/file-restore diffs

petec@umcp-cs.UUCP (02/28/84)

: Run this shell script with "sh" not "csh"
PATH=:/bin:/usr/bin:/usr/ucb
export PATH
all=FALSE
if [ $1x = -ax ]; then
	all=TRUE
fi
/bin/echo 'Extracting DIFFNOTES'
sed 's/^X//' <<'//go.sysin dd *' >DIFFNOTES
The files in this directory, named for the modules of the
dump program, are actually diff listings between the Berkeley
code and the University of Maryland's hacked versions. Since 
there have been no revisions to the unctime.c module, there is
no diff file here for it.
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 DIFFNOTES
	/bin/echo -n '	'; /bin/ls -ld DIFFNOTES
fi
/bin/echo 'Extracting dump.h'
sed 's/^X//' <<'//go.sysin dd *' >dump.h
5a6,7
> /* #define DEBUG 1 */
> #define TAPNAMOPT 1
18a21,23
> #ifdef	DEBUG
> #include "dumprestor.h"
> #else
19a25
> #endif
58a65,92
> #ifdef	TAPNAMOPT
> /* This structure is used in 'putitime' to determine which entries
>    in /etc/dumpdates can be trashed */
> #define NUMDEV 15
> #define MAXTPD 100
> struct usedlist{
> 	char	dev_name[16];
> 	char	tused[MAXTPD][MAXTAPNAM+1];
> 	int	notapes;
> } used_list[NUMDEV];
> /* int	nodevs=0; Taken out so that nodevs would not be multiply defined. It
> 		  is now defined in dumpmain.c */
> int	tflag;		/* Tape Name flag, set if Tape Name is 
> 			   given in call line */
> ino_t	prev_ino;	/* Remeber starting inode for parent */
> int	pv_tps;		/* index for ptapes */
> char	ptapes[MAXTAPDMP][MAXTAPNAM+1];
> 			/* Holds all previously used tapes */
> char	dtapes[MAXTAPDMP][MAXTAPNAM+1];
> 			/* Holds names of tapes used for dump */
> ino_t	dinos[MAXTAPDMP];
> 			/* Holds starting inodes for tapes dumped */
> int	ask_tapnam;
> char	tape_name[MAXTAPNAM+2];/* leave room for \n\0 */
> FILE	*ftapnam;
> int	unpk_tapes(),unpk_inos();
> char	*pk_tapes(),*pk_inos();
> #endif
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 dump.h
	/bin/echo -n '	'; /bin/ls -ld dump.h
fi
/bin/echo 'Extracting dumpitime.d'
sed 's/^X//' <<'//go.sysin dd *' >dumpitime.d
1a2,7
> /* #define PKDEBUG 1
> #define FDEBUG 1
> #define TNDEBUG 1
>  */
> extern	char fnfile[];
> extern  int nodevs;
95a102,130
> 
> #ifdef	TAPNAMOPT
> 	/* Insert this dumps record at the begining of the dumpdates file.
> 	   And mark the tapes used for this dump as previously used.
> 	   If the existing records contain ONLY tapes that have been
> 	   ALREADY USED, then that record will be deleted.  Note:  This
> 	   is different that the original way in which the dumpdates file
> 	   was maintained.
> 	 */
> 	itwalk = (struct idates *)calloc(1, sizeof(struct idates));
> 	/* Arrayify the list of tape names & starting inode numbers */
> 	itwalk->id_notapes = get_tapesused(itwalk->id_tapes,itwalk->id_inos);
> 	/* mark tapes used for this dump as already used */
> 	(void)alreadyused(itwalk->id_tapes,itwalk->id_notapes,fname);
> 
> 	strncpy(itwalk->id_name, fname, sizeof (itwalk->id_name));
> 	itwalk->id_incno = incno;
> 	itwalk->id_ddate = spcl.c_date;
> 
> 	if ( (df = fopen(increm, "w")) == NULL){
> 		msg("Cannot open %s\n", increm);
> 		dumpabort();
> 	}
> 
> 	/* Write out first entry (new) */
> 	recout(df,itwalk);
> 
> 	/* Write out the dumpdates file, saving only the entries
> 	   with valid tape information on them */
96a132,142
> 		if (alreadyused(itwalk->id_tapes,itwalk->id_notapes,
> 				itwalk->id_name) &&
> 				itwalk->id_notapes > 0)
> 			continue;
> 		recout(df, itwalk);
> 	}
> 	fclose(df);
> 	msg("level %c dump on %s\n", incno, prdate(spcl.c_date));
> #else
> 	
> 	ITITERATE(i, itwalk){
110a157
> 
119a167
> 
124a173
> #endif	TAPNAMOPT
130a180,199
> #ifdef	TAPNAMOPT
> 	char	tap_buf[100],ino_buf[100];
> 	char	*buftime=ctime(&(what->id_ddate));
> 
> 	buftime[strlen(buftime)-1] = '\0'; /* get rid of \n */
> 	if (what->id_notapes > 0){
> 		fprintf(file, TNDUMPOUTFMT,
> 			what->id_name,
> 			what->id_incno,
> 			buftime,
> 			pk_tapes(tap_buf,what->id_tapes,what->id_notapes),
> 			pk_inos(ino_buf,what->id_inos,what->id_notapes));
> 	}
> 	else{
> 		fprintf(file, TN_DUMPOUTFMT,
> 			what->id_name,
> 			what->id_incno,
> 			buftime);
> 	}
> #else
134,135c203,204
< 		ctime(&(what->id_ddate))
< 	);
---
> 		ctime(&(what->id_ddate)));
> #endif
138,139c207,210
< int	recno;
< int getrecord(df, idatep)
---
> 
> 
> int	recno = 0;
> int getrecord(df, ip)
141c212
< 	struct	idates	*idatep;
---
> 	struct	idates	*ip;
143c214,216
< 	char		buf[BUFSIZ];
---
> #ifdef	TAPNAMOPT
> 	char	buf[BUFSIZ],tap_buf[100],ino_buf[100];
> 	int	nocnv;
145d217
< 	recno = 0;
148a221,247
> 
> 	nocnv = sscanf(buf,TNDUMPINFMT,ip->id_name,&(ip->id_incno),ip->id_pdate);
> 	nocnv = sscanf(&(buf[ENDOLDLINE]),"%s %s",tap_buf,ino_buf);
> 	if (nocnv < 2){
> 		ip->id_notapes = 0;
> 	}
> 	else{
> 		ip->id_notapes = unpk_tapes(tap_buf,ip->id_tapes);	
> 		if (unpk_inos(ino_buf,ip->id_inos) != ip->id_notapes){
> 			msg("Mismatched tape names & starting inode numbers, line %d\n",
> 				recno);
> 		}
> 	}
> 
> 	if (makeidate(ip, ip->id_pdate) < 0)
> 		msg("Unknown intermediate format in %s, line %d\n",
> 			NINCREM, recno);
> 
> #ifdef FDEBUG
> 	msg("getrecord: %s %c %s\n",
> 		ip->id_name, ip->id_incno, prdate(ip->id_ddate));
> #endif
> #else
> 
> 	if ( (fgets(buf, BUFSIZ, df)) != buf)
> 		return(-1);
> 	recno++;
157a257
> #endif
159a260
> 
203d303
< 	char	un_buf[128];
205c305,314
< 	sscanf(buf, DUMPINFMT, ip->id_name, &ip->id_incno, un_buf);
---
> #ifdef	TAPNAMOPT
> #ifdef	DEBUG
> msg("Decode this time '%s'\n",buf);
> #endif
> 	ip->id_ddate = unctime(buf);
> 	if (ip->id_ddate < 0)
> 		return(-1);
> 	return(0);
> #else
> 	sscanf(buf, DUMPINFMT, ip->id_name, &ip->id_incno, un_buf);
209a319
> #endif
211a322
> 
244a356,580
> }
> 
> 
> 
> unpk_tapes(buf,ar)
> char	*buf,ar[MAXTAPDMP][MAXTAPNAM+1];
> {
> 	int i=0;
> 	char *ptr=buf,*ent,c,c2;
> 	
> #ifdef	TNDEBUG
> msg("     In UNPK tapes function with `%s'  (array is at %x)\n",buf,ar);
> #endif
> 	while(*ptr){
> 		ent = (ptr == buf)? ptr: ++ptr;/* skip over comma, if ness */
> 		/* find end of entry */
> 		while (*ptr != ',' && *ptr != '\0')
> 			ptr++;
> 		c = *ptr;
> 		c2 = '\0';
> 		*ptr = '\0';/* temp mark end of string */
> 		/* Watch for tape names that are too long */
> 		if(strlen(ent) > MAXTAPNAM){
> 			msg("Tape name too long %s in %s\n",ent,NINCREM);
> 			/* prevent subscript error */
> 			c2 = ent[MAXTAPNAM];
> 			ent[MAXTAPNAM] = '\0';
> 			msg("Truncated to '%s'\n",ent);
> 		}
> 		/* Assign tape name to i(th) position */
> 		strcpy(ar[i],ent);
> 		/* prevent subscript error */
> 		if (c2)
> 			ent[MAXTAPNAM] = c2;
> 
> 		i++;
> 		/* replace char saved */
> 		*ptr = c;
> 	}
> 	return(i);
> }
> 
> 
> 
> 
> unpk_inos(buf,inos)
> char	*buf;
> ino_t	inos[MAXTAPDMP];
> {
> 	int i=0;	/* count # of entries */
> 	char *ptr=buf,*ent,c;
> 	
> #ifdef	PKDEBUG
> msg("     In UNPK INOS function with `%s'  (array is at %x)\n",buf,inos);
> #endif
> 	while(*ptr){
> 		ent = (ptr == buf)? ptr: ++ptr;/* skip over comma, if ness */
> 		/* find end of entry */
> 		while (*ptr != ',' && *ptr != '\0')
> 			ptr++;
> 		c = *ptr;
> 		*ptr = '\0';/* temp mark end of string */
> 		inos[i++] = (ino_t)(atoi(ent));
> #ifdef	PKDEBUG
> msg("inode(%d) = %d\n",i,(int)(inos[i-1]));
> #endif
> 		/* replace char saved */
> 		*ptr = c;
> 	}
> 	return(i);
> }
> 
> 
> 
> char *
> pk_inos(inobuf,inos,n)
> char	*inobuf;
> ino_t	inos[MAXTAPDMP];
> {
> 	char tbuf[10];
> 	int i;
> 	
> 	*inobuf = '\0';
> 	for(i=0; i < n; i++){
> 		sprintf(tbuf,"%d",(int)(inos[i]));
> 		strcat(inobuf,tbuf);
> 		strcat(inobuf,(i==n-1)? "" : ",");
> #ifdef	PKDEBUG
> msg("   ** In PK_INOS (%d=%s)   line is %s\n",i,tbuf,inobuf);
> #endif
> 	}
> 	return(inobuf);
> }
> 
> 
> 
> char *
> pk_tapes(tapbuf,tapes,n)
> char	*tapbuf,tapes[MAXTAPDMP][MAXTAPNAM+1];
> int	n;
> {
> 	int i;
> 
> 	*tapbuf = '\0';
> 	for(i=0; i < n; i++){
> 		strcat(tapbuf,tapes[i]);
> 		strcat(tapbuf,(i == n-1)? "" : ",");
> #ifdef	PKDEBUG
> msg("  ** In PK_TAPES (%d=%s)  line is %s\n",i,tapes[i],tapbuf);
> #endif
> 	}
> 	return(tapbuf);
> }
> 
> 
> 
> 
> get_tapesused(tapes,inos)
> char	tapes[MAXTAPDMP][MAXTAPNAM+1];
> ino_t	inos[MAXTAPDMP];
> {
> 	char buf[BUFSIZ];
> 	int tapeno,notapes=0,int_ino,i;
> 
> #ifdef	TNDEBUG
> msg("\nIn GET TAPES USED\n");
> #endif
> 	if ((ftapnam = fopen(fnfile,"r")) == NULL){
> 		/* Can't determince tapes used */
> 		return(0);
> 	}
> 	/* put tape names & starting inodes into arrays */
> 	while (fgets(buf,BUFSIZ,ftapnam) == buf){
> 		/* The tapeno tells us where this entry belongs in 
> 		   the arrays.  Actually this file should be in reverse
> 		   order, due to the recursive nature in which the
> 		   dump returns or exits */
> 		sscanf(buf,"%d",&tapeno);
> 		sscanf(buf,"%d %s %d",&i,tapes[tapeno-1],&int_ino);
> 		inos[tapeno-1] = (ino_t)int_ino;
> 		if (tapeno > notapes)
> 			/* Remember the number of tapes (for return) */
> 			notapes = tapeno;
> #ifdef	TNDEBUG
> msg("Tape Name rec: %s",buf);
> msg("Tapes(%d) = %s  & Inos(%d) = %d\n",tapeno,tapes[tapeno-1],tapeno,inos[tapeno-1]);
> #endif
> 	}
> 	fclose(ftapnam);
> 	return((notapes > MAXTAPDMP) ? MAXTAPDMP : notapes);
> }
> 
> 
> 
> /* alreadyused:  This returns 1, if all the tapes on the tape list (tapes)
>    have been previously used.  Otherwise, 0 is returned.  If the tape
>    list is null (ie. n=0) then 1 is returned.  The purpose is to keep
>    track of tapes which have valid dump data on them.  It is expected
>    that the dump tapes will periodically be re-used.  So after they
>    are re-used, this routine will allow reused tape entries to be
>    erased. */
> 
> alreadyused(tapes,n,dev)
> char	tapes[MAXTAPDMP][MAXTAPNAM+1];
> int	n;
> char	dev[16];		/* should be 16, as in <dumprestor.h> */
> {
> 	int nomatch=0,i,j,pused;
> 	int d,dd;
> 	
> #ifdef	TNDEBUG
> msg("In already used with (n=%d)\n",n);
> for(i=0;i<n;i++)
> 	printf("(%d) = %s\t",i,tapes[i]);
> printf("\n");
> #endif
> 	/* Treat each device separately, concerning tape names */
> 	for(d=0,dd=(-1); d < nodevs; d++){
> 		/* determine tapes list to use */
> 		if (strcmp(dev,used_list[d].dev_name) == 0){
> 			/* Use this list of tape names */
> 			dd = d;
> 			break;
> 		}
> 	}
> 	if (dd == (-1)){
> 		/* This file system not found yet.  So insert it into the
> 		   list of file systems we have so far */
> 		strncpy(used_list[nodevs].dev_name,dev,sizeof(used_list[nodevs].dev_name));
> 		dd = nodevs++;
> 	}
> 
> 
> 	/* Now look for the tapes passed (ie. tapes) in this list of tapes
> 	   for this file system */
> 	for(i=0; i < n; i++){
> 		/* Has this tape been used by a more recent dump??? */
> 		for(j=0,pused=0; j < used_list[dd].notapes; j++)
> 			if (strcmp(used_list[dd].tused[j],tapes[i]) == 0){
> 				/*  Tape[i] has already been used by a more
> 				   recent dump. So this entry is really no
> 				   longer usefull */
> 				nomatch++;
> 				pused = 1;
> 				break;
> 			}
> 		if (pused == 0){
> 			/*  This tape has not been used on any previous
> 			   dumps, so mark it as being used now (by this
> 			   entry) */
> 			strcpy(used_list[dd].tused[used_list[dd].notapes++],tapes[i]);
> 		}
> 	}			/* end for */
> 
> 	/* If all tapes in this entry have been used previously, then
> 	   let this entry be overwritten */
> #ifdef	TNDEBUG
> msg("EXIT Already Used: Number Matched is %d\n",nomatch);
> if (nomatch  == n)
> 	msg("     ** Exit Already Used with (%d)\n",1);
> else
> 	msg("     ** Exit Already Used with (%d)\n",0);
> #endif	
> 	if (nomatch == n) return(1);/*  Overwrite this entry */
> 	return(0);		/* Save this entry */
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 dumpitime.d
	/bin/echo -n '	'; /bin/ls -ld dumpitime.d
fi
/bin/echo 'Extracting dumpmain.d'
sed 's/^X//' <<'//go.sysin dd *' >dumpmain.d
3a4
> int     nodevs=0;
8c9,12
< 
---
> #ifdef	TAPNAMOPT
> /* temperary file used to hold tape names & starting inode numbers */
> char	fnfile[]="/tmp/dumpXXXXXX";
> #endif
96a101,111
> #ifdef	TAPNAMOPT
> 	case 't':
> 		tflag++;
> 		if (argc > 1){
> 			argv++;
> 			argc--;
> 			strcpy(tape_name,*argv);
> 		}
> 		break;
> #endif	TAPNAMOPT
> 
123a139,153
> #ifdef	TAPNAMOPT
> 	/* Create temp file for holding tapenames & starting inode numbers */
> 	mktemp(fnfile);
> 	prev_ino = 0;
> 
> 	if (tflag == 0){
> 		msg("What is the tape name (Max len %d)? ",
> 				MAXTAPNAM);
> 		fgets(tape_name,MAXTAPNAM+2,stdin);
> 		/*  get rid of \n */
> 		tape_name[strlen(tape_name)-1] = '\0';
> 	}
> 	
> 
> #endif	TAPNAMOPT
143a174
> 
187d217
< 
196a227
> 
202a234,236
> #ifdef	TAPNAMOPT
> 	unlink(fnfile);
> #endif	TAPNAMOPT	
227a262
> 	char *rindex();
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 dumpmain.d
	/bin/echo -n '	'; /bin/ls -ld dumpmain.d
fi
/bin/echo 'Extracting dumpoptr.d'
sed 's/^X//' <<'//go.sysin dd *' >dumpoptr.d
1a2
> extern int nodevs;
51a53,61
> #ifdef	TAPNAMOPT
> 				if (ask_tapnam){
> 				msg("What is the tape name (Max len %d)? ",
> 						MAXTAPNAM);
> 				fgets(tape_name,MAXTAPNAM+2,mytty);
> 				/*  get rid of \n */
> 				tape_name[strlen(tape_name)-1] = '\0';
> 				}
> #endif				
90a101
> 	msg("Dump in PROGRESS (at inode %d)\n",(int)ino);
321c332
< 	keylength = min(strlen(key), sizeof (dt->fs_file));
---
> /*	keylength = min(strlen(key), sizeof (dt->fs_file));  PJS & PBC */
322a334
> 		keylength = min(max(strlen(dt->fs_file), strlen(key)),sizeof(dt->fs_file));
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 dumpoptr.d
	/bin/echo -n '	'; /bin/ls -ld dumpoptr.d
fi
/bin/echo 'Extracting dumptape.d'
sed 's/^X//' <<'//go.sysin dd *' >dumptape.d
1a2,3
> /* #define TDEBUG 1 */
> extern int nodevs;
6a9
> extern	char fnfile[];
7a11
> 
84a89,91
> #ifdef	TAPNAMOPT
> 		/* also prompt for tape name */
> 		ask_tapnam = 1;
85a93,94
> 		ask_tapnam = 0;
> #endif
111a121,123
> #ifdef	TAPNAMOPT
> 	int	sv_ask=0;
> #endif
118a131,134
> #ifdef	TAPNAMOPT
> 		if (sv_ask)ask_tapnam=1;
> 		/* Also ask for tape name here (see query) */
> #endif
120a137,141
> #ifdef	TAPNAMOPT
> 		if (ask_tapnam)sv_ask=1;
> 		/* Don't ask for tape name here! */
> 		ask_tapnam=0;
> #endif
207a229
> 
209a232
> 		
222a246,260
> #ifdef	TAPNAMOPT
> 				/*  This bit of code keeps track of the tape
> 				    names & starting inodes */
> 				if ((ftapnam=fopen(fnfile,"a")) == NULL){
> 					msg("Can't open %s to keep track of tape names\n",fnfile);
> 				}
> 				else{
> 					fprintf(ftapnam,TAPNAMFMT,tapeno+1,tape_name,(tapeno == 0)? 0 : ino);
> #ifdef	TDEBUG
> printf("*** Start Writing tape(#%d) is %s, (at inode %d)\n",tapeno+1,tape_name,ino);
> #endif
> 					fclose(ftapnam);
> 				}
> 				
> #endif	TAPNAMOPT
254a293,295
> #ifdef	TAPNAMOPT
> 	unlink(fnfile);
> #endif	TAPNAMOPT
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 dumptape.d
	/bin/echo -n '	'; /bin/ls -ld dumptape.d
fi
/bin/echo 'Extracting dumptraverse.d'
sed 's/^X//' <<'//go.sysin dd *' >dumptraverse.d
1a2,3
> /* #define	QUICKPASS 1 */
> extern int nodevs;
15c17,19
< 
---
> #ifdef	QUICKPASS
> return;
> #endif
//go.sysin dd *
made=TRUE
if [ $made = TRUE ]; then
	/bin/chmod 644 dumptraverse.d
	/bin/echo -n '	'; /bin/ls -ld dumptraverse.d
fi
-- 
Call-Me:   Pete Cottrell, Univ. of Md. Comp. Sci. Dept.
UUCP:	   {seismo,allegra,brl-bmd}!umcp-cs!petec
CSNet:	   petec@umcp-cs
ARPA:	   petec.umcp-cs@CSNet-Relay