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