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