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