2020-04-03 22:36:32 +03:00
|
|
|
/* $NetBSD: setup.c,v 1.62 2020/04/03 19:36:33 joerg Exp $ */
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Konrad E. Schroder <perseant@hhhh.org>.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1999-03-18 05:02:18 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1980, 1986, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 14:04:22 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1999-03-18 05:02:18 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* #define DKTYPENAMES */
|
|
|
|
#define FSTYPENAMES
|
2003-03-28 11:09:52 +03:00
|
|
|
#include <sys/types.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/queue.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/disklabel.h>
|
2010-02-17 02:20:30 +03:00
|
|
|
#include <sys/disk.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <sys/file.h>
|
|
|
|
|
2013-06-06 04:54:49 +04:00
|
|
|
#define vnode uvnode
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <ufs/lfs/lfs.h>
|
2015-07-28 08:09:34 +03:00
|
|
|
#include <ufs/lfs/lfs_accessors.h>
|
2013-06-08 06:16:03 +04:00
|
|
|
#include <ufs/lfs/lfs_inode.h>
|
2003-03-28 11:09:52 +03:00
|
|
|
#undef vnode
|
1999-03-18 05:02:18 +03:00
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2010-02-17 02:20:30 +03:00
|
|
|
#include <unistd.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
#include <string.h>
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
#include <time.h>
|
2006-11-09 22:36:36 +03:00
|
|
|
#include <util.h>
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2003-03-28 11:09:52 +03:00
|
|
|
#include "bufcache.h"
|
2005-09-13 08:14:17 +04:00
|
|
|
#include "lfs_user.h"
|
2003-03-28 11:09:52 +03:00
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
#include "fsck.h"
|
|
|
|
#include "extern.h"
|
|
|
|
#include "fsutil.h"
|
|
|
|
|
2015-08-02 21:10:07 +03:00
|
|
|
static uint64_t calcmaxfilesize(unsigned);
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2015-09-01 09:15:02 +03:00
|
|
|
daddr_t *din_table;
|
2003-03-28 11:09:52 +03:00
|
|
|
SEGUSE *seg_table;
|
2000-05-16 08:55:58 +04:00
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
#ifdef DKTYPENAMES
|
2003-03-28 11:09:52 +03:00
|
|
|
int useless(void);
|
1999-03-18 05:02:18 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
useless(void)
|
|
|
|
{
|
2003-03-28 11:09:52 +03:00
|
|
|
char **foo = (char **) dktypenames;
|
|
|
|
char **bar = (char **) fscknames;
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2000-05-23 05:48:52 +04:00
|
|
|
return foo - bar;
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-09-15 07:24:09 +04:00
|
|
|
/*
|
|
|
|
* calculate the maximum file size allowed with the specified block shift.
|
|
|
|
*/
|
|
|
|
static uint64_t
|
2015-08-02 21:10:07 +03:00
|
|
|
calcmaxfilesize(unsigned bshift)
|
2004-09-15 07:24:09 +04:00
|
|
|
{
|
|
|
|
uint64_t nptr; /* number of block pointers per block */
|
|
|
|
uint64_t maxblock;
|
|
|
|
|
2015-10-03 11:29:21 +03:00
|
|
|
nptr = (1 << bshift) / LFS_BLKPTRSIZE(fs);
|
2013-06-06 04:52:50 +04:00
|
|
|
maxblock = ULFS_NDADDR + nptr + nptr * nptr + nptr * nptr * nptr;
|
2004-09-15 07:24:09 +04:00
|
|
|
|
|
|
|
return maxblock << bshift;
|
|
|
|
}
|
2005-04-12 03:19:24 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
reset_maxino(ino_t len)
|
|
|
|
{
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (debug)
|
|
|
|
pwarn("maxino reset from %lld to %lld\n", (long long)maxino,
|
|
|
|
(long long)len);
|
|
|
|
|
2006-11-09 22:36:36 +03:00
|
|
|
din_table = erealloc(din_table, len * sizeof(*din_table));
|
|
|
|
statemap = erealloc(statemap, len * sizeof(char));
|
|
|
|
typemap = erealloc(typemap, len * sizeof(char));
|
|
|
|
lncntp = erealloc(lncntp, len * sizeof(int16_t));
|
2005-04-12 03:19:24 +04:00
|
|
|
|
|
|
|
memset(din_table + maxino, 0, (len - maxino) * sizeof(*din_table));
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
memset(statemap + maxino, USTATE, (len - maxino) * sizeof(char));
|
2005-04-12 03:19:24 +04:00
|
|
|
memset(typemap + maxino, 0, (len - maxino) * sizeof(char));
|
|
|
|
memset(lncntp + maxino, 0, (len - maxino) * sizeof(int16_t));
|
|
|
|
|
2005-06-08 23:09:55 +04:00
|
|
|
maxino = len;
|
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/*
|
|
|
|
* We can't roll forward after allocating new inodes in previous
|
|
|
|
* phases, or thy would conflict (lost+found, for example, might
|
|
|
|
* disappear to be replaced by a file found in roll-forward).
|
|
|
|
*/
|
|
|
|
no_roll_forward = 1;
|
|
|
|
|
2005-04-12 03:19:24 +04:00
|
|
|
return;
|
|
|
|
}
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
int
|
2000-05-23 05:48:52 +04:00
|
|
|
setup(const char *dev)
|
1999-03-18 05:02:18 +03:00
|
|
|
{
|
2016-03-17 21:56:14 +03:00
|
|
|
#ifndef VERBOSE_BLOCKMAP
|
2003-03-28 11:09:52 +03:00
|
|
|
long bmapsize;
|
2016-03-17 21:56:14 +03:00
|
|
|
#endif
|
2003-03-28 11:09:52 +03:00
|
|
|
struct stat statb;
|
|
|
|
int doskipclean;
|
|
|
|
u_int64_t maxfilesize;
|
|
|
|
int open_flags;
|
|
|
|
struct uvnode *ivp;
|
|
|
|
struct ubuf *bp;
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
int i, isdirty;
|
|
|
|
long sn, curseg;
|
2003-03-28 11:09:52 +03:00
|
|
|
SEGUSE *sup;
|
2015-08-12 21:26:26 +03:00
|
|
|
size_t sumstart;
|
1999-03-18 05:02:18 +03:00
|
|
|
|
|
|
|
havesb = 0;
|
|
|
|
doskipclean = skipclean;
|
|
|
|
if (stat(dev, &statb) < 0) {
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pfatal("Can't stat %s: %s\n", dev, strerror(errno));
|
1999-03-18 05:02:18 +03:00
|
|
|
return (0);
|
|
|
|
}
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (!S_ISCHR(statb.st_mode) && skipclean) {
|
1999-03-18 05:02:18 +03:00
|
|
|
pfatal("%s is not a character device", dev);
|
|
|
|
if (reply("CONTINUE") == 0)
|
|
|
|
return (0);
|
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
if (nflag)
|
|
|
|
open_flags = O_RDONLY;
|
|
|
|
else
|
|
|
|
open_flags = O_RDWR;
|
|
|
|
|
|
|
|
if ((fsreadfd = open(dev, open_flags)) < 0) {
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pfatal("Can't open %s: %s\n", dev, strerror(errno));
|
1999-03-18 05:02:18 +03:00
|
|
|
return (0);
|
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
if (nflag) {
|
1999-03-18 05:02:18 +03:00
|
|
|
if (preen)
|
|
|
|
pfatal("NO WRITE ACCESS");
|
2005-04-15 01:15:59 +04:00
|
|
|
printf("** %s (NO WRITE)\n", dev);
|
|
|
|
quiet = 0;
|
|
|
|
} else if (!preen && !quiet)
|
|
|
|
printf("** %s\n", dev);
|
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
fsmodified = 0;
|
|
|
|
lfdir = 0;
|
2003-03-28 11:09:52 +03:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
/* Initialize time in case we have to write */
|
|
|
|
time(&write_time);
|
|
|
|
|
2005-04-12 03:19:24 +04:00
|
|
|
bufinit(0); /* XXX we could make a better guess */
|
2005-02-26 08:45:54 +03:00
|
|
|
fs = lfs_init(fsreadfd, bflag, idaddr, 0, debug);
|
2003-03-28 11:09:52 +03:00
|
|
|
if (fs == NULL) {
|
|
|
|
if (preen)
|
|
|
|
printf("%s: ", cdevname());
|
2008-03-17 02:17:55 +03:00
|
|
|
errexit("BAD SUPER BLOCK OR IFILE INODE NOT FOUND");
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
1999-03-18 05:02:18 +03:00
|
|
|
|
2005-04-12 03:19:24 +04:00
|
|
|
/* Resize buffer cache now that we have a superblock to guess from. */
|
2015-07-24 09:56:41 +03:00
|
|
|
bufrehash((lfs_sb_getsegtabsz(fs) + maxino / lfs_sb_getifpb(fs)) << 4);
|
2005-04-12 03:19:24 +04:00
|
|
|
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getpflags(fs) & LFS_PF_CLEAN) {
|
2003-03-28 11:09:52 +03:00
|
|
|
if (doskipclean) {
|
2005-04-15 01:15:59 +04:00
|
|
|
if (!quiet)
|
|
|
|
pwarn("%sile system is clean; not checking\n",
|
|
|
|
preen ? "f" : "** F");
|
2003-03-28 11:09:52 +03:00
|
|
|
return (-1);
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
if (!preen)
|
|
|
|
pwarn("** File system is already clean\n");
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|
2000-05-16 08:55:58 +04:00
|
|
|
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (idaddr) {
|
|
|
|
daddr_t tdaddr;
|
|
|
|
SEGSUM *sp;
|
|
|
|
FINFO *fp;
|
|
|
|
int bc;
|
|
|
|
|
|
|
|
if (debug)
|
2015-08-02 21:10:07 +03:00
|
|
|
pwarn("adjusting offset, serial for -i 0x%jx\n",
|
|
|
|
(uintmax_t)idaddr);
|
2013-06-18 22:18:57 +04:00
|
|
|
tdaddr = lfs_sntod(fs, lfs_dtosn(fs, idaddr));
|
|
|
|
if (lfs_sntod(fs, lfs_dtosn(fs, tdaddr)) == tdaddr) {
|
2015-07-24 09:59:31 +03:00
|
|
|
if (tdaddr == lfs_sb_gets0addr(fs))
|
2013-06-18 22:18:57 +04:00
|
|
|
tdaddr += lfs_btofsb(fs, LFS_LABELPAD);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
for (i = 0; i < LFS_MAXNUMSB; i++) {
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getsboff(fs, i) == tdaddr)
|
2013-06-18 22:18:57 +04:00
|
|
|
tdaddr += lfs_btofsb(fs, LFS_SBPAD);
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getsboff(fs, i) > tdaddr)
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_setoffset(fs, tdaddr);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (debug)
|
2015-07-24 09:56:41 +03:00
|
|
|
pwarn("begin with offset/serial 0x%jx/%jd\n",
|
|
|
|
(uintmax_t)lfs_sb_getoffset(fs),
|
|
|
|
(intmax_t)lfs_sb_getserial(fs));
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
while (tdaddr < idaddr) {
|
2013-06-18 22:18:57 +04:00
|
|
|
bread(fs->lfs_devvp, LFS_FSBTODB(fs, tdaddr),
|
2015-07-24 09:59:31 +03:00
|
|
|
lfs_sb_getsumsize(fs),
|
2015-03-29 22:35:58 +03:00
|
|
|
0, &bp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
sp = (SEGSUM *)bp->b_data;
|
2015-08-12 21:26:26 +03:00
|
|
|
sumstart = lfs_ss_getsumstart(fs);
|
|
|
|
if (lfs_ss_getsumsum(fs, sp) !=
|
|
|
|
cksum((char *)sp + sumstart,
|
|
|
|
lfs_sb_getsumsize(fs) - sumstart)) {
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
2006-09-01 23:52:48 +04:00
|
|
|
if (debug)
|
2015-08-02 21:10:07 +03:00
|
|
|
printf("bad cksum at %jx\n",
|
|
|
|
(uintmax_t)tdaddr);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
break;
|
|
|
|
}
|
2015-08-12 21:26:26 +03:00
|
|
|
fp = SEGSUM_FINFOBASE(fs, sp);
|
|
|
|
bc = howmany(lfs_ss_getninos(fs, sp), LFS_INOPB(fs)) <<
|
2015-08-02 21:14:16 +03:00
|
|
|
(lfs_sb_getversion(fs) > 1 ? lfs_sb_getffshift(fs) :
|
2015-07-24 09:59:31 +03:00
|
|
|
lfs_sb_getbshift(fs));
|
2015-08-12 21:26:26 +03:00
|
|
|
for (i = 0; i < lfs_ss_getnfinfo(fs, sp); i++) {
|
2015-08-12 21:27:01 +03:00
|
|
|
bc += lfs_fi_getlastlength(fs, fp) + ((lfs_fi_getnblocks(fs, fp) - 1)
|
2015-07-24 09:59:31 +03:00
|
|
|
<< lfs_sb_getbshift(fs));
|
2015-08-12 21:26:26 +03:00
|
|
|
fp = NEXT_FINFO(fs, fp);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
2013-06-18 22:18:57 +04:00
|
|
|
tdaddr += lfs_btofsb(fs, bc) + 1;
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_setoffset(fs, tdaddr);
|
2015-08-12 21:26:26 +03:00
|
|
|
lfs_sb_setserial(fs, lfs_ss_getserial(fs, sp) + 1);
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set curseg, nextseg appropriately -- inlined from
|
|
|
|
* lfs_newseg()
|
|
|
|
*/
|
2015-07-24 09:56:41 +03:00
|
|
|
curseg = lfs_dtosn(fs, lfs_sb_getoffset(fs));
|
|
|
|
lfs_sb_setcurseg(fs, lfs_sntod(fs, curseg));
|
2015-07-24 09:59:31 +03:00
|
|
|
for (sn = curseg + lfs_sb_getinterleave(fs);;) {
|
|
|
|
sn = (sn + 1) % lfs_sb_getnseg(fs);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (sn == curseg)
|
|
|
|
errx(1, "init: no clean segments");
|
|
|
|
LFS_SEGENTRY(sup, fs, sn, bp);
|
|
|
|
isdirty = sup->su_flags & SEGUSE_DIRTY;
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
|
|
|
if (!isdirty)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip superblock if necessary */
|
|
|
|
for (i = 0; i < LFS_MAXNUMSB; i++)
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getoffset(fs) == lfs_sb_getsboff(fs, i))
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_addoffset(fs, lfs_btofsb(fs, LFS_SBPAD));
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
|
|
|
|
++fs->lfs_nactive;
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_setnextseg(fs, lfs_sntod(fs, sn));
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
if (debug) {
|
2015-08-02 21:10:07 +03:00
|
|
|
pwarn("offset = 0x%" PRIx64 ", serial = %" PRIu64 "\n",
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_getoffset(fs), lfs_sb_getserial(fs));
|
2015-08-02 21:10:07 +03:00
|
|
|
pwarn("curseg = %" PRIx64 ", nextseg = %" PRIx64 "\n",
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_getcurseg(fs), lfs_sb_getnextseg(fs));
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!nflag && !skipclean) {
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_setidaddr(fs, idaddr);
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
fsmodified = 1;
|
|
|
|
sbdirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-23 05:48:52 +04:00
|
|
|
if (debug) {
|
2015-07-24 09:56:41 +03:00
|
|
|
pwarn("idaddr = 0x%jx\n", idaddr ? (uintmax_t)idaddr :
|
|
|
|
(uintmax_t)lfs_sb_getidaddr(fs));
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pwarn("dev_bsize = %lu\n", dev_bsize);
|
2015-07-24 09:56:41 +03:00
|
|
|
pwarn("lfs_bsize = %lu\n", (unsigned long) lfs_sb_getbsize(fs));
|
|
|
|
pwarn("lfs_fsize = %lu\n", (unsigned long) lfs_sb_getfsize(fs));
|
|
|
|
pwarn("lfs_frag = %lu\n", (unsigned long) lfs_sb_getfrag(fs));
|
2015-07-24 09:59:31 +03:00
|
|
|
pwarn("lfs_inopb = %lu\n", (unsigned long) lfs_sb_getinopb(fs));
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|
2015-08-02 21:14:16 +03:00
|
|
|
if (lfs_sb_getversion(fs) == 1)
|
2015-08-02 20:56:24 +03:00
|
|
|
maxfsblock = lfs_blkstofrags(fs, lfs_sb_getsize(fs));
|
2003-03-28 11:09:52 +03:00
|
|
|
else
|
2015-07-24 09:56:41 +03:00
|
|
|
maxfsblock = lfs_sb_getsize(fs);
|
2015-07-24 09:59:31 +03:00
|
|
|
maxfilesize = calcmaxfilesize(lfs_sb_getbshift(fs));
|
2015-07-24 09:56:41 +03:00
|
|
|
if (/* lfs_sb_getminfree(fs) < 0 || */ lfs_sb_getminfree(fs) > 99) {
|
|
|
|
pfatal("IMPOSSIBLE MINFREE=%u IN SUPERBLOCK",
|
|
|
|
lfs_sb_getminfree(fs));
|
1999-03-18 05:02:18 +03:00
|
|
|
if (reply("SET TO DEFAULT") == 1) {
|
2015-07-24 09:56:41 +03:00
|
|
|
lfs_sb_setminfree(fs, 10);
|
1999-03-18 05:02:18 +03:00
|
|
|
sbdirty();
|
|
|
|
}
|
|
|
|
}
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getbmask(fs) != lfs_sb_getbsize(fs) - 1) {
|
|
|
|
pwarn("INCORRECT BMASK=0x%jx IN SUPERBLOCK (SHOULD BE 0x%x)",
|
|
|
|
(uintmax_t)lfs_sb_getbmask(fs),
|
|
|
|
lfs_sb_getbsize(fs) - 1);
|
|
|
|
lfs_sb_setbmask(fs, lfs_sb_getbsize(fs) - 1);
|
1999-03-18 05:02:18 +03:00
|
|
|
if (preen)
|
|
|
|
printf(" (FIXED)\n");
|
|
|
|
if (preen || reply("FIX") == 1) {
|
|
|
|
sbdirty();
|
|
|
|
}
|
|
|
|
}
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getffmask(fs) != lfs_sb_getfsize(fs) - 1) {
|
|
|
|
pwarn("INCORRECT FFMASK=0x%jx IN SUPERBLOCK (SHOULD BE 0x%x)",
|
|
|
|
(uintmax_t)lfs_sb_getffmask(fs),
|
|
|
|
lfs_sb_getfsize(fs) - 1);
|
|
|
|
lfs_sb_setffmask(fs, lfs_sb_getfsize(fs) - 1);
|
1999-03-18 05:02:18 +03:00
|
|
|
if (preen)
|
|
|
|
printf(" (FIXED)\n");
|
|
|
|
if (preen || reply("FIX") == 1) {
|
|
|
|
sbdirty();
|
|
|
|
}
|
|
|
|
}
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getfbmask(fs) != (1U << lfs_sb_getfbshift(fs)) - 1) {
|
|
|
|
pwarn("INCORRECT FBMASK=0x%jx IN SUPERBLOCK (SHOULD BE 0x%x)",
|
|
|
|
(uintmax_t)lfs_sb_getfbmask(fs),
|
|
|
|
(1U << lfs_sb_getfbshift(fs)) - 1);
|
|
|
|
lfs_sb_setfbmask(fs, (1U << lfs_sb_getfbshift(fs)) - 1);
|
2003-03-28 11:09:52 +03:00
|
|
|
if (preen)
|
|
|
|
printf(" (FIXED)\n");
|
|
|
|
if (preen || reply("FIX") == 1) {
|
|
|
|
sbdirty();
|
|
|
|
}
|
|
|
|
}
|
2015-07-24 09:59:31 +03:00
|
|
|
if (lfs_sb_getmaxfilesize(fs) != maxfilesize) {
|
2001-01-05 05:02:57 +03:00
|
|
|
pwarn(
|
2015-08-02 21:10:07 +03:00
|
|
|
"INCORRECT MAXFILESIZE=%ju IN SUPERBLOCK (SHOULD BE %ju WITH BSHIFT %u)",
|
|
|
|
(uintmax_t) lfs_sb_getmaxfilesize(fs),
|
|
|
|
(uintmax_t) maxfilesize, lfs_sb_getbshift(fs));
|
2000-05-23 05:48:52 +04:00
|
|
|
if (preen)
|
|
|
|
printf(" (FIXED)\n");
|
|
|
|
if (preen || reply("FIX") == 1) {
|
2015-07-24 09:59:31 +03:00
|
|
|
lfs_sb_setmaxfilesize(fs, maxfilesize);
|
2000-05-23 05:48:52 +04:00
|
|
|
sbdirty();
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|
2000-05-23 05:48:52 +04:00
|
|
|
}
|
2015-09-01 09:12:33 +03:00
|
|
|
if (lfs_sb_getmaxsymlinklen(fs) != LFS_MAXSYMLINKLEN(fs)) {
|
2015-07-24 09:59:31 +03:00
|
|
|
pwarn("INCORRECT MAXSYMLINKLEN=%d IN SUPERBLOCK (SHOULD BE %zu)",
|
2015-09-01 09:12:33 +03:00
|
|
|
lfs_sb_getmaxsymlinklen(fs), LFS_MAXSYMLINKLEN(fs));
|
|
|
|
lfs_sb_setmaxsymlinklen(fs, LFS_MAXSYMLINKLEN(fs));
|
2000-05-23 05:48:52 +04:00
|
|
|
if (preen)
|
|
|
|
printf(" (FIXED)\n");
|
|
|
|
if (preen || reply("FIX") == 1) {
|
|
|
|
sbdirty();
|
1999-03-18 05:02:18 +03:00
|
|
|
}
|
2000-05-23 05:48:52 +04:00
|
|
|
}
|
2003-03-28 11:09:52 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read in the Ifile; we'll be using it a lot.
|
|
|
|
* XXX If the Ifile is corrupted we are in bad shape. We need to
|
|
|
|
* XXX run through the segment headers of the entire disk to
|
|
|
|
* XXX reconstruct the inode table, then pretend all segments are
|
|
|
|
* XXX dirty while we do the rest.
|
|
|
|
*/
|
|
|
|
ivp = fs->lfs_ivnode;
|
2015-09-01 09:08:37 +03:00
|
|
|
maxino = ((lfs_dino_getsize(fs, VTOI(ivp)->i_din) - (lfs_sb_getcleansz(fs) + lfs_sb_getsegtabsz(fs))
|
2015-07-24 09:56:41 +03:00
|
|
|
* lfs_sb_getbsize(fs)) / lfs_sb_getbsize(fs)) * lfs_sb_getifpb(fs);
|
2003-03-28 11:09:52 +03:00
|
|
|
if (debug)
|
Various improvements to fsck_lfs, to wit:
* Add lfs_balloc capability to the lfs library.
* Extend the Ifile if we run out of free inodes when creating lost+found.
* Don't roll forward if we have allocated a lost+found, to avoid
conflicts when adding new files in roll-forward.
* Make some messages slightly more verbose (e.g. include inode number,
and use pwarn() instead of printf() so the messages include the device
name when preening).
* Change superblock detection/avoidance to use the offset table in the
primary superblock, rather than looking at the contents.
* Be more verbose about various operations when passed the -d flag,
especially roll-forward.
* Be more careful about dirops during roll forward, since the cleaner can
sometimes write blocks from dirop vnodes. Detect and avoid this problem.
* Always check the free list, even if given -i; if we're going to write
it we have to check it first.
* Mark inodes dirty when blocks are found during roll forward, so the
inodes are written with the new block locations.
* Update size of inodes if blocks beyond EOF are found during roll
forward.
* Fix segment accounting for blocks and inodes found during roll
forward.
* Report statistics on roll forward: how many new/deleted/moved files
and how many updated blocks (or "nothing new").
* Don't care if the device being checked is really a device, if we have
been passed the -f flag (to facilitate automated testing).
* When writing to the disk, use the current time in the segment headers
rathern than time 0.
* When passed the -i flag, locate the partial segment containing the
Ifile inode and use that to calculate lfs_offset, lfs_curseg,
lfs_nextseg. (Again for automated testing.)
2006-07-19 03:37:13 +04:00
|
|
|
pwarn("maxino = %llu\n", (unsigned long long)maxino);
|
2015-09-01 09:08:37 +03:00
|
|
|
for (i = 0; i < lfs_dino_getsize(fs, VTOI(ivp)->i_din); i += lfs_sb_getbsize(fs)) {
|
2015-07-24 09:59:31 +03:00
|
|
|
bread(ivp, i >> lfs_sb_getbshift(fs), lfs_sb_getbsize(fs), 0, &bp);
|
2003-03-28 11:09:52 +03:00
|
|
|
/* XXX check B_ERROR */
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
/*
|
|
|
|
* allocate and initialize the necessary maps
|
|
|
|
*/
|
2006-11-09 22:36:36 +03:00
|
|
|
din_table = ecalloc(maxino, sizeof(*din_table));
|
2015-07-24 09:59:31 +03:00
|
|
|
seg_table = ecalloc(lfs_sb_getnseg(fs), sizeof(SEGUSE));
|
2003-03-28 11:09:52 +03:00
|
|
|
/* Get segment flags */
|
2015-07-24 09:59:31 +03:00
|
|
|
for (i = 0; i < lfs_sb_getnseg(fs); i++) {
|
2003-03-28 11:09:52 +03:00
|
|
|
LFS_SEGENTRY(sup, fs, i, bp);
|
|
|
|
seg_table[i].su_flags = sup->su_flags & ~SEGUSE_ACTIVE;
|
2003-03-29 03:09:43 +03:00
|
|
|
if (preen)
|
|
|
|
seg_table[i].su_nbytes = sup->su_nbytes;
|
2007-10-09 01:39:49 +04:00
|
|
|
brelse(bp, 0);
|
2003-03-28 11:09:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize Ifile entry */
|
2015-09-01 09:12:04 +03:00
|
|
|
din_table[LFS_IFILE_INUM] = lfs_sb_getidaddr(fs);
|
2015-08-12 21:28:00 +03:00
|
|
|
seg_table[lfs_dtosn(fs, lfs_sb_getidaddr(fs))].su_nbytes += DINOSIZE(fs);
|
2003-03-28 11:09:52 +03:00
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
#ifndef VERBOSE_BLOCKMAP
|
|
|
|
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
|
2006-11-09 22:36:36 +03:00
|
|
|
blockmap = ecalloc(bmapsize, sizeof(char));
|
1999-03-18 05:02:18 +03:00
|
|
|
#else
|
2006-11-09 22:36:36 +03:00
|
|
|
blockmap = ecalloc(maxfsblock, sizeof(ino_t));
|
1999-03-18 05:02:18 +03:00
|
|
|
#endif
|
2006-11-09 22:36:36 +03:00
|
|
|
statemap = ecalloc(maxino, sizeof(char));
|
|
|
|
typemap = ecalloc(maxino, sizeof(char));
|
|
|
|
lncntp = ecalloc(maxino, sizeof(int16_t));
|
2003-03-29 03:09:43 +03:00
|
|
|
|
|
|
|
if (preen) {
|
2015-07-24 09:56:41 +03:00
|
|
|
n_files = lfs_sb_getnfiles(fs);
|
|
|
|
n_blks = lfs_sb_getdsize(fs) - lfs_sb_getbfree(fs);
|
2003-03-29 03:09:43 +03:00
|
|
|
numdirs = maxino;
|
|
|
|
inplast = 0;
|
|
|
|
listmax = numdirs + 10;
|
2006-11-09 22:36:36 +03:00
|
|
|
inpsort = ecalloc(listmax, sizeof(struct inoinfo *));
|
|
|
|
inphead = ecalloc(numdirs, sizeof(struct inoinfo *));
|
2003-03-29 03:09:43 +03:00
|
|
|
}
|
|
|
|
|
1999-03-18 05:02:18 +03:00
|
|
|
return (1);
|
|
|
|
|
|
|
|
ckfini(0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|