No empty .Rs/.Re
[netbsd-mini2440.git] / sbin / fsck_lfs / fsck.h
blobb3228d4debac87f4f8e337a1e0b133f0b0209f79
1 /* $NetBSD: fsck.h,v 1.17 2008/04/28 20:23:08 martin Exp $ */
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1980, 1986, 1993
34 * The Regents of the University of California. All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
60 * @(#)fsck.h 8.1 (Berkeley) 6/5/93
63 #ifdef KS_DEBUG
64 #include <err.h>
65 #define debug_printf warn
66 #else
67 #define debug_printf
68 #endif
70 #define MAXDUP 10 /* limit on dup blks (per inode) */
71 #define MAXBAD 10 /* limit on bad blks (per inode) */
72 #define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */
73 #define INOBUFSIZE 56*1024 /* size of buffer to read inodes in pass1 */
75 #ifndef BUFSIZ
76 #define BUFSIZ 1024
77 #endif
79 #define USTATE 01 /* inode not allocated */
80 #define FSTATE 02 /* inode is file */
81 #define DSTATE 03 /* inode is directory */
82 #define DFOUND 04 /* directory found during descent */
83 #define DCLEAR 05 /* directory is to be cleared */
84 #define FCLEAR 06 /* file is to be cleared */
86 #define EEXIT 8 /* Standard error exit */
89 * buffer cache structure.
91 struct ubufarea {
92 struct ubufarea *b_next; /* free list queue */
93 struct ubufarea *b_prev; /* free list queue */
94 daddr_t b_bno;
95 int b_size;
96 int b_errs;
97 int b_flags;
98 union {
99 char *b_buf; /* buffer space */
100 /* XXX ondisk32 */
101 int32_t *b_indir; /* indirect block */
102 struct lfs *b_fs; /* super block */
103 struct cg *b_cg;/* cylinder group */
104 struct ufs1_dinode *b_dinode; /* inode block */
105 } b_un;
106 char b_dirty;
108 #define B_INUSE 1
110 #define MINBUFS 5 /* minimum number of buffers required */
112 #define dirty(bp) (bp)->b_dirty = 1
113 #define initbarea(bp) \
114 (bp)->b_dirty = 0; \
115 (bp)->b_bno = (daddr_t)-1; \
116 (bp)->b_flags = 0;
118 enum fixstate {
119 DONTKNOW, NOFIX, FIX, IGNORE
122 struct inodesc {
123 enum fixstate id_fix; /* policy on fixing errors */
124 int (*id_func) (struct inodesc *); /* function to be applied to
125 * blocks of inode */
126 ino_t id_number; /* inode number described */
127 ino_t id_parent; /* for DATA nodes, their parent */
128 daddr_t id_blkno; /* current block number being examined */
129 daddr_t id_lblkno; /* current logical block number */
130 int id_numfrags; /* number of frags contained in block */
131 quad_t id_filesize; /* for DATA nodes, the size of the directory */
132 int id_loc; /* for DATA nodes, current location in dir */
133 int id_entryno; /* for DATA nodes, current entry number */
134 struct direct *id_dirp; /* for DATA nodes, ptr to current entry */
135 const char *id_name; /* for DATA nodes, name to find or enter */
136 char id_type; /* type of descriptor, DATA or ADDR */
138 /* file types */
139 #define DATA 1
140 #define ADDR 2
143 * Linked list of duplicate blocks.
145 * The list is composed of two parts. The first part of the
146 * list (from duplist through the node pointed to by muldup)
147 * contains a single copy of each duplicate block that has been
148 * found. The second part of the list (from muldup to the end)
149 * contains duplicate blocks that have been found more than once.
150 * To check if a block has been found as a duplicate it is only
151 * necessary to search from duplist through muldup. To find the
152 * total number of times that a block has been found as a duplicate
153 * the entire list must be searched for occurrences of the block
154 * in question. The following diagram shows a sample list where
155 * w (found twice), x (found once), y (found three times), and z
156 * (found once) are duplicate block numbers:
158 * w -> y -> x -> z -> y -> w -> y
159 * ^ ^
160 * | |
161 * duplist muldup
163 struct dups {
164 struct dups *next;
165 daddr_t dup;
168 * Linked list of inodes with zero link counts.
170 struct zlncnt {
171 struct zlncnt *next;
172 ino_t zlncnt;
175 * Inode cache data structures.
177 struct inoinfo {
178 struct inoinfo *i_nexthash; /* next entry in hash chain */
179 struct inoinfo *i_child, *i_sibling, *i_parentp;
180 ino_t i_number; /* inode number of this entry */
181 ino_t i_parent; /* inode number of parent */
182 ino_t i_dotdot; /* inode number of `..' */
183 size_t i_isize; /* size of inode */
184 u_int i_numblks; /* size of block array in bytes */
185 /* XXX ondisk32 */
186 int32_t i_blks[1]; /* actually longer */
187 } **inphead, **inpsort;
189 #ifndef VERBOSE_BLOCKMAP
190 #define setbmap(blkno) setbit(blockmap, blkno)
191 #define testbmap(blkno) isset(blockmap, blkno)
192 #define clrbmap(blkno) clrbit(blockmap, blkno)
193 #else
194 #define setbmap(blkno,ino) if(blkno > maxfsblock)raise(1); else blockmap[blkno] = ino
195 #define testbmap(blkno) blockmap[blkno]
196 #define clrbmap(blkno) blockmap[blkno] = 0
197 #endif
199 int Uflag; /* resolve user names */
201 #define STOP 0x01
202 #define SKIP 0x02
203 #define KEEPON 0x04
204 #define ALTERED 0x08
205 #define FOUND 0x10
207 ino_t allocino(ino_t, int);
208 int ino_to_fsba(struct lfs *, ino_t);
209 struct ufs1_dinode *ginode(ino_t);
210 struct inoinfo *getinoinfo(ino_t);
211 daddr_t lfs_ino_daddr(ino_t);
212 void clearinode(ino_t);
213 void reset_maxino(ino_t);
215 #include "fsck_vars.h"