|
|
1.1.1.2 ! root 1: /* ! 2: * Copyright (c) 1983 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)restore.h 5.1 (Berkeley) 5/28/85 ! 7: */ 1.1 root 8: 9: #include <stdio.h> 10: #include <sys/param.h> 11: #include <sys/inode.h> 12: #include <sys/fs.h> 1.1.1.2 ! root 13: #include <sys/dir.h> 1.1 root 14: 15: /* 16: * Flags 17: */ 18: extern int cvtflag; /* convert from old to new tape format */ 1.1.1.2 ! root 19: extern int bflag; /* set input block size */ 1.1 root 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 vflag; /* print out actions taken */ 24: extern int yflag; /* always try to recover from tape errors */ 25: /* 26: * Global variables 27: */ 28: extern char *dumpmap; /* map of inodes on this dump tape */ 29: extern char *clrimap; /* map of inodes to be deleted */ 30: extern ino_t maxino; /* highest numbered inode in this file system */ 31: extern long dumpnum; /* location of the dump on this tape */ 32: extern long volno; /* current volume being read */ 1.1.1.2 ! root 33: extern long ntrec; /* number of TP_BSIZE records per tape block */ 1.1 root 34: extern time_t dumptime; /* time that this dump begins */ 35: extern time_t dumpdate; /* time that this dump was made */ 36: extern char command; /* opration being performed */ 37: extern FILE *terminal; /* file descriptor for the terminal input */ 38: 39: /* 40: * Each file in the file system is described by one of these entries 41: */ 42: struct entry { 43: char *e_name; /* the current name of this entry */ 44: u_char e_namlen; /* length of this name */ 45: char e_type; /* type of this entry, see below */ 46: short e_flags; /* status flags, see below */ 47: ino_t e_ino; /* inode number in previous file sys */ 48: long e_index; /* unique index (for dumpped table) */ 49: struct entry *e_parent; /* pointer to parent directory (..) */ 50: struct entry *e_sibling; /* next element in this directory (.) */ 51: struct entry *e_links; /* hard links to this inode */ 52: struct entry *e_entries; /* for directories, their entries */ 53: struct entry *e_next; /* hash chain list */ 54: }; 55: /* types */ 56: #define LEAF 1 /* non-directory entry */ 57: #define NODE 2 /* directory entry */ 58: #define LINK 4 /* synthesized type, stripped by addentry */ 59: /* flags */ 60: #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ 61: #define NEW 0x0002 /* a new entry to be extracted */ 62: #define KEEP 0x0004 /* entry is not to change */ 63: #define REMOVED 0x0010 /* entry has been removed */ 64: #define TMPNAME 0x0020 /* entry has been given a temporary name */ 1.1.1.2 ! root 65: #define EXISTED 0x0040 /* directory already existed during extract */ 1.1 root 66: /* 67: * functions defined on entry structs 68: */ 69: extern struct entry *lookupino(); 70: extern struct entry *lookupname(); 71: extern struct entry *lookupparent(); 72: extern struct entry *addentry(); 73: extern char *myname(); 74: extern char *savename(); 75: extern char *gentempname(); 76: extern char *flagvalues(); 77: extern ino_t lowerbnd(); 78: extern ino_t upperbnd(); 1.1.1.2 ! root 79: extern DIR *rst_opendir(); ! 80: extern struct direct *rst_readdir(); 1.1 root 81: #define NIL ((struct entry *)(0)) 82: /* 83: * Constants associated with entry structs 84: */ 85: #define HARDLINK 1 86: #define SYMLINK 2 87: #define TMPHDR "RSTTMP" 88: 89: /* 90: * The entry describes the next file available on the tape 91: */ 92: struct context { 93: char *name; /* name of file */ 94: ino_t ino; /* inumber of file */ 95: struct dinode *dip; /* pointer to inode */ 96: char action; /* action being taken on this file */ 97: } curfile; 98: /* actions */ 99: #define USING 1 /* extracting from the tape */ 100: #define SKIP 2 /* skipping */ 101: #define UNKNOWN 3 /* disposition or starting point is unknown */ 102: 103: /* 104: * Other exported routines 105: */ 106: extern ino_t psearch(); 107: extern ino_t dirlookup(); 108: extern long listfile(); 109: extern long deletefile(); 110: extern long addfile(); 111: extern long nodeupdates(); 112: extern long verifyfile(); 113: extern char *rindex(); 114: extern char *index(); 115: extern char *strcat(); 116: extern char *strncat(); 117: extern char *strcpy(); 118: extern char *strncpy(); 119: extern char *fgets(); 120: extern char *mktemp(); 121: extern char *malloc(); 122: extern char *calloc(); 123: extern char *realloc(); 124: extern long lseek(); 125: 126: /* 127: * Useful macros 128: */ 129: #define MWORD(m,i) (m[(unsigned)(i-1)/NBBY]) 130: #define MBIT(i) (1<<((unsigned)(i-1)%NBBY)) 131: #define BIS(i,w) (MWORD(w,i) |= MBIT(i)) 132: #define BIC(i,w) (MWORD(w,i) &= ~MBIT(i)) 133: #define BIT(i,w) (MWORD(w,i) & MBIT(i)) 134: 135: #define dprintf if (dflag) fprintf 136: #define vprintf if (vflag) fprintf 137: 138: #define GOOD 1 139: #define FAIL 0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.