xref: /netbsd-src/sbin/fsck_lfs/vars.c (revision a74e29fe24406e588e4c7ad6d03168a00d009bc1)
1*a74e29feSjoerg /* $NetBSD: vars.c,v 1.19 2020/04/03 19:36:33 joerg Exp $	 */
2ba10361aSperseant /*-
3ba10361aSperseant  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
4ba10361aSperseant  * All rights reserved.
5ba10361aSperseant  *
6ba10361aSperseant  * This code is derived from software contributed to The NetBSD Foundation
7ba10361aSperseant  * by Konrad E. Schroder <perseant@hhhh.org>.
8ba10361aSperseant  *
9ba10361aSperseant  * Redistribution and use in source and binary forms, with or without
10ba10361aSperseant  * modification, are permitted provided that the following conditions
11ba10361aSperseant  * are met:
12ba10361aSperseant  * 1. Redistributions of source code must retain the above copyright
13ba10361aSperseant  *    notice, this list of conditions and the following disclaimer.
14ba10361aSperseant  * 2. Redistributions in binary form must reproduce the above copyright
15ba10361aSperseant  *    notice, this list of conditions and the following disclaimer in the
16ba10361aSperseant  *    documentation and/or other materials provided with the distribution.
17ba10361aSperseant  *
18ba10361aSperseant  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19ba10361aSperseant  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20ba10361aSperseant  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21ba10361aSperseant  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22ba10361aSperseant  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23ba10361aSperseant  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24ba10361aSperseant  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25ba10361aSperseant  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26ba10361aSperseant  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ba10361aSperseant  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28ba10361aSperseant  * POSSIBILITY OF SUCH DAMAGE.
29ba10361aSperseant  */
309d343b25Skleink 
31369e9cadSperseant #include <sys/param.h>
32369e9cadSperseant #include <sys/time.h>
33a4fc39c0Sdholland #include <sys/mount.h>		/* XXX */
34369e9cadSperseant #include <ufs/lfs/lfs.h>
35369e9cadSperseant #include "fsck.h"
36369e9cadSperseant 
37369e9cadSperseant /* variables previously of file scope (from fsck.h) */
38369e9cadSperseant struct dups *duplist;		/* head of dup list */
39369e9cadSperseant struct dups *muldup;		/* end of unique duplicate dup block numbers */
40369e9cadSperseant 
41369e9cadSperseant struct zlncnt *zlnhead;		/* head of zero link count list */
42cb2499acSperseant struct zlncnt *orphead = NULL;	/* head of "properly orphaned" list */
43369e9cadSperseant 
44ba10361aSperseant struct lfs *fs;
45ba10361aSperseant 
4675453f28Sperseant daddr_t idaddr;			/* inode block containing ifile inode */
47369e9cadSperseant long numdirs, listmax, inplast;
48369e9cadSperseant 
49369e9cadSperseant char nflag;			/* assume a no response */
50369e9cadSperseant char yflag;			/* assume a yes response */
51369e9cadSperseant int bflag;			/* location of alternate super block */
52369e9cadSperseant int debug;			/* output debugging info */
53369e9cadSperseant int exitonfail;
54369e9cadSperseant int preen;			/* just fix normal inconsistencies */
55369e9cadSperseant char havesb;			/* superblock has been read */
56369e9cadSperseant char skipclean;			/* skip clean file systems if preening */
57369e9cadSperseant int fsmodified;			/* 1 => write done to file system */
58369e9cadSperseant int fsreadfd;			/* file descriptor for reading file system */
59369e9cadSperseant int rerun;			/* rerun fsck.  Only used in non-preen mode */
60369e9cadSperseant 
61369e9cadSperseant daddr_t maxfsblock;		/* number of blocks in the file system */
62369e9cadSperseant #ifndef VERBOSE_BLOCKMAP
63369e9cadSperseant char *blockmap;			/* ptr to primary blk allocation map */
64369e9cadSperseant #else
65369e9cadSperseant ino_t *blockmap;
66369e9cadSperseant #endif
67369e9cadSperseant ino_t maxino;			/* number of inodes in file system */
68369e9cadSperseant ino_t lastino;			/* last inode in use */
69369e9cadSperseant char *statemap;			/* ptr to inode state table */
70369e9cadSperseant char *typemap;			/* ptr to inode type table */
71369e9cadSperseant int16_t *lncntp;		/* ptr to link count table */
72369e9cadSperseant 
73369e9cadSperseant ino_t lfdir;			/* lost & found directory inode number */
74*a74e29feSjoerg int lfmode = 01700;		/* lost & found directory creation mode */
75369e9cadSperseant 
76369e9cadSperseant daddr_t n_blks;			/* number of blocks in use */
77a3ff3a30Sfvdl ino_t n_files;			/* number of files in use */
78369e9cadSperseant 
7929f1062bSperseant int no_roll_forward = 0;	/* don't roll forward */
80*a74e29feSjoerg 
81*a74e29feSjoerg struct inoinfo **inphead, **inpsort;
82