1 /* $OpenBSD: restore.h,v 1.10 2021/01/21 00:16:36 mortimer Exp $ */ 2 /* $NetBSD: restore.h,v 1.8 1997/07/01 05:37:54 lukem Exp $ */ 3 4 /* 5 * Copyright (c) 1983, 1993 6 * The Regents of the University of California. All rights reserved. 7 * (c) UNIX System Laboratories, Inc. 8 * All or some portions of this file are derived from material licensed 9 * to the University of California by American Telephone and Telegraph 10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 11 * the permission of UNIX System Laboratories, Inc. 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)restore.h 8.3 (Berkeley) 9/13/94 38 */ 39 40 /* 41 * Flags 42 */ 43 extern int cvtflag; /* convert from old to new tape format */ 44 extern int bflag; /* set input block size */ 45 extern int dflag; /* print out debugging info */ 46 extern int hflag; /* restore heirarchies */ 47 extern int mflag; /* restore by name instead of inode number */ 48 extern int Nflag; /* do not write the disk */ 49 extern int vflag; /* print out actions taken */ 50 extern int yflag; /* always try to recover from tape errors */ 51 /* 52 * Global variables 53 */ 54 extern char *dumpmap; /* map of inodes on this dump tape */ 55 extern char *usedinomap; /* map of inodes that are in use on this fs */ 56 extern ino_t maxino; /* highest numbered inode in this file system */ 57 extern long dumpnum; /* location of the dump on this tape */ 58 extern long volno; /* current volume being read */ 59 extern long ntrec; /* number of TP_BSIZE records per tape block */ 60 extern time_t dumptime; /* time that this dump begins */ 61 extern time_t dumpdate; /* time that this dump was made */ 62 extern char command; /* operation being performed */ 63 extern FILE *terminal; /* file descriptor for the terminal input */ 64 extern char *tmpdir; /* where to store temporary files */ 65 extern int oldinofmt; /* reading tape with old format inodes */ 66 extern int Bcvt; /* need byte swapping on inodes and dirs */ 67 extern char *__progname; /* from crt0.o */ 68 69 /* 70 * Each file in the file system is described by one of these entries 71 */ 72 struct entry { 73 char *e_name; /* the current name of this entry */ 74 u_char e_namlen; /* length of this name */ 75 char e_type; /* type of this entry, see below */ 76 short e_flags; /* status flags, see below */ 77 ino_t e_ino; /* inode number in previous file sys */ 78 long e_index; /* unique index (for dumped table) */ 79 struct entry *e_parent; /* pointer to parent directory (..) */ 80 struct entry *e_sibling; /* next element in this directory (.) */ 81 struct entry *e_links; /* hard links to this inode */ 82 struct entry *e_entries; /* for directories, their entries */ 83 struct entry *e_next; /* hash chain list */ 84 }; 85 /* types */ 86 #define LEAF 1 /* non-directory entry */ 87 #define NODE 2 /* directory entry */ 88 #define LINK 4 /* synthesized type, stripped by addentry */ 89 /* flags */ 90 #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ 91 #define NEW 0x0002 /* a new entry to be extracted */ 92 #define KEEP 0x0004 /* entry is not to change */ 93 #define REMOVED 0x0010 /* entry has been removed */ 94 #define TMPNAME 0x0020 /* entry has been given a temporary name */ 95 #define EXISTED 0x0040 /* directory already existed during extract */ 96 97 /* 98 * Constants associated with entry structs 99 */ 100 #define HARDLINK 1 101 #define SYMLINK 2 102 #define TMPHDR "RSTTMP" 103 104 /* 105 * The entry describes the next file available on the tape 106 */ 107 extern struct context { 108 short action; /* action being taken on this file */ 109 mode_t mode; /* mode of file */ 110 ino_t ino; /* inumber of file */ 111 uid_t uid; /* file owner */ 112 gid_t gid; /* file group */ 113 int file_flags; /* status flags (chflags) */ 114 int rdev; /* device number of file */ 115 time_t atime_sec; /* access time seconds */ 116 time_t mtime_sec; /* modified time seconds */ 117 time_t birthtime_sec; /* creation time seconds */ 118 int atime_nsec; /* access time nanoseconds */ 119 int mtime_nsec; /* modified time nanoseconds */ 120 int birthtime_nsec; /* creation time nanoseconds */ 121 off_t size; /* size of file */ 122 char *name; /* name of file */ 123 } curfile; 124 /* actions */ 125 #define USING 1 /* extracting from the tape */ 126 #define SKIP 2 /* skipping */ 127 #define UNKNOWN 3 /* disposition or starting point is unknown */ 128 129 /* 130 * Definitions for library routines operating on directories. 131 */ 132 typedef struct rstdirdesc RST_DIR; 133 134 /* 135 * Flags to setdirmodes. 136 */ 137 #define FORCE 0x0001 138 139 /* 140 * Useful macros 141 */ 142 #define TSTINO(ino, map) \ 143 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 144 #define SETINO(ino, map) \ 145 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) 146 147 #define Dprintf if (dflag) fprintf 148 #define Vprintf if (vflag) fprintf 149 150 #define GOOD 1 151 #define FAIL 0 152