121173Sdist /* 261536Sbostic * Copyright (c) 1983, 1993 361536Sbostic * The Regents of the University of California. All rights reserved. 465767Sbostic * (c) UNIX System Laboratories, Inc. 565767Sbostic * All or some portions of this file are derived from material licensed 665767Sbostic * to the University of California by American Telephone and Telegraph 765767Sbostic * Co. or Unix System Laboratories, Inc. and are reproduced herein with 865767Sbostic * the permission of UNIX System Laboratories, Inc. 921173Sdist * 1042709Sbostic * %sccs.include.redist.c% 1136105Sbostic * 12*67774Smckusick * @(#)restore.h 8.3 (Berkeley) 09/13/94 1321173Sdist */ 1410315Smckusick 1510315Smckusick /* 1610315Smckusick * Flags 1710315Smckusick */ 1810315Smckusick extern int cvtflag; /* convert from old to new tape format */ 1918496Smckusick extern int bflag; /* set input block size */ 2010315Smckusick extern int dflag; /* print out debugging info */ 2110315Smckusick extern int hflag; /* restore heirarchies */ 2210315Smckusick extern int mflag; /* restore by name instead of inode number */ 2334268Smckusick extern int Nflag; /* do not write the disk */ 2410315Smckusick extern int vflag; /* print out actions taken */ 2510315Smckusick extern int yflag; /* always try to recover from tape errors */ 2610315Smckusick /* 2710315Smckusick * Global variables 2810315Smckusick */ 2910315Smckusick extern char *dumpmap; /* map of inodes on this dump tape */ 30*67774Smckusick extern char *usedinomap; /* map of inodes that are in use on this fs */ 3110315Smckusick extern ino_t maxino; /* highest numbered inode in this file system */ 3210315Smckusick extern long dumpnum; /* location of the dump on this tape */ 3310315Smckusick extern long volno; /* current volume being read */ 3417705Smckusick extern long ntrec; /* number of TP_BSIZE records per tape block */ 3511304Smckusick extern time_t dumptime; /* time that this dump begins */ 3611304Smckusick extern time_t dumpdate; /* time that this dump was made */ 3710315Smckusick extern char command; /* opration being performed */ 3811992Smckusick extern FILE *terminal; /* file descriptor for the terminal input */ 3954581Smckusick extern int oldinofmt; /* reading tape with old format inodes */ 4054581Smckusick extern int Bcvt; /* need byte swapping on inodes and dirs */ 4110315Smckusick 4210315Smckusick /* 4310315Smckusick * Each file in the file system is described by one of these entries 4410315Smckusick */ 4510315Smckusick struct entry { 4610315Smckusick char *e_name; /* the current name of this entry */ 4710315Smckusick u_char e_namlen; /* length of this name */ 4810315Smckusick char e_type; /* type of this entry, see below */ 4910315Smckusick short e_flags; /* status flags, see below */ 5010315Smckusick ino_t e_ino; /* inode number in previous file sys */ 5111645Smckusick long e_index; /* unique index (for dumpped table) */ 5210315Smckusick struct entry *e_parent; /* pointer to parent directory (..) */ 5310315Smckusick struct entry *e_sibling; /* next element in this directory (.) */ 5410315Smckusick struct entry *e_links; /* hard links to this inode */ 5510315Smckusick struct entry *e_entries; /* for directories, their entries */ 5611645Smckusick struct entry *e_next; /* hash chain list */ 5710315Smckusick }; 5810315Smckusick /* types */ 5910315Smckusick #define LEAF 1 /* non-directory entry */ 6010315Smckusick #define NODE 2 /* directory entry */ 6110315Smckusick #define LINK 4 /* synthesized type, stripped by addentry */ 6210315Smckusick /* flags */ 6311645Smckusick #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ 6411645Smckusick #define NEW 0x0002 /* a new entry to be extracted */ 6511645Smckusick #define KEEP 0x0004 /* entry is not to change */ 6611645Smckusick #define REMOVED 0x0010 /* entry has been removed */ 6711645Smckusick #define TMPNAME 0x0020 /* entry has been given a temporary name */ 6818006Smckusick #define EXISTED 0x0040 /* directory already existed during extract */ 6956567Sbostic 7010315Smckusick /* 7110315Smckusick * Constants associated with entry structs 7210315Smckusick */ 7311645Smckusick #define HARDLINK 1 7411645Smckusick #define SYMLINK 2 7511645Smckusick #define TMPHDR "RSTTMP" 7610315Smckusick 7710315Smckusick /* 7810315Smckusick * The entry describes the next file available on the tape 7910315Smckusick */ 8010315Smckusick struct context { 8110315Smckusick char *name; /* name of file */ 8210315Smckusick ino_t ino; /* inumber of file */ 8310315Smckusick struct dinode *dip; /* pointer to inode */ 8410315Smckusick char action; /* action being taken on this file */ 8510315Smckusick } curfile; 8610315Smckusick /* actions */ 8710315Smckusick #define USING 1 /* extracting from the tape */ 8810315Smckusick #define SKIP 2 /* skipping */ 8910315Smckusick #define UNKNOWN 3 /* disposition or starting point is unknown */ 9010315Smckusick 9110315Smckusick /* 9240063Smckusick * Definitions for library routines operating on directories. 9340063Smckusick */ 9450656Smckusick typedef struct rstdirdesc RST_DIR; 9540063Smckusick 9640063Smckusick /* 9755879Smckusick * Flags to setdirmodes. 9855879Smckusick */ 9955879Smckusick #define FORCE 0x0001 10055879Smckusick 10155879Smckusick /* 10210315Smckusick * Useful macros 10310315Smckusick */ 10456431Smckusick #define TSTINO(ino, map) \ 10556431Smckusick (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 106*67774Smckusick #define SETINO(ino, map) \ 107*67774Smckusick map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) 10810315Smckusick 10910315Smckusick #define dprintf if (dflag) fprintf 11010315Smckusick #define vprintf if (vflag) fprintf 11110315Smckusick 11211304Smckusick #define GOOD 1 11311304Smckusick #define FAIL 0 114