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