17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (c) 1983 Regents of the University of California.
37c478bd9Sstevel@tonic-gate  * All rights reserved.  The Berkeley software License Agreement
47c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
57c478bd9Sstevel@tonic-gate  */
77c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
87c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
107c478bd9Sstevel@tonic-gate /*
1133a5e6b2Srm  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
127c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
137c478bd9Sstevel@tonic-gate  */
157c478bd9Sstevel@tonic-gate #ifndef _RESTORE_H
167c478bd9Sstevel@tonic-gate #define	_RESTORE_H
187c478bd9Sstevel@tonic-gate #include <stdio.h>
197c478bd9Sstevel@tonic-gate #include <string.h>
207c478bd9Sstevel@tonic-gate #include <malloc.h>
217c478bd9Sstevel@tonic-gate #include <netdb.h>
227c478bd9Sstevel@tonic-gate #include <fcntl.h>
237c478bd9Sstevel@tonic-gate #include <unistd.h>
247c478bd9Sstevel@tonic-gate #include <errno.h>
257c478bd9Sstevel@tonic-gate #include <sys/stat.h>
267c478bd9Sstevel@tonic-gate #include <sys/param.h>
277c478bd9Sstevel@tonic-gate #include <sys/time.h>
287c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
297c478bd9Sstevel@tonic-gate #include <locale.h>
307c478bd9Sstevel@tonic-gate #include <stdlib.h>
317c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_inode.h>
327c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_fs.h>
337c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_fsdir.h>
347c478bd9Sstevel@tonic-gate #include <note.h>
367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
377c478bd9Sstevel@tonic-gate extern "C" {
387c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate #define	ROOTINO	UFSROOTINO
417c478bd9Sstevel@tonic-gate #define	SUPPORTS_MTB_TAPE_FORMAT
427c478bd9Sstevel@tonic-gate #include <protocols/dumprestore.h>
437c478bd9Sstevel@tonic-gate #include <memutils.h>
447c478bd9Sstevel@tonic-gate #include <assert.h>
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Flags
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate extern int	cvtflag;	/* convert from old to new tape format */
507c478bd9Sstevel@tonic-gate extern int	bflag;		/* set input block size */
517c478bd9Sstevel@tonic-gate extern int	dflag;		/* print out debugging info */
527c478bd9Sstevel@tonic-gate extern int	hflag;		/* restore heirarchies */
537c478bd9Sstevel@tonic-gate extern int	mflag;		/* restore by name instead of inode number */
547c478bd9Sstevel@tonic-gate extern int	vflag;		/* print out actions taken */
557c478bd9Sstevel@tonic-gate extern int	yflag;		/* always try to recover from tape errors */
567c478bd9Sstevel@tonic-gate extern int	paginating;	/* paginate bulk interactive output */
577c478bd9Sstevel@tonic-gate extern int	offline;	/* take tape offline when closing */
587c478bd9Sstevel@tonic-gate extern int	autoload;	/* wait for tape to autoload; implies offline */
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate  * Global variables
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate extern int	autoload_tries;	/* number of times to check on autoload */
637c478bd9Sstevel@tonic-gate extern int	autoload_period; /* seconds, tries*period = total wait time */
647c478bd9Sstevel@tonic-gate extern struct byteorder_ctx *byteorder;
657c478bd9Sstevel@tonic-gate extern char	*progname;	/* our name */
66d9529689SToomas Soome extern char	*dumpmap;	/* map of inodes on this dump tape */
67d9529689SToomas Soome extern char	*clrimap;	/* map of inodes to be deleted */
687c478bd9Sstevel@tonic-gate extern char	*c_label;	/* label we expect to see on the tape */
697c478bd9Sstevel@tonic-gate extern ino_t	maxino;		/* highest numbered inode in this file system */
707c478bd9Sstevel@tonic-gate extern long	dumpnum;	/* location of the dump on this tape */
717c478bd9Sstevel@tonic-gate extern int	volno;		/* current volume being read */
727c478bd9Sstevel@tonic-gate extern uint_t	ntrec;		/* number of tp_bsize records per tape block */
737c478bd9Sstevel@tonic-gate extern uint_t	saved_ntrec;	/* number of tp_bsize records per tape block */
747c478bd9Sstevel@tonic-gate extern ssize_t	tape_rec_size;	/* tape record size (tp_bsize * ntrec) */
757c478bd9Sstevel@tonic-gate extern time_t	dumptime;	/* time that this dump begins */
767c478bd9Sstevel@tonic-gate extern time_t	dumpdate;	/* time that this dump was made */
777c478bd9Sstevel@tonic-gate extern char	command;	/* opration being performed */
787c478bd9Sstevel@tonic-gate extern FILE	*terminal;	/* file descriptor for the terminal input */
797c478bd9Sstevel@tonic-gate extern char	*tmpdir;	/* where to put the rst{dir,mode}... files */
807c478bd9Sstevel@tonic-gate extern char	*pager_catenated; /* pager command and args */
817c478bd9Sstevel@tonic-gate extern char	**pager_vector;	/* pager_catenated split up for execve() */
827c478bd9Sstevel@tonic-gate extern int	pager_len;	/* # elements in pager_vector; includes NULL */
837c478bd9Sstevel@tonic-gate extern int	inattrspace;	/* true if currently scanning attribute space */
847c478bd9Sstevel@tonic-gate extern int	savepwd;	/* this is where restore is running from */
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * Each file in the file system is described by one of these entries
887c478bd9Sstevel@tonic-gate  * Note that the e_next field is used by the symbol table hash lists
897c478bd9Sstevel@tonic-gate  * and then reused by the remove code after the entry is removed from
907c478bd9Sstevel@tonic-gate  * the symbol table.
917c478bd9Sstevel@tonic-gate  */
927c478bd9Sstevel@tonic-gate struct entry {
937c478bd9Sstevel@tonic-gate 	char	*e_name;		/* the current name of this entry */
947c478bd9Sstevel@tonic-gate 	ushort_t e_namlen;		/* length of this name */
957c478bd9Sstevel@tonic-gate 	char	e_type;			/* type of this entry, see below */
967c478bd9Sstevel@tonic-gate 	short	e_flags;		/* status flags, see below */
977c478bd9Sstevel@tonic-gate 	ino_t	e_ino;			/* inode number in previous file sys */
987c478bd9Sstevel@tonic-gate 	long	e_index;		/* unique index (for dumpped table) */
997c478bd9Sstevel@tonic-gate 	struct	entry *e_parent;	/* pointer to parent directory (..) */
1007c478bd9Sstevel@tonic-gate 	struct	entry *e_sibling;	/* next element in this directory (.) */
1017c478bd9Sstevel@tonic-gate 	struct	entry *e_links;		/* hard links to this inode */
1027c478bd9Sstevel@tonic-gate 	struct	entry *e_entries;	/* for directories, their entries */
1037c478bd9Sstevel@tonic-gate 	struct	entry *e_xattrs;	/* pointer to extended attribute root */
1047c478bd9Sstevel@tonic-gate 	struct	entry *e_next;		/* hash chain list and removelist */
1057c478bd9Sstevel@tonic-gate };
1067c478bd9Sstevel@tonic-gate /* types */
1077c478bd9Sstevel@tonic-gate #define	LEAF 1			/* non-directory entry */
1087c478bd9Sstevel@tonic-gate #define	NODE 2			/* directory entry */
1097c478bd9Sstevel@tonic-gate #define	LINK 4			/* synthesized type, stripped by addentry */
1107c478bd9Sstevel@tonic-gate #define	ROOT 8			/* synthesized type, stripped by addentry */
1117c478bd9Sstevel@tonic-gate /* flags */
1127c478bd9Sstevel@tonic-gate #define	EXTRACT		0x0001	/* entry is to be replaced from the tape */
1137c478bd9Sstevel@tonic-gate #define	NEW		0x0002	/* a new entry to be extracted */
1147c478bd9Sstevel@tonic-gate #define	KEEP		0x0004	/* entry is not to change */
1157c478bd9Sstevel@tonic-gate #define	REMOVED		0x0010	/* entry has been removed */
1167c478bd9Sstevel@tonic-gate #define	TMPNAME		0x0020	/* entry has been given a temporary name */
1177c478bd9Sstevel@tonic-gate #define	EXISTED		0x0040	/* directory already existed during extract */
1187c478bd9Sstevel@tonic-gate #define	XATTR		0x0080	/* file belongs in an attribute tree */
1197c478bd9Sstevel@tonic-gate #define	XATTRROOT	0x0100	/* directory is root of an attribute tree */
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate  * functions defined on entry structs
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate extern struct entry *lookupino(ino_t);
1247c478bd9Sstevel@tonic-gate extern struct entry *lookupname(char *);
1257c478bd9Sstevel@tonic-gate extern struct entry *addentry(char *, ino_t, int);
1267c478bd9Sstevel@tonic-gate extern void deleteino(ino_t);
1277c478bd9Sstevel@tonic-gate extern char *myname(struct entry *);
1287c478bd9Sstevel@tonic-gate extern void freeentry(struct entry *);
1297c478bd9Sstevel@tonic-gate extern void moveentry(struct entry *, char *);
1307c478bd9Sstevel@tonic-gate extern char *savename(char *);
1317c478bd9Sstevel@tonic-gate extern void freename(char *);
1327c478bd9Sstevel@tonic-gate extern void dumpsymtable(char *, int);
1337c478bd9Sstevel@tonic-gate extern void initsymtable(char *);
1347c478bd9Sstevel@tonic-gate extern void mktempname(struct entry *);
1357c478bd9Sstevel@tonic-gate extern char *gentempname(struct entry *);
1367c478bd9Sstevel@tonic-gate extern void newnode(struct entry *);
1377c478bd9Sstevel@tonic-gate extern void removenode(struct entry *);
1387c478bd9Sstevel@tonic-gate extern void removeleaf(struct entry *);
1397c478bd9Sstevel@tonic-gate extern ino_t lowerbnd(ino_t);
1407c478bd9Sstevel@tonic-gate extern ino_t upperbnd(ino_t);
1417c478bd9Sstevel@tonic-gate extern void badentry(struct entry *, char *);
1427c478bd9Sstevel@tonic-gate extern char *flagvalues(struct entry *);
1437c478bd9Sstevel@tonic-gate extern ino_t dirlookup(char *);
1447c478bd9Sstevel@tonic-gate #define	NIL ((struct entry *)(0))
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate  * Definitions for library routines operating on directories.
1487c478bd9Sstevel@tonic-gate  * These definitions are used only for reading fake directory
1497c478bd9Sstevel@tonic-gate  * entries from restore's temporary file "restoresymtable"
1507c478bd9Sstevel@tonic-gate  * These have little to do with real directory entries.
1517c478bd9Sstevel@tonic-gate  */
1527c478bd9Sstevel@tonic-gate #if !defined(DEV_BSIZE)
1537c478bd9Sstevel@tonic-gate #define	DEV_BSIZE	512
1547c478bd9Sstevel@tonic-gate #endif
1557c478bd9Sstevel@tonic-gate #define	DIRBLKSIZ	DEV_BSIZE
1567c478bd9Sstevel@tonic-gate typedef struct _rstdirdesc {
1577c478bd9Sstevel@tonic-gate 	int	dd_fd;
1587c478bd9Sstevel@tonic-gate 	int	dd_refcnt;  /* so rst_{open,close}dir() avoid leaking memory */
1597c478bd9Sstevel@tonic-gate 	off64_t	dd_loc;
1607c478bd9Sstevel@tonic-gate 	off64_t	dd_size;
1617c478bd9Sstevel@tonic-gate 	char	dd_buf[DIRBLKSIZ];
1627c478bd9Sstevel@tonic-gate } RST_DIR;
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * Constants associated with entry structs
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate #define	HARDLINK	1
1687c478bd9Sstevel@tonic-gate #define	SYMLINK		2
1697c478bd9Sstevel@tonic-gate #define	TMPHDR		"RSTTMP"
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * The entry describes the next file available on the tape
1737c478bd9Sstevel@tonic-gate  */
174*e0dfa398SToomas Soome extern struct context {
1757c478bd9Sstevel@tonic-gate 	char	*name;		/* name of file */
1767c478bd9Sstevel@tonic-gate 	ino_t	ino;		/* inumber of file */
1777c478bd9Sstevel@tonic-gate 	struct	dinode *dip;	/* pointer to inode */
1787c478bd9Sstevel@tonic-gate 	int	action;		/* action being taken on this file */
1797c478bd9Sstevel@tonic-gate 	int	ts;		/* TS_* type of tape record */
1807c478bd9Sstevel@tonic-gate } curfile;
1817c478bd9Sstevel@tonic-gate /* actions */
1827c478bd9Sstevel@tonic-gate #define	USING	1	/* extracting from the tape */
1837c478bd9Sstevel@tonic-gate #define	SKIP	2	/* skipping */
1847c478bd9Sstevel@tonic-gate #define	UNKNOWN 3	/* disposition or starting point is unknown */
1867c478bd9Sstevel@tonic-gate /*
1877c478bd9Sstevel@tonic-gate  * Structure and routines associated with listing directories
1887c478bd9Sstevel@tonic-gate  * and expanding meta-characters in pathnames.
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate struct afile {
1917c478bd9Sstevel@tonic-gate 	ino_t	fnum;		/* inode number of file */
1927c478bd9Sstevel@tonic-gate 	char	*fname;		/* file name */
1937c478bd9Sstevel@tonic-gate 	short	fflags;		/* extraction flags, if any */
1947c478bd9Sstevel@tonic-gate 	char	ftype;		/* file type, e.g. LEAF or NODE */
1957c478bd9Sstevel@tonic-gate };
1967c478bd9Sstevel@tonic-gate struct arglist {
1977c478bd9Sstevel@tonic-gate 	struct afile	*head;	/* start of argument list */
1987c478bd9Sstevel@tonic-gate 	struct afile	*last;	/* end of argument list */
1997c478bd9Sstevel@tonic-gate 	struct afile	*base;	/* current list arena */
2007c478bd9Sstevel@tonic-gate 	int		nent;	/* maximum size of list */
2017c478bd9Sstevel@tonic-gate 	char		*cmd;	/* the current command */
2027c478bd9Sstevel@tonic-gate };
2047c478bd9Sstevel@tonic-gate /*
2057c478bd9Sstevel@tonic-gate  * Other exported routines
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate #ifdef __STDC__
2087c478bd9Sstevel@tonic-gate extern int mkentry(char *, ino_t, struct arglist *);
2097c478bd9Sstevel@tonic-gate extern int expand(char *, int, struct arglist *);
2107c478bd9Sstevel@tonic-gate extern ino_t psearch(char *);
2117c478bd9Sstevel@tonic-gate extern void metaget(char **data, size_t *size);
2127c478bd9Sstevel@tonic-gate extern void metaproc(char *, char *, size_t);
2137c478bd9Sstevel@tonic-gate extern long listfile(char *, ino_t, int);
2147c478bd9Sstevel@tonic-gate extern long addfile(char *, ino_t, int);
2157c478bd9Sstevel@tonic-gate extern long deletefile(char *, ino_t, int);
2167c478bd9Sstevel@tonic-gate extern long nodeupdates(char *, ino_t, int);
2177c478bd9Sstevel@tonic-gate extern long verifyfile(char *, ino_t, int);
2187c478bd9Sstevel@tonic-gate extern void extractdirs(int genmode);
2197c478bd9Sstevel@tonic-gate extern void skipdirs(void);
2207c478bd9Sstevel@tonic-gate extern void treescan(char *, ino_t, long (*)(char *, ino_t, int));
2217c478bd9Sstevel@tonic-gate extern RST_DIR *rst_opendir(char *);
2227c478bd9Sstevel@tonic-gate extern void rst_closedir(RST_DIR *);
2237c478bd9Sstevel@tonic-gate extern struct direct *rst_readdir(RST_DIR *);
2247c478bd9Sstevel@tonic-gate extern void setdirmodes(void);
2257c478bd9Sstevel@tonic-gate extern int genliteraldir(char *, ino_t);
2267c478bd9Sstevel@tonic-gate extern int inodetype(ino_t);
227c0882bf4SToomas Soome extern void done(int) __NORETURN;
2287c478bd9Sstevel@tonic-gate extern void runcmdshell(void);
2297c478bd9Sstevel@tonic-gate extern void canon(char *, char *, size_t);
2307c478bd9Sstevel@tonic-gate extern void onintr(int);
2317c478bd9Sstevel@tonic-gate extern void removeoldleaves(void);
2327c478bd9Sstevel@tonic-gate extern void findunreflinks(void);
2337c478bd9Sstevel@tonic-gate extern void removeoldnodes(void);
2347c478bd9Sstevel@tonic-gate extern void createleaves(char *);
2357c478bd9Sstevel@tonic-gate extern void createfiles(void);
2367c478bd9Sstevel@tonic-gate extern void createlinks(void);
2377c478bd9Sstevel@tonic-gate extern void checkrestore(void);
2387c478bd9Sstevel@tonic-gate extern void setinput(char *, char *);
2397c478bd9Sstevel@tonic-gate extern void newtapebuf(size_t);
2407c478bd9Sstevel@tonic-gate extern void setup(void);
2417c478bd9Sstevel@tonic-gate extern void setupR(void);
2427c478bd9Sstevel@tonic-gate extern void getvol(int);
2437c478bd9Sstevel@tonic-gate extern void printdumpinfo(void);
2447c478bd9Sstevel@tonic-gate extern int extractfile(char *);
2457c478bd9Sstevel@tonic-gate extern void skipmaps(void);
2467c478bd9Sstevel@tonic-gate extern void skipfile(void);
2477c478bd9Sstevel@tonic-gate extern void getfile(void (*)(char *, size_t), void (*)(char *, size_t));
2487c478bd9Sstevel@tonic-gate extern void null(char *, size_t);
2497c478bd9Sstevel@tonic-gate extern void findtapeblksize(int);
2507c478bd9Sstevel@tonic-gate extern void flsht(void);
25133a5e6b2Srm extern void closemt(int);
2527c478bd9Sstevel@tonic-gate extern int readhdr(struct s_spcl *);
2537c478bd9Sstevel@tonic-gate extern int gethead(struct s_spcl *);
2547c478bd9Sstevel@tonic-gate extern int volnumber(ino_t);
2557c478bd9Sstevel@tonic-gate extern void findinode(struct s_spcl *);
2567c478bd9Sstevel@tonic-gate extern void pathcheck(char *);
2577c478bd9Sstevel@tonic-gate extern void renameit(char *, char *);
2587c478bd9Sstevel@tonic-gate extern int linkit(char *, char *, int);
2597c478bd9Sstevel@tonic-gate extern int lf_linkit(char *, char *, int);
2607c478bd9Sstevel@tonic-gate extern int reply(char *);
2617c478bd9Sstevel@tonic-gate /*PRINTFLIKE1*/
2627c478bd9Sstevel@tonic-gate extern void panic(const char *, ...);
2637c478bd9Sstevel@tonic-gate extern char *lctime(time_t *);
2647c478bd9Sstevel@tonic-gate extern int safe_open(int, const char *file, int mode, int perms);
2657c478bd9Sstevel@tonic-gate extern FILE *safe_fopen(const char *filename, const char *smode, int perms);
2667c478bd9Sstevel@tonic-gate extern void reset_dump(void);
2677c478bd9Sstevel@tonic-gate extern void get_next_device(void);
2687c478bd9Sstevel@tonic-gate extern void initpagercmd(void);
2697c478bd9Sstevel@tonic-gate extern void resolve(char *, int *, char **);
2707c478bd9Sstevel@tonic-gate extern int complexcopy(char *, char *, int);
2717c478bd9Sstevel@tonic-gate #else	/* !STDC */
2727c478bd9Sstevel@tonic-gate extern int mkentry();
2737c478bd9Sstevel@tonic-gate extern int expand();
2747c478bd9Sstevel@tonic-gate extern ino_t psearch();
2757c478bd9Sstevel@tonic-gate extern void metaget();
2767c478bd9Sstevel@tonic-gate extern void metaproc();
2777c478bd9Sstevel@tonic-gate extern long listfile();
2787c478bd9Sstevel@tonic-gate extern long addfile();
2797c478bd9Sstevel@tonic-gate extern long deletefile();
2807c478bd9Sstevel@tonic-gate extern long nodeupdates();
2817c478bd9Sstevel@tonic-gate extern long verifyfile();
2827c478bd9Sstevel@tonic-gate extern void extractdirs();
2837c478bd9Sstevel@tonic-gate extern void skipdirs();
2847c478bd9Sstevel@tonic-gate extern void treescan();
2857c478bd9Sstevel@tonic-gate extern RST_DIR *rst_opendir();
2867c478bd9Sstevel@tonic-gate extern void rst_closedir();
2877c478bd9Sstevel@tonic-gate extern struct direct *rst_readdir();
2887c478bd9Sstevel@tonic-gate extern void setdirmodes();
2897c478bd9Sstevel@tonic-gate extern int genliteraldir();
2907c478bd9Sstevel@tonic-gate extern int inodetype();
2917c478bd9Sstevel@tonic-gate extern void done();
2927c478bd9Sstevel@tonic-gate extern void runcmdshell();
2937c478bd9Sstevel@tonic-gate extern void canon();
2947c478bd9Sstevel@tonic-gate extern void onintr();
2957c478bd9Sstevel@tonic-gate extern void removeoldleaves();
2967c478bd9Sstevel@tonic-gate extern void findunreflinks();
2977c478bd9Sstevel@tonic-gate extern void removeoldnodes();
2987c478bd9Sstevel@tonic-gate extern void createleaves();
2997c478bd9Sstevel@tonic-gate extern void createfiles();
3007c478bd9Sstevel@tonic-gate extern void createlinks();
3017c478bd9Sstevel@tonic-gate extern void checkrestore();
3027c478bd9Sstevel@tonic-gate extern void setinput();
3037c478bd9Sstevel@tonic-gate extern void newtapebuf();
3047c478bd9Sstevel@tonic-gate extern void setup();
3057c478bd9Sstevel@tonic-gate extern void setupR();
3067c478bd9Sstevel@tonic-gate extern void getvol();
3077c478bd9Sstevel@tonic-gate extern void printdumpinfo();
3087c478bd9Sstevel@tonic-gate extern int extractfile();
3097c478bd9Sstevel@tonic-gate extern void skipmaps();
3107c478bd9Sstevel@tonic-gate extern void skipfile();
3117c478bd9Sstevel@tonic-gate extern void getfile();
3127c478bd9Sstevel@tonic-gate extern void null();
3137c478bd9Sstevel@tonic-gate extern void findtapeblksize();
3147c478bd9Sstevel@tonic-gate extern void flsht();
3157c478bd9Sstevel@tonic-gate extern void closemt();
3167c478bd9Sstevel@tonic-gate extern int readhdr();
3177c478bd9Sstevel@tonic-gate extern int gethead();
3187c478bd9Sstevel@tonic-gate extern int volnumber();
3197c478bd9Sstevel@tonic-gate extern void findinode();
3207c478bd9Sstevel@tonic-gate extern void pathcheck();
3217c478bd9Sstevel@tonic-gate extern void renameit();
3227c478bd9Sstevel@tonic-gate extern int linkit();
3237c478bd9Sstevel@tonic-gate extern int lf_linkit();
3247c478bd9Sstevel@tonic-gate extern int reply();
3257c478bd9Sstevel@tonic-gate extern void panic();
3267c478bd9Sstevel@tonic-gate extern char *lctime();
3277c478bd9Sstevel@tonic-gate extern int safe_open();
3287c478bd9Sstevel@tonic-gate extern FILE *safe_fopen();
3297c478bd9Sstevel@tonic-gate extern void reset_dump();
3307c478bd9Sstevel@tonic-gate extern void get_next_device();
3317c478bd9Sstevel@tonic-gate extern void initpagercmd();
3327c478bd9Sstevel@tonic-gate extern void resolve();
3337c478bd9Sstevel@tonic-gate extern int complexcopy();
3347c478bd9Sstevel@tonic-gate #endif	/* STDC */
3367c478bd9Sstevel@tonic-gate /*
3377c478bd9Sstevel@tonic-gate  * Useful macros
3387c478bd9Sstevel@tonic-gate  */
3397c478bd9Sstevel@tonic-gate #define	MWORD(m, i)	((m)[(ino_t)((i)-1)/NBBY])
3407c478bd9Sstevel@tonic-gate #define	MBIT(i)		(1<<((ino_t)((i)-1)%NBBY))
3417c478bd9Sstevel@tonic-gate #define	BIS(i, w)	(MWORD((w), (i)) |=  MBIT(i))
3427c478bd9Sstevel@tonic-gate #define	BIC(i, w)	(MWORD((w), (i)) &= ~MBIT(i))
3437c478bd9Sstevel@tonic-gate #define	BIT(i, w)	(MWORD((w), (i)) & MBIT(i))
3457c478bd9Sstevel@tonic-gate /*
3467c478bd9Sstevel@tonic-gate  * Macro used to get to the last segment of a complex string
3477c478bd9Sstevel@tonic-gate  */
3487c478bd9Sstevel@tonic-gate #define	LASTPART(s)	{int len = strlen(s)+1;\
3497c478bd9Sstevel@tonic-gate 				while (s[len] != '\0')\
3507c478bd9Sstevel@tonic-gate 					{s += len; len = strlen(s)+1; }\
3517c478bd9Sstevel@tonic-gate 			}
3537c478bd9Sstevel@tonic-gate /*
3547c478bd9Sstevel@tonic-gate  * Define maximum length of complex string.  For now we use
3557c478bd9Sstevel@tonic-gate  * MAXPATHLEN * 2 since recursion is not (yet) supported.
3567c478bd9Sstevel@tonic-gate  * (add 3 for the 3 NULL characters in a two-part path)
3577c478bd9Sstevel@tonic-gate  * Note that each component of a complex string is still
3587c478bd9Sstevel@tonic-gate  * limited to MAXPATHLEN length.
3597c478bd9Sstevel@tonic-gate  */
3607c478bd9Sstevel@tonic-gate #define	MAXCOMPLEXLEN	(MAXPATHLEN*2 + 3)
3627c478bd9Sstevel@tonic-gate /*
3637c478bd9Sstevel@tonic-gate  * Define an overflow-free version of howmany so that we don't
3647c478bd9Sstevel@tonic-gate  * run into trouble with large files.
3657c478bd9Sstevel@tonic-gate  */
3667c478bd9Sstevel@tonic-gate #define	d_howmany(x, y)	((x) / (y) + ((x) % (y) != 0))
3687c478bd9Sstevel@tonic-gate /*
3697c478bd9Sstevel@tonic-gate  * Defines used by findtapeblksize()
3707c478bd9Sstevel@tonic-gate  */
3717c478bd9Sstevel@tonic-gate #define	TAPE_FILE	0
3727c478bd9Sstevel@tonic-gate #define	ARCHIVE_FILE	1
374fe0e7ec4Smaheshvs #undef	setjmp
3757c478bd9Sstevel@tonic-gate #define	setjmp(b)		sigsetjmp((b), 1)
3767c478bd9Sstevel@tonic-gate #define	longjmp			siglongjmp
3777c478bd9Sstevel@tonic-gate #define	jmp_buf			sigjmp_buf
3787c478bd9Sstevel@tonic-gate #define	chown			lchown
3807c478bd9Sstevel@tonic-gate /*
3817c478bd9Sstevel@tonic-gate  * Defaults
3827c478bd9Sstevel@tonic-gate  */
3837c478bd9Sstevel@tonic-gate #define	TAPE	"/dev/rmt/0b"		/* default tape device */
3847c478bd9Sstevel@tonic-gate #define	RESTORESYMTABLE	"./restoresymtable"
3867c478bd9Sstevel@tonic-gate #define	dprintf		if (dflag) (void) fprintf
3877c478bd9Sstevel@tonic-gate #define	vprintf		if (vflag) (void) fprintf
3897c478bd9Sstevel@tonic-gate #define	GOOD 1
3907c478bd9Sstevel@tonic-gate #define	FAIL 0
39233a5e6b2Srm #define	ALLOW_OFFLINE	0
39333a5e6b2Srm #define	FORCE_OFFLINE	1		/* offline drive for autoload */
3957c478bd9Sstevel@tonic-gate #define	DEF_PAGER	"/usr/bin/more"
3977c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3987c478bd9Sstevel@tonic-gate }
3997c478bd9Sstevel@tonic-gate #endif
4017c478bd9Sstevel@tonic-gate #endif /* _RESTORE_H */