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