xref: /onnv-gate/usr/src/cmd/backup/restore/restore.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (c) 1983 Regents of the University of California.
3*0Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
4*0Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
5*0Sstevel@tonic-gate  */
6*0Sstevel@tonic-gate 
7*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
8*0Sstevel@tonic-gate /*	  All Rights Reserved	*/
9*0Sstevel@tonic-gate 
10*0Sstevel@tonic-gate /*
11*0Sstevel@tonic-gate  * Copyright 1994, 1996, 1998-2003 Sun Microsystems, Inc.  All rights reserved.
12*0Sstevel@tonic-gate  * Use is subject to license terms.
13*0Sstevel@tonic-gate  */
14*0Sstevel@tonic-gate 
15*0Sstevel@tonic-gate #ifndef _RESTORE_H
16*0Sstevel@tonic-gate #define	_RESTORE_H
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
19*0Sstevel@tonic-gate 
20*0Sstevel@tonic-gate #include <stdio.h>
21*0Sstevel@tonic-gate #include <string.h>
22*0Sstevel@tonic-gate #include <malloc.h>
23*0Sstevel@tonic-gate #include <netdb.h>
24*0Sstevel@tonic-gate #include <fcntl.h>
25*0Sstevel@tonic-gate #include <unistd.h>
26*0Sstevel@tonic-gate #include <errno.h>
27*0Sstevel@tonic-gate #include <sys/stat.h>
28*0Sstevel@tonic-gate #include <sys/param.h>
29*0Sstevel@tonic-gate #include <sys/time.h>
30*0Sstevel@tonic-gate #include <sys/vnode.h>
31*0Sstevel@tonic-gate #include <locale.h>
32*0Sstevel@tonic-gate #include <stdlib.h>
33*0Sstevel@tonic-gate #include <sys/fs/ufs_inode.h>
34*0Sstevel@tonic-gate #include <sys/fs/ufs_fs.h>
35*0Sstevel@tonic-gate #include <sys/fs/ufs_fsdir.h>
36*0Sstevel@tonic-gate #include <note.h>
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #ifdef	__cplusplus
39*0Sstevel@tonic-gate extern "C" {
40*0Sstevel@tonic-gate #endif
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate #define	ROOTINO	UFSROOTINO
43*0Sstevel@tonic-gate #define	SUPPORTS_MTB_TAPE_FORMAT
44*0Sstevel@tonic-gate #include <protocols/dumprestore.h>
45*0Sstevel@tonic-gate #include <memutils.h>
46*0Sstevel@tonic-gate #include <assert.h>
47*0Sstevel@tonic-gate 
48*0Sstevel@tonic-gate /*
49*0Sstevel@tonic-gate  * Flags
50*0Sstevel@tonic-gate  */
51*0Sstevel@tonic-gate extern int	cvtflag;	/* convert from old to new tape format */
52*0Sstevel@tonic-gate extern int	bflag;		/* set input block size */
53*0Sstevel@tonic-gate extern int	dflag;		/* print out debugging info */
54*0Sstevel@tonic-gate extern int	hflag;		/* restore heirarchies */
55*0Sstevel@tonic-gate extern int	mflag;		/* restore by name instead of inode number */
56*0Sstevel@tonic-gate extern int	vflag;		/* print out actions taken */
57*0Sstevel@tonic-gate extern int	yflag;		/* always try to recover from tape errors */
58*0Sstevel@tonic-gate extern int	paginating;	/* paginate bulk interactive output */
59*0Sstevel@tonic-gate extern int	offline;	/* take tape offline when closing */
60*0Sstevel@tonic-gate extern int	autoload;	/* wait for tape to autoload; implies offline */
61*0Sstevel@tonic-gate /*
62*0Sstevel@tonic-gate  * Global variables
63*0Sstevel@tonic-gate  */
64*0Sstevel@tonic-gate extern int	autoload_tries;	/* number of times to check on autoload */
65*0Sstevel@tonic-gate extern int	autoload_period; /* seconds, tries*period = total wait time */
66*0Sstevel@tonic-gate extern struct byteorder_ctx *byteorder;
67*0Sstevel@tonic-gate extern char	*progname;	/* our name */
68*0Sstevel@tonic-gate extern char	*dumpmap; 	/* map of inodes on this dump tape */
69*0Sstevel@tonic-gate extern char	*clrimap; 	/* map of inodes to be deleted */
70*0Sstevel@tonic-gate extern char	*c_label;	/* label we expect to see on the tape */
71*0Sstevel@tonic-gate extern ino_t	maxino;		/* highest numbered inode in this file system */
72*0Sstevel@tonic-gate extern long	dumpnum;	/* location of the dump on this tape */
73*0Sstevel@tonic-gate extern int	volno;		/* current volume being read */
74*0Sstevel@tonic-gate extern uint_t	ntrec;		/* number of tp_bsize records per tape block */
75*0Sstevel@tonic-gate extern uint_t	saved_ntrec;	/* number of tp_bsize records per tape block */
76*0Sstevel@tonic-gate extern ssize_t	tape_rec_size;	/* tape record size (tp_bsize * ntrec) */
77*0Sstevel@tonic-gate extern time_t	dumptime;	/* time that this dump begins */
78*0Sstevel@tonic-gate extern time_t	dumpdate;	/* time that this dump was made */
79*0Sstevel@tonic-gate extern char	command;	/* opration being performed */
80*0Sstevel@tonic-gate extern FILE	*terminal;	/* file descriptor for the terminal input */
81*0Sstevel@tonic-gate extern char	*tmpdir;	/* where to put the rst{dir,mode}... files */
82*0Sstevel@tonic-gate extern char	*pager_catenated; /* pager command and args */
83*0Sstevel@tonic-gate extern char	**pager_vector;	/* pager_catenated split up for execve() */
84*0Sstevel@tonic-gate extern int	pager_len;	/* # elements in pager_vector; includes NULL */
85*0Sstevel@tonic-gate extern int	inattrspace;	/* true if currently scanning attribute space */
86*0Sstevel@tonic-gate extern int	savepwd;	/* this is where restore is running from */
87*0Sstevel@tonic-gate 
88*0Sstevel@tonic-gate /*
89*0Sstevel@tonic-gate  * Each file in the file system is described by one of these entries
90*0Sstevel@tonic-gate  * Note that the e_next field is used by the symbol table hash lists
91*0Sstevel@tonic-gate  * and then reused by the remove code after the entry is removed from
92*0Sstevel@tonic-gate  * the symbol table.
93*0Sstevel@tonic-gate  */
94*0Sstevel@tonic-gate struct entry {
95*0Sstevel@tonic-gate 	char	*e_name;		/* the current name of this entry */
96*0Sstevel@tonic-gate 	ushort_t e_namlen;		/* length of this name */
97*0Sstevel@tonic-gate 	char	e_type;			/* type of this entry, see below */
98*0Sstevel@tonic-gate 	short	e_flags;		/* status flags, see below */
99*0Sstevel@tonic-gate 	ino_t	e_ino;			/* inode number in previous file sys */
100*0Sstevel@tonic-gate 	long	e_index;		/* unique index (for dumpped table) */
101*0Sstevel@tonic-gate 	struct	entry *e_parent;	/* pointer to parent directory (..) */
102*0Sstevel@tonic-gate 	struct	entry *e_sibling;	/* next element in this directory (.) */
103*0Sstevel@tonic-gate 	struct	entry *e_links;		/* hard links to this inode */
104*0Sstevel@tonic-gate 	struct	entry *e_entries;	/* for directories, their entries */
105*0Sstevel@tonic-gate 	struct	entry *e_xattrs;	/* pointer to extended attribute root */
106*0Sstevel@tonic-gate 	struct	entry *e_next;		/* hash chain list and removelist */
107*0Sstevel@tonic-gate };
108*0Sstevel@tonic-gate /* types */
109*0Sstevel@tonic-gate #define	LEAF 1			/* non-directory entry */
110*0Sstevel@tonic-gate #define	NODE 2			/* directory entry */
111*0Sstevel@tonic-gate #define	LINK 4			/* synthesized type, stripped by addentry */
112*0Sstevel@tonic-gate #define	ROOT 8			/* synthesized type, stripped by addentry */
113*0Sstevel@tonic-gate /* flags */
114*0Sstevel@tonic-gate #define	EXTRACT		0x0001	/* entry is to be replaced from the tape */
115*0Sstevel@tonic-gate #define	NEW		0x0002	/* a new entry to be extracted */
116*0Sstevel@tonic-gate #define	KEEP		0x0004	/* entry is not to change */
117*0Sstevel@tonic-gate #define	REMOVED		0x0010	/* entry has been removed */
118*0Sstevel@tonic-gate #define	TMPNAME		0x0020	/* entry has been given a temporary name */
119*0Sstevel@tonic-gate #define	EXISTED		0x0040	/* directory already existed during extract */
120*0Sstevel@tonic-gate #define	XATTR		0x0080	/* file belongs in an attribute tree */
121*0Sstevel@tonic-gate #define	XATTRROOT	0x0100	/* directory is root of an attribute tree */
122*0Sstevel@tonic-gate /*
123*0Sstevel@tonic-gate  * functions defined on entry structs
124*0Sstevel@tonic-gate  */
125*0Sstevel@tonic-gate #ifdef __STDC__
126*0Sstevel@tonic-gate extern struct entry *lookupino(ino_t);
127*0Sstevel@tonic-gate extern struct entry *lookupname(char *);
128*0Sstevel@tonic-gate extern struct entry *addentry(char *, ino_t, int);
129*0Sstevel@tonic-gate extern void deleteino(ino_t);
130*0Sstevel@tonic-gate extern char *myname(struct entry *);
131*0Sstevel@tonic-gate extern void freeentry(struct entry *);
132*0Sstevel@tonic-gate extern void moveentry(struct entry *, char *);
133*0Sstevel@tonic-gate extern char *savename(char *);
134*0Sstevel@tonic-gate extern void freename(char *);
135*0Sstevel@tonic-gate extern void dumpsymtable(char *, int);
136*0Sstevel@tonic-gate extern void initsymtable(char *);
137*0Sstevel@tonic-gate extern void mktempname(struct entry *);
138*0Sstevel@tonic-gate extern char *gentempname(struct entry *);
139*0Sstevel@tonic-gate extern void newnode(struct entry *);
140*0Sstevel@tonic-gate extern void removenode(struct entry *);
141*0Sstevel@tonic-gate extern void removeleaf(struct entry *);
142*0Sstevel@tonic-gate extern ino_t lowerbnd(ino_t);
143*0Sstevel@tonic-gate extern ino_t upperbnd(ino_t);
144*0Sstevel@tonic-gate extern void badentry(struct entry *, char *);
145*0Sstevel@tonic-gate extern char *flagvalues(struct entry *);
146*0Sstevel@tonic-gate extern ino_t dirlookup(char *);
147*0Sstevel@tonic-gate #else
148*0Sstevel@tonic-gate extern struct entry *lookupino();
149*0Sstevel@tonic-gate extern struct entry *lookupname();
150*0Sstevel@tonic-gate extern struct entry *addentry();
151*0Sstevel@tonic-gate extern void deleteino();
152*0Sstevel@tonic-gate extern char *myname();
153*0Sstevel@tonic-gate extern void freeentry();
154*0Sstevel@tonic-gate extern void moveentry();
155*0Sstevel@tonic-gate extern char *savename();
156*0Sstevel@tonic-gate extern void freename();
157*0Sstevel@tonic-gate extern void dumpsymtable();
158*0Sstevel@tonic-gate extern void initsymtable();
159*0Sstevel@tonic-gate extern void mktempname();
160*0Sstevel@tonic-gate extern char *gentempname();
161*0Sstevel@tonic-gate extern void newnode();
162*0Sstevel@tonic-gate extern void removenode();
163*0Sstevel@tonic-gate extern void removeleaf();
164*0Sstevel@tonic-gate extern ino_t lowerbnd();
165*0Sstevel@tonic-gate extern ino_t upperbnd();
166*0Sstevel@tonic-gate extern void badentry();
167*0Sstevel@tonic-gate extern char *flagvalues();
168*0Sstevel@tonic-gate extern ino_t dirlookup();
169*0Sstevel@tonic-gate #endif
170*0Sstevel@tonic-gate #define	NIL ((struct entry *)(0))
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate /*
173*0Sstevel@tonic-gate  * Definitions for library routines operating on directories.
174*0Sstevel@tonic-gate  * These definitions are used only for reading fake directory
175*0Sstevel@tonic-gate  * entries from restore's temporary file "restoresymtable"
176*0Sstevel@tonic-gate  * These have little to do with real directory entries.
177*0Sstevel@tonic-gate  */
178*0Sstevel@tonic-gate #if !defined(DEV_BSIZE)
179*0Sstevel@tonic-gate #define	DEV_BSIZE	512
180*0Sstevel@tonic-gate #endif
181*0Sstevel@tonic-gate #define	DIRBLKSIZ	DEV_BSIZE
182*0Sstevel@tonic-gate typedef struct _rstdirdesc {
183*0Sstevel@tonic-gate 	int	dd_fd;
184*0Sstevel@tonic-gate 	int	dd_refcnt;  /* so rst_{open,close}dir() avoid leaking memory */
185*0Sstevel@tonic-gate 	off64_t	dd_loc;
186*0Sstevel@tonic-gate 	off64_t	dd_size;
187*0Sstevel@tonic-gate 	char	dd_buf[DIRBLKSIZ];
188*0Sstevel@tonic-gate } RST_DIR;
189*0Sstevel@tonic-gate 
190*0Sstevel@tonic-gate /*
191*0Sstevel@tonic-gate  * Constants associated with entry structs
192*0Sstevel@tonic-gate  */
193*0Sstevel@tonic-gate #define	HARDLINK	1
194*0Sstevel@tonic-gate #define	SYMLINK		2
195*0Sstevel@tonic-gate #define	TMPHDR		"RSTTMP"
196*0Sstevel@tonic-gate 
197*0Sstevel@tonic-gate /*
198*0Sstevel@tonic-gate  * The entry describes the next file available on the tape
199*0Sstevel@tonic-gate  */
200*0Sstevel@tonic-gate struct context {
201*0Sstevel@tonic-gate 	char	*name;		/* name of file */
202*0Sstevel@tonic-gate 	ino_t	ino;		/* inumber of file */
203*0Sstevel@tonic-gate 	struct	dinode *dip;	/* pointer to inode */
204*0Sstevel@tonic-gate 	int	action;		/* action being taken on this file */
205*0Sstevel@tonic-gate 	int	ts;		/* TS_* type of tape record */
206*0Sstevel@tonic-gate } curfile;
207*0Sstevel@tonic-gate /* actions */
208*0Sstevel@tonic-gate #define	USING	1	/* extracting from the tape */
209*0Sstevel@tonic-gate #define	SKIP	2	/* skipping */
210*0Sstevel@tonic-gate #define	UNKNOWN 3	/* disposition or starting point is unknown */
211*0Sstevel@tonic-gate 
212*0Sstevel@tonic-gate /*
213*0Sstevel@tonic-gate  * Structure and routines associated with listing directories
214*0Sstevel@tonic-gate  * and expanding meta-characters in pathnames.
215*0Sstevel@tonic-gate  */
216*0Sstevel@tonic-gate struct afile {
217*0Sstevel@tonic-gate 	ino_t	fnum;		/* inode number of file */
218*0Sstevel@tonic-gate 	char	*fname;		/* file name */
219*0Sstevel@tonic-gate 	short	fflags;		/* extraction flags, if any */
220*0Sstevel@tonic-gate 	char	ftype;		/* file type, e.g. LEAF or NODE */
221*0Sstevel@tonic-gate };
222*0Sstevel@tonic-gate struct arglist {
223*0Sstevel@tonic-gate 	struct afile	*head;	/* start of argument list */
224*0Sstevel@tonic-gate 	struct afile	*last;	/* end of argument list */
225*0Sstevel@tonic-gate 	struct afile	*base;	/* current list arena */
226*0Sstevel@tonic-gate 	int		nent;	/* maximum size of list */
227*0Sstevel@tonic-gate 	char		*cmd;	/* the current command */
228*0Sstevel@tonic-gate };
229*0Sstevel@tonic-gate 
230*0Sstevel@tonic-gate /*
231*0Sstevel@tonic-gate  * Other exported routines
232*0Sstevel@tonic-gate  */
233*0Sstevel@tonic-gate #ifdef __STDC__
234*0Sstevel@tonic-gate extern int mkentry(char *, ino_t, struct arglist *);
235*0Sstevel@tonic-gate extern int expand(char *, int, struct arglist *);
236*0Sstevel@tonic-gate extern ino_t psearch(char *);
237*0Sstevel@tonic-gate extern void metaget(char **data, size_t *size);
238*0Sstevel@tonic-gate extern void metaproc(char *, char *, size_t);
239*0Sstevel@tonic-gate extern long listfile(char *, ino_t, int);
240*0Sstevel@tonic-gate extern long addfile(char *, ino_t, int);
241*0Sstevel@tonic-gate extern long deletefile(char *, ino_t, int);
242*0Sstevel@tonic-gate extern long nodeupdates(char *, ino_t, int);
243*0Sstevel@tonic-gate extern long verifyfile(char *, ino_t, int);
244*0Sstevel@tonic-gate extern void extractdirs(int genmode);
245*0Sstevel@tonic-gate extern void skipdirs(void);
246*0Sstevel@tonic-gate extern void treescan(char *, ino_t, long (*)(char *, ino_t, int));
247*0Sstevel@tonic-gate extern RST_DIR *rst_opendir(char *);
248*0Sstevel@tonic-gate extern void rst_closedir(RST_DIR *);
249*0Sstevel@tonic-gate extern struct direct *rst_readdir(RST_DIR *);
250*0Sstevel@tonic-gate extern void setdirmodes(void);
251*0Sstevel@tonic-gate extern int genliteraldir(char *, ino_t);
252*0Sstevel@tonic-gate extern int inodetype(ino_t);
253*0Sstevel@tonic-gate extern void done(int);
254*0Sstevel@tonic-gate extern void runcmdshell(void);
255*0Sstevel@tonic-gate extern void canon(char *, char *, size_t);
256*0Sstevel@tonic-gate extern void onintr(int);
257*0Sstevel@tonic-gate extern void removeoldleaves(void);
258*0Sstevel@tonic-gate extern void findunreflinks(void);
259*0Sstevel@tonic-gate extern void removeoldnodes(void);
260*0Sstevel@tonic-gate extern void createleaves(char *);
261*0Sstevel@tonic-gate extern void createfiles(void);
262*0Sstevel@tonic-gate extern void createlinks(void);
263*0Sstevel@tonic-gate extern void checkrestore(void);
264*0Sstevel@tonic-gate extern void setinput(char *, char *);
265*0Sstevel@tonic-gate extern void newtapebuf(size_t);
266*0Sstevel@tonic-gate extern void setup(void);
267*0Sstevel@tonic-gate extern void setupR(void);
268*0Sstevel@tonic-gate extern void getvol(int);
269*0Sstevel@tonic-gate extern void printdumpinfo(void);
270*0Sstevel@tonic-gate extern int extractfile(char *);
271*0Sstevel@tonic-gate extern void skipmaps(void);
272*0Sstevel@tonic-gate extern void skipfile(void);
273*0Sstevel@tonic-gate extern void getfile(void (*)(char *, size_t), void (*)(char *, size_t));
274*0Sstevel@tonic-gate extern void null(char *, size_t);
275*0Sstevel@tonic-gate extern void findtapeblksize(int);
276*0Sstevel@tonic-gate extern void flsht(void);
277*0Sstevel@tonic-gate extern void closemt(void);
278*0Sstevel@tonic-gate extern int readhdr(struct s_spcl *);
279*0Sstevel@tonic-gate extern int gethead(struct s_spcl *);
280*0Sstevel@tonic-gate extern int volnumber(ino_t);
281*0Sstevel@tonic-gate extern void findinode(struct s_spcl *);
282*0Sstevel@tonic-gate extern void pathcheck(char *);
283*0Sstevel@tonic-gate extern void renameit(char *, char *);
284*0Sstevel@tonic-gate extern int linkit(char *, char *, int);
285*0Sstevel@tonic-gate extern int lf_linkit(char *, char *, int);
286*0Sstevel@tonic-gate extern int reply(char *);
287*0Sstevel@tonic-gate /*PRINTFLIKE1*/
288*0Sstevel@tonic-gate extern void panic(const char *, ...);
289*0Sstevel@tonic-gate extern char *lctime(time_t *);
290*0Sstevel@tonic-gate extern int safe_open(int, const char *file, int mode, int perms);
291*0Sstevel@tonic-gate extern FILE *safe_fopen(const char *filename, const char *smode, int perms);
292*0Sstevel@tonic-gate extern void reset_dump(void);
293*0Sstevel@tonic-gate extern void get_next_device(void);
294*0Sstevel@tonic-gate extern void initpagercmd(void);
295*0Sstevel@tonic-gate extern void resolve(char *, int *, char **);
296*0Sstevel@tonic-gate extern int complexcopy(char *, char *, int);
297*0Sstevel@tonic-gate #else	/* !STDC */
298*0Sstevel@tonic-gate extern int mkentry();
299*0Sstevel@tonic-gate extern int expand();
300*0Sstevel@tonic-gate extern ino_t psearch();
301*0Sstevel@tonic-gate extern void metaget();
302*0Sstevel@tonic-gate extern void metaproc();
303*0Sstevel@tonic-gate extern long listfile();
304*0Sstevel@tonic-gate extern long addfile();
305*0Sstevel@tonic-gate extern long deletefile();
306*0Sstevel@tonic-gate extern long nodeupdates();
307*0Sstevel@tonic-gate extern long verifyfile();
308*0Sstevel@tonic-gate extern void extractdirs();
309*0Sstevel@tonic-gate extern void skipdirs();
310*0Sstevel@tonic-gate extern void treescan();
311*0Sstevel@tonic-gate extern RST_DIR *rst_opendir();
312*0Sstevel@tonic-gate extern void rst_closedir();
313*0Sstevel@tonic-gate extern struct direct *rst_readdir();
314*0Sstevel@tonic-gate extern void setdirmodes();
315*0Sstevel@tonic-gate extern int genliteraldir();
316*0Sstevel@tonic-gate extern int inodetype();
317*0Sstevel@tonic-gate extern void done();
318*0Sstevel@tonic-gate extern void runcmdshell();
319*0Sstevel@tonic-gate extern void canon();
320*0Sstevel@tonic-gate extern void onintr();
321*0Sstevel@tonic-gate extern void removeoldleaves();
322*0Sstevel@tonic-gate extern void findunreflinks();
323*0Sstevel@tonic-gate extern void removeoldnodes();
324*0Sstevel@tonic-gate extern void createleaves();
325*0Sstevel@tonic-gate extern void createfiles();
326*0Sstevel@tonic-gate extern void createlinks();
327*0Sstevel@tonic-gate extern void checkrestore();
328*0Sstevel@tonic-gate extern void setinput();
329*0Sstevel@tonic-gate extern void newtapebuf();
330*0Sstevel@tonic-gate extern void setup();
331*0Sstevel@tonic-gate extern void setupR();
332*0Sstevel@tonic-gate extern void getvol();
333*0Sstevel@tonic-gate extern void printdumpinfo();
334*0Sstevel@tonic-gate extern int extractfile();
335*0Sstevel@tonic-gate extern void skipmaps();
336*0Sstevel@tonic-gate extern void skipfile();
337*0Sstevel@tonic-gate extern void getfile();
338*0Sstevel@tonic-gate extern void null();
339*0Sstevel@tonic-gate extern void findtapeblksize();
340*0Sstevel@tonic-gate extern void flsht();
341*0Sstevel@tonic-gate extern void closemt();
342*0Sstevel@tonic-gate extern int readhdr();
343*0Sstevel@tonic-gate extern int gethead();
344*0Sstevel@tonic-gate extern int volnumber();
345*0Sstevel@tonic-gate extern void findinode();
346*0Sstevel@tonic-gate extern void pathcheck();
347*0Sstevel@tonic-gate extern void renameit();
348*0Sstevel@tonic-gate extern int linkit();
349*0Sstevel@tonic-gate extern int lf_linkit();
350*0Sstevel@tonic-gate extern int reply();
351*0Sstevel@tonic-gate extern void panic();
352*0Sstevel@tonic-gate extern char *lctime();
353*0Sstevel@tonic-gate extern int safe_open();
354*0Sstevel@tonic-gate extern FILE *safe_fopen();
355*0Sstevel@tonic-gate extern void reset_dump();
356*0Sstevel@tonic-gate extern void get_next_device();
357*0Sstevel@tonic-gate extern void initpagercmd();
358*0Sstevel@tonic-gate extern void resolve();
359*0Sstevel@tonic-gate extern int complexcopy();
360*0Sstevel@tonic-gate #endif	/* STDC */
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*
363*0Sstevel@tonic-gate  * Useful macros
364*0Sstevel@tonic-gate  */
365*0Sstevel@tonic-gate #define	MWORD(m, i)	((m)[(ino_t)((i)-1)/NBBY])
366*0Sstevel@tonic-gate #define	MBIT(i)		(1<<((ino_t)((i)-1)%NBBY))
367*0Sstevel@tonic-gate #define	BIS(i, w)	(MWORD((w), (i)) |=  MBIT(i))
368*0Sstevel@tonic-gate #define	BIC(i, w)	(MWORD((w), (i)) &= ~MBIT(i))
369*0Sstevel@tonic-gate #define	BIT(i, w)	(MWORD((w), (i)) & MBIT(i))
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate /*
372*0Sstevel@tonic-gate  * Macro used to get to the last segment of a complex string
373*0Sstevel@tonic-gate  */
374*0Sstevel@tonic-gate #define	LASTPART(s)	{int len = strlen(s)+1;\
375*0Sstevel@tonic-gate 				while (s[len] != '\0')\
376*0Sstevel@tonic-gate 					{s += len; len = strlen(s)+1; }\
377*0Sstevel@tonic-gate 			}
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate /*
380*0Sstevel@tonic-gate  * Define maximum length of complex string.  For now we use
381*0Sstevel@tonic-gate  * MAXPATHLEN * 2 since recursion is not (yet) supported.
382*0Sstevel@tonic-gate  * (add 3 for the 3 NULL characters in a two-part path)
383*0Sstevel@tonic-gate  * Note that each component of a complex string is still
384*0Sstevel@tonic-gate  * limited to MAXPATHLEN length.
385*0Sstevel@tonic-gate  */
386*0Sstevel@tonic-gate #define	MAXCOMPLEXLEN	(MAXPATHLEN*2 + 3)
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate /*
389*0Sstevel@tonic-gate  * Define an overflow-free version of howmany so that we don't
390*0Sstevel@tonic-gate  * run into trouble with large files.
391*0Sstevel@tonic-gate  */
392*0Sstevel@tonic-gate #define	d_howmany(x, y)	((x) / (y) + ((x) % (y) != 0))
393*0Sstevel@tonic-gate 
394*0Sstevel@tonic-gate /*
395*0Sstevel@tonic-gate  * Defines used by findtapeblksize()
396*0Sstevel@tonic-gate  */
397*0Sstevel@tonic-gate #define	TAPE_FILE	0
398*0Sstevel@tonic-gate #define	ARCHIVE_FILE	1
399*0Sstevel@tonic-gate 
400*0Sstevel@tonic-gate #define	setjmp(b)		sigsetjmp((b), 1)
401*0Sstevel@tonic-gate #define	longjmp			siglongjmp
402*0Sstevel@tonic-gate #define	jmp_buf			sigjmp_buf
403*0Sstevel@tonic-gate #define	chown			lchown
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate /*
406*0Sstevel@tonic-gate  * Defaults
407*0Sstevel@tonic-gate  */
408*0Sstevel@tonic-gate #define	TAPE	"/dev/rmt/0b"		/* default tape device */
409*0Sstevel@tonic-gate #define	RESTORESYMTABLE	"./restoresymtable"
410*0Sstevel@tonic-gate 
411*0Sstevel@tonic-gate #define	dprintf		if (dflag) (void) fprintf
412*0Sstevel@tonic-gate #define	vprintf		if (vflag) (void) fprintf
413*0Sstevel@tonic-gate 
414*0Sstevel@tonic-gate #define	GOOD 1
415*0Sstevel@tonic-gate #define	FAIL 0
416*0Sstevel@tonic-gate 
417*0Sstevel@tonic-gate #define	DEF_PAGER	"/usr/bin/more"
418*0Sstevel@tonic-gate 
419*0Sstevel@tonic-gate #ifdef	__cplusplus
420*0Sstevel@tonic-gate }
421*0Sstevel@tonic-gate #endif
422*0Sstevel@tonic-gate 
423*0Sstevel@tonic-gate #endif /* _RESTORE_H */
424