date and time created 87/02/05 15:19:02 by slatteng
[unix-history] / usr / src / sbin / restore / restore.h
CommitLineData
8c5eec2f
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
6 * @(#)restore.h 5.1 (Berkeley) %G%
7 */
e0519353
KM
8
9#include <stdio.h>
10#include <sys/param.h>
11#include <sys/inode.h>
12#include <sys/fs.h>
f97d7036 13#include <sys/dir.h>
e0519353
KM
14
15/*
16 * Flags
17 */
18extern int cvtflag; /* convert from old to new tape format */
b97e998a 19extern int bflag; /* set input block size */
e0519353
KM
20extern int dflag; /* print out debugging info */
21extern int hflag; /* restore heirarchies */
22extern int mflag; /* restore by name instead of inode number */
23extern int vflag; /* print out actions taken */
24extern int yflag; /* always try to recover from tape errors */
25/*
26 * Global variables
27 */
28extern char *dumpmap; /* map of inodes on this dump tape */
29extern char *clrimap; /* map of inodes to be deleted */
30extern ino_t maxino; /* highest numbered inode in this file system */
31extern long dumpnum; /* location of the dump on this tape */
32extern long volno; /* current volume being read */
19230a53 33extern long ntrec; /* number of TP_BSIZE records per tape block */
2cb5dabb
KM
34extern time_t dumptime; /* time that this dump begins */
35extern time_t dumpdate; /* time that this dump was made */
e0519353 36extern char command; /* opration being performed */
7432ff81 37extern FILE *terminal; /* file descriptor for the terminal input */
e0519353
KM
38
39/*
40 * Each file in the file system is described by one of these entries
41 */
42struct entry {
43 char *e_name; /* the current name of this entry */
44 u_char e_namlen; /* length of this name */
45 char e_type; /* type of this entry, see below */
46 short e_flags; /* status flags, see below */
47 ino_t e_ino; /* inode number in previous file sys */
16e2b8d5 48 long e_index; /* unique index (for dumpped table) */
e0519353
KM
49 struct entry *e_parent; /* pointer to parent directory (..) */
50 struct entry *e_sibling; /* next element in this directory (.) */
51 struct entry *e_links; /* hard links to this inode */
52 struct entry *e_entries; /* for directories, their entries */
16e2b8d5 53 struct entry *e_next; /* hash chain list */
e0519353
KM
54};
55/* types */
56#define LEAF 1 /* non-directory entry */
57#define NODE 2 /* directory entry */
58#define LINK 4 /* synthesized type, stripped by addentry */
59/* flags */
16e2b8d5
KM
60#define EXTRACT 0x0001 /* entry is to be replaced from the tape */
61#define NEW 0x0002 /* a new entry to be extracted */
62#define KEEP 0x0004 /* entry is not to change */
63#define REMOVED 0x0010 /* entry has been removed */
64#define TMPNAME 0x0020 /* entry has been given a temporary name */
a7d37956 65#define EXISTED 0x0040 /* directory already existed during extract */
e0519353
KM
66/*
67 * functions defined on entry structs
68 */
69extern struct entry *lookupino();
70extern struct entry *lookupname();
71extern struct entry *lookupparent();
72extern struct entry *addentry();
73extern char *myname();
74extern char *savename();
16e2b8d5 75extern char *gentempname();
55f85ba7 76extern char *flagvalues();
e0519353
KM
77extern ino_t lowerbnd();
78extern ino_t upperbnd();
f97d7036
KM
79extern DIR *rst_opendir();
80extern struct direct *rst_readdir();
e0519353
KM
81#define NIL ((struct entry *)(0))
82/*
83 * Constants associated with entry structs
84 */
16e2b8d5
KM
85#define HARDLINK 1
86#define SYMLINK 2
87#define TMPHDR "RSTTMP"
e0519353
KM
88
89/*
90 * The entry describes the next file available on the tape
91 */
92struct context {
93 char *name; /* name of file */
94 ino_t ino; /* inumber of file */
95 struct dinode *dip; /* pointer to inode */
96 char action; /* action being taken on this file */
97} curfile;
98/* actions */
99#define USING 1 /* extracting from the tape */
100#define SKIP 2 /* skipping */
101#define UNKNOWN 3 /* disposition or starting point is unknown */
102
103/*
104 * Other exported routines
105 */
106extern ino_t psearch();
7432ff81 107extern ino_t dirlookup();
314ac756 108extern long listfile();
7432ff81 109extern long deletefile();
314ac756
KM
110extern long addfile();
111extern long nodeupdates();
112extern long verifyfile();
e0519353
KM
113extern char *rindex();
114extern char *index();
16e2b8d5 115extern char *strcat();
7432ff81 116extern char *strncat();
16e2b8d5 117extern char *strcpy();
7432ff81
KM
118extern char *strncpy();
119extern char *fgets();
16e2b8d5
KM
120extern char *mktemp();
121extern char *malloc();
122extern char *calloc();
7432ff81 123extern char *realloc();
16e2b8d5 124extern long lseek();
e0519353
KM
125
126/*
127 * Useful macros
128 */
129#define MWORD(m,i) (m[(unsigned)(i-1)/NBBY])
130#define MBIT(i) (1<<((unsigned)(i-1)%NBBY))
131#define BIS(i,w) (MWORD(w,i) |= MBIT(i))
132#define BIC(i,w) (MWORD(w,i) &= ~MBIT(i))
133#define BIT(i,w) (MWORD(w,i) & MBIT(i))
134
135#define dprintf if (dflag) fprintf
136#define vprintf if (vflag) fprintf
137
2cb5dabb
KM
138#define GOOD 1
139#define FAIL 0