vars.c revision 1.9 1 /* $NetBSD: vars.c,v 1.9 2005/04/14 21:15:59 perseant Exp $ */
2 /*-
3 * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Konrad E. Schroder <perseant (at) hhhh.org>.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the NetBSD
20 * Foundation, Inc. and its contributors.
21 * 4. Neither the name of The NetBSD Foundation nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #include <sys/param.h>
39 #include <sys/time.h>
40 #include <ufs/ufs/dinode.h>
41 #include <ufs/ufs/dir.h>
42 #include <sys/mount.h> /* XXX */
43 #include <ufs/lfs/lfs.h>
44 #include "fsck.h"
45
46 /* variables previously of file scope (from fsck.h) */
47 struct dups *duplist; /* head of dup list */
48 struct dups *muldup; /* end of unique duplicate dup block numbers */
49
50 struct zlncnt *zlnhead; /* head of zero link count list */
51
52 struct lfs *fs;
53
54 daddr_t idaddr; /* inode block containing ifile inode */
55 long numdirs, listmax, inplast;
56
57 long dev_bsize; /* computed value of DEV_BSIZE */
58 long secsize; /* actual disk sector size */
59 char nflag; /* assume a no response */
60 char yflag; /* assume a yes response */
61 int bflag; /* location of alternate super block */
62 int debug; /* output debugging info */
63 int exitonfail;
64 int preen; /* just fix normal inconsistencies */
65 int quiet; /* don't report clean filesystems */
66 char havesb; /* superblock has been read */
67 char skipclean; /* skip clean file systems if preening */
68 int fsmodified; /* 1 => write done to file system */
69 int fsreadfd; /* file descriptor for reading file system */
70 int rerun; /* rerun fsck. Only used in non-preen mode */
71
72 daddr_t maxfsblock; /* number of blocks in the file system */
73 #ifndef VERBOSE_BLOCKMAP
74 char *blockmap; /* ptr to primary blk allocation map */
75 #else
76 ino_t *blockmap;
77 #endif
78 ino_t maxino; /* number of inodes in file system */
79 ino_t lastino; /* last inode in use */
80 char *statemap; /* ptr to inode state table */
81 char *typemap; /* ptr to inode type table */
82 int16_t *lncntp; /* ptr to link count table */
83
84 ino_t lfdir; /* lost & found directory inode number */
85 char *lfname; /* lost & found directory name */
86 int lfmode; /* lost & found directory creation mode */
87
88 daddr_t n_blks; /* number of blocks in use */
89 ino_t n_files; /* number of files in use */
90
91 struct ufs1_dinode zino;
92