1196200Sscottl/*- 2196200Sscottl * Copyright (c) 1983, 1993 3196200Sscottl * The Regents of the University of California. All rights reserved. 4196200Sscottl * (c) UNIX System Laboratories, Inc. 5196200Sscottl * All or some portions of this file are derived from material licensed 6196200Sscottl * to the University of California by American Telephone and Telegraph 7196200Sscottl * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8196200Sscottl * the permission of UNIX System Laboratories, Inc. 9196200Sscottl * 10196200Sscottl * Redistribution and use in source and binary forms, with or without 11196200Sscottl * modification, are permitted provided that the following conditions 12196200Sscottl * are met: 13196200Sscottl * 1. Redistributions of source code must retain the above copyright 14196200Sscottl * notice, this list of conditions and the following disclaimer. 15196200Sscottl * 2. Redistributions in binary form must reproduce the above copyright 16196200Sscottl * notice, this list of conditions and the following disclaimer in the 17196200Sscottl * documentation and/or other materials provided with the distribution. 18196200Sscottl * 4. Neither the name of the University nor the names of its contributors 19196200Sscottl * may be used to endorse or promote products derived from this software 20196200Sscottl * without specific prior written permission. 21196200Sscottl * 22196200Sscottl * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23196200Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24196200Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25196200Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26196200Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27196200Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28196200Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29196200Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30196200Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31196200Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32196200Sscottl * SUCH DAMAGE. 33196200Sscottl * 34196200Sscottl * @(#)restore.h 8.3 (Berkeley) 9/13/94 35237589Seadler * $FreeBSD$ 36196200Sscottl */ 37196200Sscottl 38196200Sscottl/* 39196200Sscottl * Flags 40196200Sscottl */ 41196200Sscottlextern int bflag; /* set input block size */ 42196200Sscottlextern int dflag; /* print out debugging info */ 43196200Sscottlextern int Dflag; /* degraded mode - try hard to get stuff back */ 44196200Sscottlextern int hflag; /* restore hierarchies */ 45196200Sscottlextern int mflag; /* restore by name instead of inode number */ 46196200Sscottlextern int Nflag; /* do not write the disk */ 47196200Sscottlextern int uflag; /* unlink symlink targets */ 48196200Sscottlextern int vflag; /* print out actions taken */ 49196200Sscottlextern int yflag; /* always try to recover from tape errors */ 50196200Sscottl/* 51196200Sscottl * Global variables 52196200Sscottl */ 53196200Sscottlextern char *dumpmap; /* map of inodes on this dump tape */ 54196200Sscottlextern char *usedinomap; /* map of inodes that are in use on this fs */ 55196200Sscottlextern ino_t maxino; /* highest numbered inode in this file system */ 56196200Sscottlextern long dumpnum; /* location of the dump on this tape */ 57196200Sscottlextern long volno; /* current volume being read */ 58196200Sscottlextern long ntrec; /* number of TP_BSIZE records per tape block */ 59196200Sscottlextern time_t dumptime; /* time that this dump begins */ 60196200Sscottlextern time_t dumpdate; /* time that this dump was made */ 61196200Sscottlextern char command; /* opration being performed */ 62196200Sscottlextern FILE *terminal; /* file descriptor for the terminal input */ 63196200Sscottlextern int Bcvt; /* need byte swapping on inodes and dirs */ 64196200Sscottlextern int oldinofmt; /* reading tape with FreeBSD 1 format inodes */ 65196200Sscottl 66214396Sjhb/* 67196200Sscottl * Each file in the file system is described by one of these entries 68196200Sscottl */ 69196200Sscottlstruct entry { 70214396Sjhb char *e_name; /* the current name of this entry */ 71196200Sscottl u_char e_namlen; /* length of this name */ 72214396Sjhb char e_type; /* type of this entry, see below */ 73196200Sscottl short e_flags; /* status flags, see below */ 74196200Sscottl ino_t e_ino; /* inode number in previous file sys */ 75196200Sscottl long e_index; /* unique index (for dumpped table) */ 76196200Sscottl struct entry *e_parent; /* pointer to parent directory (..) */ 77196200Sscottl struct entry *e_sibling; /* next element in this directory (.) */ 78237589Seadler struct entry *e_links; /* hard links to this inode */ 79196200Sscottl struct entry *e_entries; /* for directories, their entries */ 80196200Sscottl struct entry *e_next; /* hash chain list */ 81196200Sscottl}; 82196200Sscottl/* types */ 83196200Sscottl#define LEAF 1 /* non-directory entry */ 84223345Sbz#define NODE 2 /* directory entry */ 85196200Sscottl#define LINK 4 /* synthesized type, stripped by addentry */ 86196200Sscottl/* flags */ 87214396Sjhb#define EXTRACT 0x0001 /* entry is to be replaced from the tape */ 88196200Sscottl#define NEW 0x0002 /* a new entry to be extracted */ 89196200Sscottl#define KEEP 0x0004 /* entry is not to change */ 90237589Seadler#define REMOVED 0x0010 /* entry has been removed */ 91196200Sscottl#define TMPNAME 0x0020 /* entry has been given a temporary name */ 92214396Sjhb#define EXISTED 0x0040 /* directory already existed during extract */ 93196200Sscottl 94214396Sjhb/* 95196200Sscottl * Constants associated with entry structs 96196200Sscottl */ 97196200Sscottl#define HARDLINK 1 98196200Sscottl#define SYMLINK 2 99214396Sjhb#define TMPHDR "RSTTMP" 100222899Sbz 101222899Sbz/* 102214396Sjhb * The entry describes the next file available on the tape 103222899Sbz */ 104196200Sscottlstruct context { 105196200Sscottl short action; /* action being taken on this file */ 106196200Sscottl mode_t mode; /* mode of file */ 107196200Sscottl ino_t ino; /* inumber of file */ 108196200Sscottl uid_t uid; /* file owner */ 109196200Sscottl gid_t gid; /* file group */ 110196200Sscottl int file_flags; /* status flags (chflags) */ 111196200Sscottl int rdev; /* device number of file */ 112196200Sscottl time_t atime_sec; /* access time seconds */ 113196200Sscottl time_t mtime_sec; /* modified time seconds */ 114196200Sscottl time_t birthtime_sec; /* creation time seconds */ 115196200Sscottl int atime_nsec; /* access time nanoseconds */ 116196200Sscottl int mtime_nsec; /* modified time nanoseconds */ 117196200Sscottl int birthtime_nsec; /* creation time nanoseconds */ 118196200Sscottl int extsize; /* size of extended attribute data */ 119196200Sscottl off_t size; /* size of file */ 120196200Sscottl char *name; /* name of file */ 121196200Sscottl} curfile; 122196200Sscottl/* actions */ 123196200Sscottl#define USING 1 /* extracting from the tape */ 124196200Sscottl#define SKIP 2 /* skipping */ 125196200Sscottl#define UNKNOWN 3 /* disposition or starting point is unknown */ 126196200Sscottl 127196200Sscottl/* 128196200Sscottl * Definitions for library routines operating on directories. 129196200Sscottl */ 130196200Sscottltypedef struct rstdirdesc RST_DIR; 131196200Sscottl 132214396Sjhb/* 133196200Sscottl * Flags to setdirmodes. 134222899Sbz */ 135214396Sjhb#define FORCE 0x0001 136196200Sscottl 137196200Sscottl/* 138196200Sscottl * Useful macros 139196200Sscottl */ 140196200Sscottl#define TSTINO(ino, map) \ 141196200Sscottl (map[(u_int)((ino) - 1) / CHAR_BIT] & \ 142196200Sscottl (1 << ((u_int)((ino) - 1) % CHAR_BIT))) 143196200Sscottl#define SETINO(ino, map) \ 144196200Sscottl map[(u_int)((ino) - 1) / CHAR_BIT] |= \ 145196200Sscottl 1 << ((u_int)((ino) - 1) % CHAR_BIT) 146196200Sscottl 147196200Sscottl#define dprintf if (dflag) fprintf 148196200Sscottl#define vprintf if (vflag) fprintf 149196200Sscottl 150196200Sscottl#define GOOD 1 151196200Sscottl#define FAIL 0 152196200Sscottl 153196200Sscottl#define NFS_DR_NEWINODEFMT 0x2 /* Tape uses 4.4 BSD inode format */ 154196200Sscottl