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