1 /* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)restore.h 8.1 (Berkeley) 06/05/93 8 */ 9 10 /* 11 * Flags 12 */ 13 extern int cvtflag; /* convert from old to new tape format */ 14 extern int bflag; /* set input block size */ 15 extern int dflag; /* print out debugging info */ 16 extern int hflag; /* restore heirarchies */ 17 extern int mflag; /* restore by name instead of inode number */ 18 extern int Nflag; /* do not write the disk */ 19 extern int vflag; /* print out actions taken */ 20 extern int yflag; /* always try to recover from tape errors */ 21 /* 22 * Global variables 23 */ 24 extern char *dumpmap; /* map of inodes on this dump tape */ 25 extern char *clrimap; /* map of inodes to be deleted */ 26 extern ino_t maxino; /* highest numbered inode in this file system */ 27 extern long dumpnum; /* location of the dump on this tape */ 28 extern long volno; /* current volume being read */ 29 extern long ntrec; /* number of TP_BSIZE records per tape block */ 30 extern time_t dumptime; /* time that this dump begins */ 31 extern time_t dumpdate; /* time that this dump was made */ 32 extern char command; /* opration being performed */ 33 extern FILE *terminal; /* file descriptor for the terminal input */ 34 extern int oldinofmt; /* reading tape with old format inodes */ 35 extern int Bcvt; /* need byte swapping on inodes and dirs */ 36 37 /* 38 * Each file in the file system is described by one of these entries 39 */ 40 struct entry { 41 char *e_name; /* the current name of this entry */ 42 u_char e_namlen; /* length of this name */ 43 char e_type; /* type of this entry, see below */ 44 short e_flags; /* status flags, see below */ 45 ino_t e_ino; /* inode number in previous file sys */ 46 long e_index; /* unique index (for dumpped table) */ 47 struct entry *e_parent; /* pointer to parent directory (..) */ 48 struct entry *e_sibling; /* next element in this directory (.) */ 49 struct entry *e_links; /* hard links to this inode */ 50 struct entry *e_entries; /* for directories, their entries */ 51 struct entry *e_next; /* hash chain list */ 52 }; 53 /* types */ 54 #define LEAF 1 /* non-directory entry */ 55 #define NODE 2 /* directory entry */ 56 #define LINK 4 /* synthesized type, stripped by addentry */ 57 /* flags */ 58 #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ 59 #define NEW 0x0002 /* a new entry to be extracted */ 60 #define KEEP 0x0004 /* entry is not to change */ 61 #define REMOVED 0x0010 /* entry has been removed */ 62 #define TMPNAME 0x0020 /* entry has been given a temporary name */ 63 #define EXISTED 0x0040 /* directory already existed during extract */ 64 65 /* 66 * Constants associated with entry structs 67 */ 68 #define HARDLINK 1 69 #define SYMLINK 2 70 #define TMPHDR "RSTTMP" 71 72 /* 73 * The entry describes the next file available on the tape 74 */ 75 struct context { 76 char *name; /* name of file */ 77 ino_t ino; /* inumber of file */ 78 struct dinode *dip; /* pointer to inode */ 79 char action; /* action being taken on this file */ 80 } curfile; 81 /* actions */ 82 #define USING 1 /* extracting from the tape */ 83 #define SKIP 2 /* skipping */ 84 #define UNKNOWN 3 /* disposition or starting point is unknown */ 85 86 /* 87 * Definitions for library routines operating on directories. 88 */ 89 typedef struct rstdirdesc RST_DIR; 90 91 /* 92 * Flags to setdirmodes. 93 */ 94 #define FORCE 0x0001 95 96 /* 97 * Useful macros 98 */ 99 #define TSTINO(ino, map) \ 100 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 101 102 #define dprintf if (dflag) fprintf 103 #define vprintf if (vflag) fprintf 104 105 #define GOOD 1 106 #define FAIL 0 107