FreeBSD/sbin/restore/tape.c
/*
 * Find an inode header.
 * Complain if had to skip.
 */
Find an inode header.
Complain if had to skip.
Find an inode header . Complain if had to skip .
static void
findinode(struct s_spcl *header)
{
	static long skipcnt = 0;
	long i;
	char buf[TP_BSIZE];
	int htype;
	curfile.name = "<name unknown>";
	curfile.action = UNKNOWN;
	curfile.mode = 0;
	curfile.ino = 0;
	do {
		htype = header->c_type;
		switch (htype) {
		case TS_ADDR:
			for (i = 0; i < header->c_count; i++)
				if (header->c_addr[i])
					readtape(buf);
			while (gethead(header) == FAIL ||
			    _time64_to_time(header->c_date) != dumpdate) {
				skipcnt++;
				if (Dflag) {
					byteslide++;
					if (byteslide < TP_BSIZE) {
						blkcnt--;
						blksread--;
					} else 
						byteslide = 0;
				}
			}
			break;
		case TS_INODE:
			curfile.mode = header->c_mode;
			curfile.uid = header->c_uid;
			curfile.gid = header->c_gid;
			curfile.file_flags = header->c_file_flags;
			curfile.rdev = header->c_rdev;
			curfile.atime_sec = header->c_atime;
			curfile.atime_nsec = header->c_atimensec;
			curfile.mtime_sec = header->c_mtime;
			curfile.mtime_nsec = header->c_mtimensec;
			curfile.birthtime_sec = header->c_birthtime;
			curfile.birthtime_nsec = header->c_birthtimensec;
			curfile.extsize = header->c_extsize;
			curfile.size = header->c_size;
			curfile.ino = header->c_inumber;
			break;
		case TS_END:
			if (tapesread & (tapesread + 1)) {
				getvol(0);
				continue;
			}
			curfile.ino = maxino;
			break;
		case TS_CLRI:
			curfile.name = "<file removal list>";
			break;
		case TS_BITS:
			curfile.name = "<file dump list>";
			break;
		case TS_TAPE:
			if (Dflag)
				fprintf(stderr, "unexpected tape header\n");
			else
				panic("unexpected tape header\n");
		default:
			if (Dflag)
				fprintf(stderr, "unknown tape header type %d\n",
				    spcl.c_type);
			else
				panic("unknown tape header type %d\n",
				    spcl.c_type);
			while (gethead(header) == FAIL ||
			    _time64_to_time(header->c_date) != dumpdate) {
				skipcnt++;
				if (Dflag) {
					byteslide++;
					if (byteslide < TP_BSIZE) {
						blkcnt--;
						blksread--;
					} else 
						byteslide = 0;
				}
			}
		}
	} while (htype == TS_ADDR);
	if (skipcnt > 0)
		fprintf(stderr, "resync restore, skipped %ld %s\n",
		    skipcnt, Dflag ? "bytes" : "blocks");
	skipcnt = 0;
}
static void findinode ( struct s_spcl * header ) { static long skipcnt = 0 ; long i ; char buf [ TP_BSIZE ] ; int htype ; curfile . name = " " ; curfile . action = UNKNOWN ; curfile . mode = 0 ; curfile . ino = 0 ; do { htype = header -> c_type ; switch ( htype ) { case TS_ADDR : for ( i = 0 ; i < header -> c_count ; i ++ ) if ( header -> c_addr [ i ] ) readtape ( buf ) ; while ( gethead ( header ) == FAIL || _time64_to_time ( header -> c_date ) != dumpdate ) { skipcnt ++ ; if ( Dflag ) { byteslide ++ ; if ( byteslide < TP_BSIZE ) { blkcnt -- ; blksread -- ; } else byteslide = 0 ; } } break ; case TS_INODE : curfile . mode = header -> c_mode ; curfile . uid = header -> c_uid ; curfile . gid = header -> c_gid ; curfile . file_flags = header -> c_file_flags ; curfile . rdev = header -> c_rdev ; curfile . atime_sec = header -> c_atime ; curfile . atime_nsec = header -> c_atimensec ; curfile . mtime_sec = header -> c_mtime ; curfile . mtime_nsec = header -> c_mtimensec ; curfile . birthtime_sec = header -> c_birthtime ; curfile . birthtime_nsec = header -> c_birthtimensec ; curfile . extsize = header -> c_extsize ; curfile . size = header -> c_size ; curfile . ino = header -> c_inumber ; break ; case TS_END : if ( tapesread & ( tapesread + 1 ) ) { getvol ( 0 ) ; continue ; } curfile . ino = maxino ; break ; case TS_CLRI : curfile . name = " " ; break ; case TS_BITS : curfile . name = " " ; break ; case TS_TAPE : if ( Dflag ) fprintf ( stderr , " \n " ) ; else panic ( " \n " ) ; default : if ( Dflag ) fprintf ( stderr , " \n " , spcl . c_type ) ; else panic ( " \n " , spcl . c_type ) ; while ( gethead ( header ) == FAIL || _time64_to_time ( header -> c_date ) != dumpdate ) { skipcnt ++ ; if ( Dflag ) { byteslide ++ ; if ( byteslide < TP_BSIZE ) { blkcnt -- ; blksread -- ; } else byteslide = 0 ; } } } } while ( htype == TS_ADDR ) ; if ( skipcnt > 0 ) fprintf ( stderr , " \n " , skipcnt , Dflag ? " " : " " ) ; skipcnt = 0 ; }
Find an inode header.
Find an inode header .
/*
			 * Skip up to the beginning of the next record
			 */ /* If we missed some tapes, get another volume. */