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