xref: /onnv-gate/usr/src/cmd/backup/restore/restore.h (revision 1053:667012633a0d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * Copyright (c) 1983 Regents of the University of California.
30Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
40Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
50Sstevel@tonic-gate  */
60Sstevel@tonic-gate 
70Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
80Sstevel@tonic-gate /*	  All Rights Reserved	*/
90Sstevel@tonic-gate 
100Sstevel@tonic-gate /*
11426Srm88369  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
120Sstevel@tonic-gate  * Use is subject to license terms.
130Sstevel@tonic-gate  */
140Sstevel@tonic-gate 
150Sstevel@tonic-gate #ifndef _RESTORE_H
160Sstevel@tonic-gate #define	_RESTORE_H
170Sstevel@tonic-gate 
180Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
190Sstevel@tonic-gate 
200Sstevel@tonic-gate #include <stdio.h>
210Sstevel@tonic-gate #include <string.h>
220Sstevel@tonic-gate #include <malloc.h>
230Sstevel@tonic-gate #include <netdb.h>
240Sstevel@tonic-gate #include <fcntl.h>
250Sstevel@tonic-gate #include <unistd.h>
260Sstevel@tonic-gate #include <errno.h>
270Sstevel@tonic-gate #include <sys/stat.h>
280Sstevel@tonic-gate #include <sys/param.h>
290Sstevel@tonic-gate #include <sys/time.h>
300Sstevel@tonic-gate #include <sys/vnode.h>
310Sstevel@tonic-gate #include <locale.h>
320Sstevel@tonic-gate #include <stdlib.h>
330Sstevel@tonic-gate #include <sys/fs/ufs_inode.h>
340Sstevel@tonic-gate #include <sys/fs/ufs_fs.h>
350Sstevel@tonic-gate #include <sys/fs/ufs_fsdir.h>
360Sstevel@tonic-gate #include <note.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #ifdef	__cplusplus
390Sstevel@tonic-gate extern "C" {
400Sstevel@tonic-gate #endif
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #define	ROOTINO	UFSROOTINO
430Sstevel@tonic-gate #define	SUPPORTS_MTB_TAPE_FORMAT
440Sstevel@tonic-gate #include <protocols/dumprestore.h>
450Sstevel@tonic-gate #include <memutils.h>
460Sstevel@tonic-gate #include <assert.h>
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * Flags
500Sstevel@tonic-gate  */
510Sstevel@tonic-gate extern int	cvtflag;	/* convert from old to new tape format */
520Sstevel@tonic-gate extern int	bflag;		/* set input block size */
530Sstevel@tonic-gate extern int	dflag;		/* print out debugging info */
540Sstevel@tonic-gate extern int	hflag;		/* restore heirarchies */
550Sstevel@tonic-gate extern int	mflag;		/* restore by name instead of inode number */
560Sstevel@tonic-gate extern int	vflag;		/* print out actions taken */
570Sstevel@tonic-gate extern int	yflag;		/* always try to recover from tape errors */
580Sstevel@tonic-gate extern int	paginating;	/* paginate bulk interactive output */
590Sstevel@tonic-gate extern int	offline;	/* take tape offline when closing */
600Sstevel@tonic-gate extern int	autoload;	/* wait for tape to autoload; implies offline */
610Sstevel@tonic-gate /*
620Sstevel@tonic-gate  * Global variables
630Sstevel@tonic-gate  */
640Sstevel@tonic-gate extern int	autoload_tries;	/* number of times to check on autoload */
650Sstevel@tonic-gate extern int	autoload_period; /* seconds, tries*period = total wait time */
660Sstevel@tonic-gate extern struct byteorder_ctx *byteorder;
670Sstevel@tonic-gate extern char	*progname;	/* our name */
680Sstevel@tonic-gate extern char	*dumpmap; 	/* map of inodes on this dump tape */
690Sstevel@tonic-gate extern char	*clrimap; 	/* map of inodes to be deleted */
700Sstevel@tonic-gate extern char	*c_label;	/* label we expect to see on the tape */
710Sstevel@tonic-gate extern ino_t	maxino;		/* highest numbered inode in this file system */
720Sstevel@tonic-gate extern long	dumpnum;	/* location of the dump on this tape */
730Sstevel@tonic-gate extern int	volno;		/* current volume being read */
740Sstevel@tonic-gate extern uint_t	ntrec;		/* number of tp_bsize records per tape block */
750Sstevel@tonic-gate extern uint_t	saved_ntrec;	/* number of tp_bsize records per tape block */
760Sstevel@tonic-gate extern ssize_t	tape_rec_size;	/* tape record size (tp_bsize * ntrec) */
770Sstevel@tonic-gate extern time_t	dumptime;	/* time that this dump begins */
780Sstevel@tonic-gate extern time_t	dumpdate;	/* time that this dump was made */
790Sstevel@tonic-gate extern char	command;	/* opration being performed */
800Sstevel@tonic-gate extern FILE	*terminal;	/* file descriptor for the terminal input */
810Sstevel@tonic-gate extern char	*tmpdir;	/* where to put the rst{dir,mode}... files */
820Sstevel@tonic-gate extern char	*pager_catenated; /* pager command and args */
830Sstevel@tonic-gate extern char	**pager_vector;	/* pager_catenated split up for execve() */
840Sstevel@tonic-gate extern int	pager_len;	/* # elements in pager_vector; includes NULL */
850Sstevel@tonic-gate extern int	inattrspace;	/* true if currently scanning attribute space */
860Sstevel@tonic-gate extern int	savepwd;	/* this is where restore is running from */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /*
890Sstevel@tonic-gate  * Each file in the file system is described by one of these entries
900Sstevel@tonic-gate  * Note that the e_next field is used by the symbol table hash lists
910Sstevel@tonic-gate  * and then reused by the remove code after the entry is removed from
920Sstevel@tonic-gate  * the symbol table.
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate struct entry {
950Sstevel@tonic-gate 	char	*e_name;		/* the current name of this entry */
960Sstevel@tonic-gate 	ushort_t e_namlen;		/* length of this name */
970Sstevel@tonic-gate 	char	e_type;			/* type of this entry, see below */
980Sstevel@tonic-gate 	short	e_flags;		/* status flags, see below */
990Sstevel@tonic-gate 	ino_t	e_ino;			/* inode number in previous file sys */
1000Sstevel@tonic-gate 	long	e_index;		/* unique index (for dumpped table) */
1010Sstevel@tonic-gate 	struct	entry *e_parent;	/* pointer to parent directory (..) */
1020Sstevel@tonic-gate 	struct	entry *e_sibling;	/* next element in this directory (.) */
1030Sstevel@tonic-gate 	struct	entry *e_links;		/* hard links to this inode */
1040Sstevel@tonic-gate 	struct	entry *e_entries;	/* for directories, their entries */
1050Sstevel@tonic-gate 	struct	entry *e_xattrs;	/* pointer to extended attribute root */
1060Sstevel@tonic-gate 	struct	entry *e_next;		/* hash chain list and removelist */
1070Sstevel@tonic-gate };
1080Sstevel@tonic-gate /* types */
1090Sstevel@tonic-gate #define	LEAF 1			/* non-directory entry */
1100Sstevel@tonic-gate #define	NODE 2			/* directory entry */
1110Sstevel@tonic-gate #define	LINK 4			/* synthesized type, stripped by addentry */
1120Sstevel@tonic-gate #define	ROOT 8			/* synthesized type, stripped by addentry */
1130Sstevel@tonic-gate /* flags */
1140Sstevel@tonic-gate #define	EXTRACT		0x0001	/* entry is to be replaced from the tape */
1150Sstevel@tonic-gate #define	NEW		0x0002	/* a new entry to be extracted */
1160Sstevel@tonic-gate #define	KEEP		0x0004	/* entry is not to change */
1170Sstevel@tonic-gate #define	REMOVED		0x0010	/* entry has been removed */
1180Sstevel@tonic-gate #define	TMPNAME		0x0020	/* entry has been given a temporary name */
1190Sstevel@tonic-gate #define	EXISTED		0x0040	/* directory already existed during extract */
1200Sstevel@tonic-gate #define	XATTR		0x0080	/* file belongs in an attribute tree */
1210Sstevel@tonic-gate #define	XATTRROOT	0x0100	/* directory is root of an attribute tree */
1220Sstevel@tonic-gate /*
1230Sstevel@tonic-gate  * functions defined on entry structs
1240Sstevel@tonic-gate  */
1250Sstevel@tonic-gate #ifdef __STDC__
1260Sstevel@tonic-gate extern struct entry *lookupino(ino_t);
1270Sstevel@tonic-gate extern struct entry *lookupname(char *);
1280Sstevel@tonic-gate extern struct entry *addentry(char *, ino_t, int);
1290Sstevel@tonic-gate extern void deleteino(ino_t);
1300Sstevel@tonic-gate extern char *myname(struct entry *);
1310Sstevel@tonic-gate extern void freeentry(struct entry *);
1320Sstevel@tonic-gate extern void moveentry(struct entry *, char *);
1330Sstevel@tonic-gate extern char *savename(char *);
1340Sstevel@tonic-gate extern void freename(char *);
1350Sstevel@tonic-gate extern void dumpsymtable(char *, int);
1360Sstevel@tonic-gate extern void initsymtable(char *);
1370Sstevel@tonic-gate extern void mktempname(struct entry *);
1380Sstevel@tonic-gate extern char *gentempname(struct entry *);
1390Sstevel@tonic-gate extern void newnode(struct entry *);
1400Sstevel@tonic-gate extern void removenode(struct entry *);
1410Sstevel@tonic-gate extern void removeleaf(struct entry *);
1420Sstevel@tonic-gate extern ino_t lowerbnd(ino_t);
1430Sstevel@tonic-gate extern ino_t upperbnd(ino_t);
1440Sstevel@tonic-gate extern void badentry(struct entry *, char *);
1450Sstevel@tonic-gate extern char *flagvalues(struct entry *);
1460Sstevel@tonic-gate extern ino_t dirlookup(char *);
1470Sstevel@tonic-gate #else
1480Sstevel@tonic-gate extern struct entry *lookupino();
1490Sstevel@tonic-gate extern struct entry *lookupname();
1500Sstevel@tonic-gate extern struct entry *addentry();
1510Sstevel@tonic-gate extern void deleteino();
1520Sstevel@tonic-gate extern char *myname();
1530Sstevel@tonic-gate extern void freeentry();
1540Sstevel@tonic-gate extern void moveentry();
1550Sstevel@tonic-gate extern char *savename();
1560Sstevel@tonic-gate extern void freename();
1570Sstevel@tonic-gate extern void dumpsymtable();
1580Sstevel@tonic-gate extern void initsymtable();
1590Sstevel@tonic-gate extern void mktempname();
1600Sstevel@tonic-gate extern char *gentempname();
1610Sstevel@tonic-gate extern void newnode();
1620Sstevel@tonic-gate extern void removenode();
1630Sstevel@tonic-gate extern void removeleaf();
1640Sstevel@tonic-gate extern ino_t lowerbnd();
1650Sstevel@tonic-gate extern ino_t upperbnd();
1660Sstevel@tonic-gate extern void badentry();
1670Sstevel@tonic-gate extern char *flagvalues();
1680Sstevel@tonic-gate extern ino_t dirlookup();
1690Sstevel@tonic-gate #endif
1700Sstevel@tonic-gate #define	NIL ((struct entry *)(0))
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate /*
1730Sstevel@tonic-gate  * Definitions for library routines operating on directories.
1740Sstevel@tonic-gate  * These definitions are used only for reading fake directory
1750Sstevel@tonic-gate  * entries from restore's temporary file "restoresymtable"
1760Sstevel@tonic-gate  * These have little to do with real directory entries.
1770Sstevel@tonic-gate  */
1780Sstevel@tonic-gate #if !defined(DEV_BSIZE)
1790Sstevel@tonic-gate #define	DEV_BSIZE	512
1800Sstevel@tonic-gate #endif
1810Sstevel@tonic-gate #define	DIRBLKSIZ	DEV_BSIZE
1820Sstevel@tonic-gate typedef struct _rstdirdesc {
1830Sstevel@tonic-gate 	int	dd_fd;
1840Sstevel@tonic-gate 	int	dd_refcnt;  /* so rst_{open,close}dir() avoid leaking memory */
1850Sstevel@tonic-gate 	off64_t	dd_loc;
1860Sstevel@tonic-gate 	off64_t	dd_size;
1870Sstevel@tonic-gate 	char	dd_buf[DIRBLKSIZ];
1880Sstevel@tonic-gate } RST_DIR;
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate /*
1910Sstevel@tonic-gate  * Constants associated with entry structs
1920Sstevel@tonic-gate  */
1930Sstevel@tonic-gate #define	HARDLINK	1
1940Sstevel@tonic-gate #define	SYMLINK		2
1950Sstevel@tonic-gate #define	TMPHDR		"RSTTMP"
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate /*
1980Sstevel@tonic-gate  * The entry describes the next file available on the tape
1990Sstevel@tonic-gate  */
2000Sstevel@tonic-gate struct context {
2010Sstevel@tonic-gate 	char	*name;		/* name of file */
2020Sstevel@tonic-gate 	ino_t	ino;		/* inumber of file */
2030Sstevel@tonic-gate 	struct	dinode *dip;	/* pointer to inode */
2040Sstevel@tonic-gate 	int	action;		/* action being taken on this file */
2050Sstevel@tonic-gate 	int	ts;		/* TS_* type of tape record */
2060Sstevel@tonic-gate } curfile;
2070Sstevel@tonic-gate /* actions */
2080Sstevel@tonic-gate #define	USING	1	/* extracting from the tape */
2090Sstevel@tonic-gate #define	SKIP	2	/* skipping */
2100Sstevel@tonic-gate #define	UNKNOWN 3	/* disposition or starting point is unknown */
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate /*
2130Sstevel@tonic-gate  * Structure and routines associated with listing directories
2140Sstevel@tonic-gate  * and expanding meta-characters in pathnames.
2150Sstevel@tonic-gate  */
2160Sstevel@tonic-gate struct afile {
2170Sstevel@tonic-gate 	ino_t	fnum;		/* inode number of file */
2180Sstevel@tonic-gate 	char	*fname;		/* file name */
2190Sstevel@tonic-gate 	short	fflags;		/* extraction flags, if any */
2200Sstevel@tonic-gate 	char	ftype;		/* file type, e.g. LEAF or NODE */
2210Sstevel@tonic-gate };
2220Sstevel@tonic-gate struct arglist {
2230Sstevel@tonic-gate 	struct afile	*head;	/* start of argument list */
2240Sstevel@tonic-gate 	struct afile	*last;	/* end of argument list */
2250Sstevel@tonic-gate 	struct afile	*base;	/* current list arena */
2260Sstevel@tonic-gate 	int		nent;	/* maximum size of list */
2270Sstevel@tonic-gate 	char		*cmd;	/* the current command */
2280Sstevel@tonic-gate };
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate /*
2310Sstevel@tonic-gate  * Other exported routines
2320Sstevel@tonic-gate  */
2330Sstevel@tonic-gate #ifdef __STDC__
2340Sstevel@tonic-gate extern int mkentry(char *, ino_t, struct arglist *);
2350Sstevel@tonic-gate extern int expand(char *, int, struct arglist *);
2360Sstevel@tonic-gate extern ino_t psearch(char *);
2370Sstevel@tonic-gate extern void metaget(char **data, size_t *size);
2380Sstevel@tonic-gate extern void metaproc(char *, char *, size_t);
2390Sstevel@tonic-gate extern long listfile(char *, ino_t, int);
2400Sstevel@tonic-gate extern long addfile(char *, ino_t, int);
2410Sstevel@tonic-gate extern long deletefile(char *, ino_t, int);
2420Sstevel@tonic-gate extern long nodeupdates(char *, ino_t, int);
2430Sstevel@tonic-gate extern long verifyfile(char *, ino_t, int);
2440Sstevel@tonic-gate extern void extractdirs(int genmode);
2450Sstevel@tonic-gate extern void skipdirs(void);
2460Sstevel@tonic-gate extern void treescan(char *, ino_t, long (*)(char *, ino_t, int));
2470Sstevel@tonic-gate extern RST_DIR *rst_opendir(char *);
2480Sstevel@tonic-gate extern void rst_closedir(RST_DIR *);
2490Sstevel@tonic-gate extern struct direct *rst_readdir(RST_DIR *);
2500Sstevel@tonic-gate extern void setdirmodes(void);
2510Sstevel@tonic-gate extern int genliteraldir(char *, ino_t);
2520Sstevel@tonic-gate extern int inodetype(ino_t);
2530Sstevel@tonic-gate extern void done(int);
2540Sstevel@tonic-gate extern void runcmdshell(void);
2550Sstevel@tonic-gate extern void canon(char *, char *, size_t);
2560Sstevel@tonic-gate extern void onintr(int);
2570Sstevel@tonic-gate extern void removeoldleaves(void);
2580Sstevel@tonic-gate extern void findunreflinks(void);
2590Sstevel@tonic-gate extern void removeoldnodes(void);
2600Sstevel@tonic-gate extern void createleaves(char *);
2610Sstevel@tonic-gate extern void createfiles(void);
2620Sstevel@tonic-gate extern void createlinks(void);
2630Sstevel@tonic-gate extern void checkrestore(void);
2640Sstevel@tonic-gate extern void setinput(char *, char *);
2650Sstevel@tonic-gate extern void newtapebuf(size_t);
2660Sstevel@tonic-gate extern void setup(void);
2670Sstevel@tonic-gate extern void setupR(void);
2680Sstevel@tonic-gate extern void getvol(int);
2690Sstevel@tonic-gate extern void printdumpinfo(void);
2700Sstevel@tonic-gate extern int extractfile(char *);
2710Sstevel@tonic-gate extern void skipmaps(void);
2720Sstevel@tonic-gate extern void skipfile(void);
2730Sstevel@tonic-gate extern void getfile(void (*)(char *, size_t), void (*)(char *, size_t));
2740Sstevel@tonic-gate extern void null(char *, size_t);
2750Sstevel@tonic-gate extern void findtapeblksize(int);
2760Sstevel@tonic-gate extern void flsht(void);
277426Srm88369 extern void closemt(int);
2780Sstevel@tonic-gate extern int readhdr(struct s_spcl *);
2790Sstevel@tonic-gate extern int gethead(struct s_spcl *);
2800Sstevel@tonic-gate extern int volnumber(ino_t);
2810Sstevel@tonic-gate extern void findinode(struct s_spcl *);
2820Sstevel@tonic-gate extern void pathcheck(char *);
2830Sstevel@tonic-gate extern void renameit(char *, char *);
2840Sstevel@tonic-gate extern int linkit(char *, char *, int);
2850Sstevel@tonic-gate extern int lf_linkit(char *, char *, int);
2860Sstevel@tonic-gate extern int reply(char *);
2870Sstevel@tonic-gate /*PRINTFLIKE1*/
2880Sstevel@tonic-gate extern void panic(const char *, ...);
2890Sstevel@tonic-gate extern char *lctime(time_t *);
2900Sstevel@tonic-gate extern int safe_open(int, const char *file, int mode, int perms);
2910Sstevel@tonic-gate extern FILE *safe_fopen(const char *filename, const char *smode, int perms);
2920Sstevel@tonic-gate extern void reset_dump(void);
2930Sstevel@tonic-gate extern void get_next_device(void);
2940Sstevel@tonic-gate extern void initpagercmd(void);
2950Sstevel@tonic-gate extern void resolve(char *, int *, char **);
2960Sstevel@tonic-gate extern int complexcopy(char *, char *, int);
2970Sstevel@tonic-gate #else	/* !STDC */
2980Sstevel@tonic-gate extern int mkentry();
2990Sstevel@tonic-gate extern int expand();
3000Sstevel@tonic-gate extern ino_t psearch();
3010Sstevel@tonic-gate extern void metaget();
3020Sstevel@tonic-gate extern void metaproc();
3030Sstevel@tonic-gate extern long listfile();
3040Sstevel@tonic-gate extern long addfile();
3050Sstevel@tonic-gate extern long deletefile();
3060Sstevel@tonic-gate extern long nodeupdates();
3070Sstevel@tonic-gate extern long verifyfile();
3080Sstevel@tonic-gate extern void extractdirs();
3090Sstevel@tonic-gate extern void skipdirs();
3100Sstevel@tonic-gate extern void treescan();
3110Sstevel@tonic-gate extern RST_DIR *rst_opendir();
3120Sstevel@tonic-gate extern void rst_closedir();
3130Sstevel@tonic-gate extern struct direct *rst_readdir();
3140Sstevel@tonic-gate extern void setdirmodes();
3150Sstevel@tonic-gate extern int genliteraldir();
3160Sstevel@tonic-gate extern int inodetype();
3170Sstevel@tonic-gate extern void done();
3180Sstevel@tonic-gate extern void runcmdshell();
3190Sstevel@tonic-gate extern void canon();
3200Sstevel@tonic-gate extern void onintr();
3210Sstevel@tonic-gate extern void removeoldleaves();
3220Sstevel@tonic-gate extern void findunreflinks();
3230Sstevel@tonic-gate extern void removeoldnodes();
3240Sstevel@tonic-gate extern void createleaves();
3250Sstevel@tonic-gate extern void createfiles();
3260Sstevel@tonic-gate extern void createlinks();
3270Sstevel@tonic-gate extern void checkrestore();
3280Sstevel@tonic-gate extern void setinput();
3290Sstevel@tonic-gate extern void newtapebuf();
3300Sstevel@tonic-gate extern void setup();
3310Sstevel@tonic-gate extern void setupR();
3320Sstevel@tonic-gate extern void getvol();
3330Sstevel@tonic-gate extern void printdumpinfo();
3340Sstevel@tonic-gate extern int extractfile();
3350Sstevel@tonic-gate extern void skipmaps();
3360Sstevel@tonic-gate extern void skipfile();
3370Sstevel@tonic-gate extern void getfile();
3380Sstevel@tonic-gate extern void null();
3390Sstevel@tonic-gate extern void findtapeblksize();
3400Sstevel@tonic-gate extern void flsht();
3410Sstevel@tonic-gate extern void closemt();
3420Sstevel@tonic-gate extern int readhdr();
3430Sstevel@tonic-gate extern int gethead();
3440Sstevel@tonic-gate extern int volnumber();
3450Sstevel@tonic-gate extern void findinode();
3460Sstevel@tonic-gate extern void pathcheck();
3470Sstevel@tonic-gate extern void renameit();
3480Sstevel@tonic-gate extern int linkit();
3490Sstevel@tonic-gate extern int lf_linkit();
3500Sstevel@tonic-gate extern int reply();
3510Sstevel@tonic-gate extern void panic();
3520Sstevel@tonic-gate extern char *lctime();
3530Sstevel@tonic-gate extern int safe_open();
3540Sstevel@tonic-gate extern FILE *safe_fopen();
3550Sstevel@tonic-gate extern void reset_dump();
3560Sstevel@tonic-gate extern void get_next_device();
3570Sstevel@tonic-gate extern void initpagercmd();
3580Sstevel@tonic-gate extern void resolve();
3590Sstevel@tonic-gate extern int complexcopy();
3600Sstevel@tonic-gate #endif	/* STDC */
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate /*
3630Sstevel@tonic-gate  * Useful macros
3640Sstevel@tonic-gate  */
3650Sstevel@tonic-gate #define	MWORD(m, i)	((m)[(ino_t)((i)-1)/NBBY])
3660Sstevel@tonic-gate #define	MBIT(i)		(1<<((ino_t)((i)-1)%NBBY))
3670Sstevel@tonic-gate #define	BIS(i, w)	(MWORD((w), (i)) |=  MBIT(i))
3680Sstevel@tonic-gate #define	BIC(i, w)	(MWORD((w), (i)) &= ~MBIT(i))
3690Sstevel@tonic-gate #define	BIT(i, w)	(MWORD((w), (i)) & MBIT(i))
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate /*
3720Sstevel@tonic-gate  * Macro used to get to the last segment of a complex string
3730Sstevel@tonic-gate  */
3740Sstevel@tonic-gate #define	LASTPART(s)	{int len = strlen(s)+1;\
3750Sstevel@tonic-gate 				while (s[len] != '\0')\
3760Sstevel@tonic-gate 					{s += len; len = strlen(s)+1; }\
3770Sstevel@tonic-gate 			}
3780Sstevel@tonic-gate 
3790Sstevel@tonic-gate /*
3800Sstevel@tonic-gate  * Define maximum length of complex string.  For now we use
3810Sstevel@tonic-gate  * MAXPATHLEN * 2 since recursion is not (yet) supported.
3820Sstevel@tonic-gate  * (add 3 for the 3 NULL characters in a two-part path)
3830Sstevel@tonic-gate  * Note that each component of a complex string is still
3840Sstevel@tonic-gate  * limited to MAXPATHLEN length.
3850Sstevel@tonic-gate  */
3860Sstevel@tonic-gate #define	MAXCOMPLEXLEN	(MAXPATHLEN*2 + 3)
3870Sstevel@tonic-gate 
3880Sstevel@tonic-gate /*
3890Sstevel@tonic-gate  * Define an overflow-free version of howmany so that we don't
3900Sstevel@tonic-gate  * run into trouble with large files.
3910Sstevel@tonic-gate  */
3920Sstevel@tonic-gate #define	d_howmany(x, y)	((x) / (y) + ((x) % (y) != 0))
3930Sstevel@tonic-gate 
3940Sstevel@tonic-gate /*
3950Sstevel@tonic-gate  * Defines used by findtapeblksize()
3960Sstevel@tonic-gate  */
3970Sstevel@tonic-gate #define	TAPE_FILE	0
3980Sstevel@tonic-gate #define	ARCHIVE_FILE	1
3990Sstevel@tonic-gate 
400*1053Smaheshvs #undef	setjmp
4010Sstevel@tonic-gate #define	setjmp(b)		sigsetjmp((b), 1)
4020Sstevel@tonic-gate #define	longjmp			siglongjmp
4030Sstevel@tonic-gate #define	jmp_buf			sigjmp_buf
4040Sstevel@tonic-gate #define	chown			lchown
4050Sstevel@tonic-gate 
4060Sstevel@tonic-gate /*
4070Sstevel@tonic-gate  * Defaults
4080Sstevel@tonic-gate  */
4090Sstevel@tonic-gate #define	TAPE	"/dev/rmt/0b"		/* default tape device */
4100Sstevel@tonic-gate #define	RESTORESYMTABLE	"./restoresymtable"
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate #define	dprintf		if (dflag) (void) fprintf
4130Sstevel@tonic-gate #define	vprintf		if (vflag) (void) fprintf
4140Sstevel@tonic-gate 
4150Sstevel@tonic-gate #define	GOOD 1
4160Sstevel@tonic-gate #define	FAIL 0
4170Sstevel@tonic-gate 
418426Srm88369 #define	ALLOW_OFFLINE	0
419426Srm88369 #define	FORCE_OFFLINE	1		/* offline drive for autoload */
420426Srm88369 
4210Sstevel@tonic-gate #define	DEF_PAGER	"/usr/bin/more"
4220Sstevel@tonic-gate 
4230Sstevel@tonic-gate #ifdef	__cplusplus
4240Sstevel@tonic-gate }
4250Sstevel@tonic-gate #endif
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate #endif /* _RESTORE_H */
428