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