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