1 /* $NetBSD: fsck.h,v 1.17 2008/04/28 20:23:08 martin Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
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
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
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
60 * @(#)fsck.h 8.1 (Berkeley) 6/5/93
65 #define debug_printf warn
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 */
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.
92 struct ubufarea
*b_next
; /* free list queue */
93 struct ubufarea
*b_prev
; /* free list queue */
99 char *b_buf
; /* buffer space */
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 */
110 #define MINBUFS 5 /* minimum number of buffers required */
112 #define dirty(bp) (bp)->b_dirty = 1
113 #define initbarea(bp) \
115 (bp)->b_bno = (daddr_t)-1; \
119 DONTKNOW
, NOFIX
, FIX
, IGNORE
123 enum fixstate id_fix
; /* policy on fixing errors */
124 int (*id_func
) (struct inodesc
*); /* function to be applied to
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 */
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
168 * Linked list of inodes with zero link counts.
175 * Inode cache data structures.
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 */
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)
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
199 int Uflag
; /* resolve user names */
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"