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