Home | History | Annotate | Line # | Download | only in restore
restore.h revision 1.8
      1 /*	$NetBSD: restore.h,v 1.8 1997/07/01 05:37:54 lukem Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1983, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  * (c) UNIX System Laboratories, Inc.
      7  * All or some portions of this file are derived from material licensed
      8  * to the University of California by American Telephone and Telegraph
      9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     10  * the permission of UNIX System Laboratories, Inc.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	@(#)restore.h	8.3 (Berkeley) 9/13/94
     41  */
     42 
     43 /*
     44  * Flags
     45  */
     46 extern int	cvtflag;	/* convert from old to new tape format */
     47 extern int	bflag;		/* set input block size */
     48 extern int	dflag;		/* print out debugging info */
     49 extern int	hflag;		/* restore heirarchies */
     50 extern int	mflag;		/* restore by name instead of inode number */
     51 extern int	Nflag;		/* do not write the disk */
     52 extern int	vflag;		/* print out actions taken */
     53 extern int	yflag;		/* always try to recover from tape errors */
     54 /*
     55  * Global variables
     56  */
     57 extern char	*dumpmap; 	/* map of inodes on this dump tape */
     58 extern char	*usedinomap; 	/* map of inodes that are in use on this fs */
     59 extern ino_t	maxino;		/* highest numbered inode in this file system */
     60 extern long	dumpnum;	/* location of the dump on this tape */
     61 extern long	volno;		/* current volume being read */
     62 extern long	ntrec;		/* number of TP_BSIZE records per tape block */
     63 extern time_t	dumptime;	/* time that this dump begins */
     64 extern time_t	dumpdate;	/* time that this dump was made */
     65 extern char	command;	/* opration being performed */
     66 extern FILE	*terminal;	/* file descriptor for the terminal input */
     67 extern char	*tmpdir;	/* where to store temporary files */
     68 extern int	oldinofmt;	/* reading tape with old format inodes */
     69 extern int	Bcvt;		/* need byte swapping on inodes and dirs */
     70 
     71 /*
     72  * Each file in the file system is described by one of these entries
     73  */
     74 struct entry {
     75 	char	*e_name;		/* the current name of this entry */
     76 	u_char	e_namlen;		/* length of this name */
     77 	char	e_type;			/* type of this entry, see below */
     78 	short	e_flags;		/* status flags, see below */
     79 	ino_t	e_ino;			/* inode number in previous file sys */
     80 	long	e_index;		/* unique index (for dumpped table) */
     81 	struct	entry *e_parent;	/* pointer to parent directory (..) */
     82 	struct	entry *e_sibling;	/* next element in this directory (.) */
     83 	struct	entry *e_links;		/* hard links to this inode */
     84 	struct	entry *e_entries;	/* for directories, their entries */
     85 	struct	entry *e_next;		/* hash chain list */
     86 };
     87 /* types */
     88 #define	LEAF 1			/* non-directory entry */
     89 #define NODE 2			/* directory entry */
     90 #define LINK 4			/* synthesized type, stripped by addentry */
     91 /* flags */
     92 #define EXTRACT		0x0001	/* entry is to be replaced from the tape */
     93 #define NEW		0x0002	/* a new entry to be extracted */
     94 #define KEEP		0x0004	/* entry is not to change */
     95 #define REMOVED		0x0010	/* entry has been removed */
     96 #define TMPNAME		0x0020	/* entry has been given a temporary name */
     97 #define EXISTED		0x0040	/* directory already existed during extract */
     98 
     99 /*
    100  * Constants associated with entry structs
    101  */
    102 #define HARDLINK	1
    103 #define SYMLINK		2
    104 #define TMPHDR		"RSTTMP"
    105 
    106 /*
    107  * The entry describes the next file available on the tape
    108  */
    109 struct context {
    110 	char	*name;		/* name of file */
    111 	ino_t	ino;		/* inumber of file */
    112 	struct	dinode *dip;	/* pointer to inode */
    113 	char	action;		/* action being taken on this file */
    114 } curfile;
    115 /* actions */
    116 #define	USING	1	/* extracting from the tape */
    117 #define	SKIP	2	/* skipping */
    118 #define UNKNOWN 3	/* disposition or starting point is unknown */
    119 
    120 /*
    121  * Definitions for library routines operating on directories.
    122  */
    123 typedef struct rstdirdesc RST_DIR;
    124 
    125 /*
    126  * Flags to setdirmodes.
    127  */
    128 #define FORCE	0x0001
    129 
    130 /*
    131  * Useful macros
    132  */
    133 #define TSTINO(ino, map) \
    134 	(map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
    135 #define	SETINO(ino, map) \
    136 	map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
    137 
    138 #define dprintf		if (dflag) fprintf
    139 #define vprintf		if (vflag) fprintf
    140 
    141 #define GOOD 1
    142 #define FAIL 0
    143