Reviewed by: rwatson, bp
Approved by: rwatson Obtained from: NetBSD-current source tree The beginnings of the fsck wrappers stuff from NetBSD. This particular commit brings a newly repo-copied sbin/fsck_ffs/ (from sbin/fsck/) into fsck wrappers mode. A quick overview (the code reflects this): * Documentation changed to reflect fsck_ffs instead of fsck * Simply acts on a single filesystem, doesn't try to do any multiple filesystem magic - this is done by the fsck wrappers now And then specific to fsck_ffs: * link to /sbin/fsck_4.2bsd and /sbin/fsck_ufs. This is because right now the filesystem is of type ufs not ffs, and that during autodetection the labeltype rather than the VFS type is used - this is because when doing an autodetection of filesystem type in the fsck wrapper program, it does not have any link between label type (4.2bsd, vinum, etc) and VFS string. Note that this shouldn't break a build since the required buildworld Makefile magic and import of the fsck wrapper code into src/sbin/fsck/ will happen in a seperate commit.
This commit is contained in:
parent
410d456c0b
commit
336dc694cc
@ -1,9 +1,12 @@
|
||||
# $FreeBSD$
|
||||
# @(#)Makefile 8.2 (Berkeley) 4/27/95
|
||||
|
||||
PROG= fsck
|
||||
MAN8= fsck.8
|
||||
PROG= fsck_ffs
|
||||
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs
|
||||
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
|
||||
MAN8= fsck_ffs.8
|
||||
SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
|
||||
pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c
|
||||
pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c
|
||||
CFLAGS+=-W
|
||||
.PATH: ${.CURDIR}/../../sys/ufs/ffs
|
||||
|
||||
|
@ -29,11 +29,12 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" @(#)0.t 8.1 (Berkeley) 6/8/93
|
||||
.\"
|
||||
.if n .ND
|
||||
.TL
|
||||
Fsck \- The UNIX\(dg File System Check Program
|
||||
Fsck_ffs \- The UNIX\(dg File System Check Program
|
||||
.EH 'SMM:3-%''The \s-2UNIX\s+2 File System Check Program'
|
||||
.OH 'The \s-2UNIX\s+2 File System Check Program''SMM:3-%'
|
||||
.AU
|
||||
@ -61,15 +62,15 @@ Arpa Order No. 4031 monitored by Naval Electronic System Command under
|
||||
Contract No. N00039-82-C-0235.
|
||||
.FE
|
||||
This document reflects the use of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
with the 4.2BSD and 4.3BSD file system organization. This
|
||||
is a revision of the
|
||||
original paper written by
|
||||
T. J. Kowalski.
|
||||
.PP
|
||||
File System Check Program (\fIfsck\fR)
|
||||
File System Check Program (\fIfsck_ffs\fR)
|
||||
is an interactive file system check and repair program.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
uses the redundant structural information in the
|
||||
UNIX file system to perform several consistency checks.
|
||||
If an inconsistency is detected, it is reported
|
||||
@ -79,7 +80,7 @@ These inconsistencies result from the permanent interruption
|
||||
of the file system updates, which are performed every
|
||||
time a file is modified.
|
||||
Unless there has been a hardware failure,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is able to repair corrupted file systems
|
||||
using procedures based upon the order in which UNIX honors
|
||||
these file system update requests.
|
||||
@ -89,7 +90,7 @@ of the file system,
|
||||
to discuss the possible causes of file system corruption,
|
||||
and to present the corrective actions implemented
|
||||
by
|
||||
.I fsck.
|
||||
.I fsck_ffs.
|
||||
Both the program and the interaction between the
|
||||
program and the operator are described.
|
||||
.sp 2
|
||||
|
@ -29,6 +29,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" @(#)1.t 8.1 (Berkeley) 6/5/93
|
||||
.\"
|
||||
.ds RH Introduction
|
||||
@ -36,7 +37,7 @@
|
||||
Introduction
|
||||
.PP
|
||||
This document reflects the use of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
with the 4.2BSD and 4.3BSD file system organization. This
|
||||
is a revision of the
|
||||
original paper written by
|
||||
@ -49,7 +50,7 @@ This precautionary measure helps to insure
|
||||
a reliable environment for file storage on disk.
|
||||
If an inconsistency is discovered,
|
||||
corrective action must be taken.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
runs in two modes.
|
||||
Normally it is run non-interactively by the system after
|
||||
a normal boot.
|
||||
@ -57,11 +58,11 @@ When running in this mode,
|
||||
it will only make changes to the file system that are known
|
||||
to always be correct.
|
||||
If an unexpected inconsistency is found
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will exit with a non-zero exit status,
|
||||
leaving the system running single-user.
|
||||
Typically the operator then runs
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
interactively.
|
||||
When running in this mode,
|
||||
each problem is listed followed by a suggested corrective action.
|
||||
@ -77,7 +78,7 @@ then describes file system corruption (the storm).
|
||||
Finally,
|
||||
the set of deterministic corrective actions
|
||||
used by
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
(the Coast Guard
|
||||
to the rescue) is presented.
|
||||
.ds RH Overview of the File System
|
||||
|
@ -29,6 +29,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" @(#)2.t 8.1 (Berkeley) 6/5/93
|
||||
.\"
|
||||
.ds RH Overview of the file system
|
||||
|
@ -29,6 +29,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" @(#)3.t 8.1 (Berkeley) 6/5/93
|
||||
.\"
|
||||
.ds RH Fixing corrupted file systems
|
||||
@ -66,19 +67,19 @@ on a disk pack, or as blatant as a non-functional disk-controller.
|
||||
Detecting and correcting corruption
|
||||
.PP
|
||||
Normally
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is run non-interactively.
|
||||
In this mode it will only fix
|
||||
corruptions that are expected to occur from an unclean halt.
|
||||
These actions are a proper subset of the actions that
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will take when it is running interactively.
|
||||
Throughout this paper we assume that
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is being run interactively,
|
||||
and all possible errors can be encountered.
|
||||
When an inconsistency is discovered in this mode,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
reports the inconsistency for the operator to
|
||||
chose a corrective action.
|
||||
.PP
|
||||
@ -95,10 +96,10 @@ or computed from other known values.
|
||||
The file system
|
||||
.B must
|
||||
be in a quiescent state when
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is run,
|
||||
since
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is a multi-pass program.
|
||||
.PP
|
||||
In the following sections,
|
||||
@ -126,54 +127,54 @@ number of blocks used by the super-block
|
||||
and the number of blocks used by the list of inodes.
|
||||
The file-system size and layout information
|
||||
are the most critical pieces of information for
|
||||
.I fsck .
|
||||
.I fsck_ffs .
|
||||
While there is no way to actually check these sizes,
|
||||
since they are statically determined by
|
||||
.I newfs ,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
can check that these sizes are within reasonable bounds.
|
||||
All other file system checks require that these sizes be correct.
|
||||
If
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
detects corruption in the static parameters of the default super-block,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
requests the operator to specify the location of an alternate super-block.
|
||||
.NH 2
|
||||
Free block checking
|
||||
.PP
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
checks that all the blocks
|
||||
marked as free in the cylinder group block maps
|
||||
are not claimed by any files.
|
||||
When all the blocks have been initially accounted for,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
checks that
|
||||
the number of free blocks
|
||||
plus the number of blocks claimed by the inodes
|
||||
equals the total number of blocks in the file system.
|
||||
.PP
|
||||
If anything is wrong with the block allocation maps,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will rebuild them,
|
||||
based on the list it has computed of allocated blocks.
|
||||
.PP
|
||||
The summary information associated with the super-block
|
||||
counts the total number of free blocks within the file system.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
compares this count to the
|
||||
number of free blocks it found within the file system.
|
||||
If the two counts do not agree, then
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
replaces the incorrect count in the summary information
|
||||
by the actual free-block count.
|
||||
.PP
|
||||
The summary information
|
||||
counts the total number of free inodes within the file system.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
compares this count to the number
|
||||
of free inodes it found within the file system.
|
||||
If the two counts do not agree, then
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
replaces the incorrect count in the
|
||||
summary information by the actual free-inode count.
|
||||
.NH 2
|
||||
@ -207,7 +208,7 @@ This last state suggests an incorrectly formated inode.
|
||||
An inode can get in this state if
|
||||
bad data is written into the inode list.
|
||||
The only possible corrective action is for
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is to clear the inode.
|
||||
.NH 2
|
||||
Inode links
|
||||
@ -215,7 +216,7 @@ Inode links
|
||||
Each inode counts the
|
||||
total number of directory entries
|
||||
linked to the inode.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
verifies the link count of each inode
|
||||
by starting at the root of the file system,
|
||||
and descending through the directory structure.
|
||||
@ -226,7 +227,7 @@ If the stored link count is non-zero and the actual
|
||||
link count is zero,
|
||||
then no directory entry appears for the inode.
|
||||
If this happens,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will place the disconnected file in the
|
||||
.I lost+found
|
||||
directory.
|
||||
@ -234,7 +235,7 @@ If the stored and actual link counts are non-zero and unequal,
|
||||
a directory entry may have been added or removed without the inode being
|
||||
updated.
|
||||
If this happens,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
replaces the incorrect stored link count by the actual link count.
|
||||
.PP
|
||||
Each inode contains a list,
|
||||
@ -245,7 +246,7 @@ Since indirect blocks are owned by an inode,
|
||||
inconsistencies in indirect blocks directly
|
||||
affect the inode that owns it.
|
||||
.PP
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
compares each block number claimed by an inode
|
||||
against a list of already allocated blocks.
|
||||
If another inode already claims a block number,
|
||||
@ -255,7 +256,7 @@ Otherwise, the list of allocated blocks
|
||||
is updated to include the block number.
|
||||
.PP
|
||||
If there are any duplicate blocks,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will perform a partial second
|
||||
pass over the inode list
|
||||
to find the inode of the duplicated block.
|
||||
@ -270,12 +271,12 @@ then the inode with the earliest
|
||||
modify time is usually incorrect,
|
||||
and should be cleared.
|
||||
If this happens,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
prompts the operator to clear both inodes.
|
||||
The operator must decide which one should be kept
|
||||
and which one should be cleared.
|
||||
.PP
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
checks the range of each block number claimed by an inode.
|
||||
If the block number is
|
||||
lower than the first data block in the file system,
|
||||
@ -286,7 +287,7 @@ Many bad blocks in an inode are usually caused by
|
||||
an indirect block that was not written to the file system,
|
||||
a condition which can only occur if there has been a hardware failure.
|
||||
If an inode contains bad block numbers,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
prompts the operator to clear it.
|
||||
.NH 2
|
||||
Inode data size
|
||||
@ -296,12 +297,12 @@ that it contains.
|
||||
The number of actual data blocks
|
||||
is the sum of the allocated data blocks
|
||||
and the indirect blocks.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
computes the actual number of data blocks
|
||||
and compares that block count against
|
||||
the actual number of blocks the inode claims.
|
||||
If an inode contains an incorrect count
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
prompts the operator to fix it.
|
||||
.PP
|
||||
Each inode contains a thirty-two bit size field.
|
||||
@ -325,7 +326,7 @@ contain the information stored in a file;
|
||||
symbolic link data blocks
|
||||
contain the path name stored in a link.
|
||||
Directory data blocks contain directory entries.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
can only check the validity of directory data blocks.
|
||||
.PP
|
||||
Each directory data block is checked for
|
||||
@ -339,27 +340,27 @@ and directories that are not attached to the file system.
|
||||
If the inode number in a directory data block
|
||||
references an unallocated inode,
|
||||
then
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will remove that directory entry.
|
||||
Again,
|
||||
this condition can only arise when there has been a hardware failure.
|
||||
.PP
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
also checks for directories with unallocated blocks (holes).
|
||||
Such directories should never be created.
|
||||
When found,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will prompt the user to adjust the length of the offending directory
|
||||
which is done by shortening the size of the directory to the end of the
|
||||
last allocated block preceeding the hole.
|
||||
Unfortunately, this means that another Phase 1 run has to be done.
|
||||
.I Fsck
|
||||
will remind the user to rerun fsck after repairing a
|
||||
.I Fsck_ffs
|
||||
will remind the user to rerun fsck_ffs after repairing a
|
||||
directory containing an unallocated block.
|
||||
.PP
|
||||
If a directory entry inode number references
|
||||
outside the inode list, then
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will remove that directory entry.
|
||||
This condition occurs if bad data is written into a directory data block.
|
||||
.PP
|
||||
@ -379,19 +380,19 @@ data block if the directory is the
|
||||
root directory).
|
||||
If the directory inode numbers are
|
||||
incorrect,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will replace them with the correct values.
|
||||
If there are multiple hard links to a directory,
|
||||
the first one encountered is considered the real parent
|
||||
to which ``\fB..\fP'' should point;
|
||||
\fIfsck\fP recommends deletion for the subsequently discovered names.
|
||||
\fIfsck_ffs\fP recommends deletion for the subsequently discovered names.
|
||||
.NH 2
|
||||
File system connectivity
|
||||
.PP
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
checks the general connectivity of the file system.
|
||||
If directories are not linked into the file system, then
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
links the directory back into the file system in the
|
||||
.I lost+found
|
||||
directory.
|
||||
@ -412,9 +413,9 @@ Contract No. N00039-82-C-0235. (Kirk McKusick, July 1983)
|
||||
.PP
|
||||
I would like to thank Larry A. Wehr for advice that lead
|
||||
to the first version of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
and Rick B. Brandt for adapting
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
to
|
||||
UNIX/TS. (T. Kowalski, July 1979)
|
||||
.sp 2
|
||||
@ -448,5 +449,5 @@ UNIX Implementation,
|
||||
.I "The Bell System Technical Journal\^"
|
||||
.B 57 ,
|
||||
6 (July-August 1978, Part 2), pp. 1931-46.
|
||||
.ds RH Appendix A \- Fsck Error Conditions
|
||||
.ds RH Appendix A \- Fsck_ffs Error Conditions
|
||||
.bp
|
||||
|
@ -29,22 +29,23 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\" @(#)4.t 8.1 (Berkeley) 6/5/93
|
||||
.\"
|
||||
.ds RH Appendix A \- Fsck Error Conditions
|
||||
.ds RH Appendix A \- Fsck_ffs Error Conditions
|
||||
.NH
|
||||
Appendix A \- Fsck Error Conditions
|
||||
Appendix A \- Fsck_ffs Error Conditions
|
||||
.NH 2
|
||||
Conventions
|
||||
.PP
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
is
|
||||
a multi-pass file system check program.
|
||||
Each file system pass invokes a different Phase of the
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
program.
|
||||
After the initial setup,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
performs successive Phases over each file system,
|
||||
checking blocks and sizes,
|
||||
path-names,
|
||||
@ -55,7 +56,7 @@ and the map of free blocks,
|
||||
and performs some cleanup.
|
||||
.LP
|
||||
Normally
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
is run non-interactively to
|
||||
.I preen
|
||||
the file systems after an unclean halt.
|
||||
@ -63,15 +64,15 @@ While preen'ing a file system,
|
||||
it will only fix corruptions that are expected
|
||||
to occur from an unclean halt.
|
||||
These actions are a proper subset of the actions that
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will take when it is running interactively.
|
||||
Throughout this appendix many errors have several options
|
||||
that the operator can take.
|
||||
When an inconsistency is detected,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
reports the error condition to the operator.
|
||||
If a response is required,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
prints a prompt message and
|
||||
waits for a response.
|
||||
When preen'ing most errors are fatal.
|
||||
@ -83,7 +84,7 @@ the possible responses, and the related error conditions.
|
||||
The error conditions are organized by the
|
||||
.I Phase
|
||||
of the
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
program in which they can occur.
|
||||
The error conditions that may occur
|
||||
in more than one Phase
|
||||
@ -109,12 +110,12 @@ when the file system is being preen'ed.
|
||||
.B "\fIC\fP option?"
|
||||
.br
|
||||
\fIC\fP is not a legal option to
|
||||
.I fsck ;
|
||||
.I fsck_ffs ;
|
||||
legal options are \-b, \-c, \-y, \-n, and \-p.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
terminates on this error condition.
|
||||
See the
|
||||
.I fsck (8)
|
||||
.I fsck_ffs (8)
|
||||
manual entry for further detail.
|
||||
.sp
|
||||
.LP
|
||||
@ -126,11 +127,11 @@ manual entry for further detail.
|
||||
.br
|
||||
.B "cannot alloc NNN bytes for lncntp"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request for memory for its virtual
|
||||
memory tables failed.
|
||||
This should never happen.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
terminates on this error condition.
|
||||
See a guru.
|
||||
.sp
|
||||
@ -141,17 +142,17 @@ The file system checklist file
|
||||
\fIF\fP (usually
|
||||
.I /etc/fstab )
|
||||
can not be opened for reading.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
terminates on this error condition.
|
||||
Check access modes of \fIF\fP.
|
||||
.sp
|
||||
.LP
|
||||
.B "Can't stat root"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request for statistics about the root directory ``/'' failed.
|
||||
This should never happen.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
terminates on this error condition.
|
||||
See a guru.
|
||||
.sp
|
||||
@ -160,7 +161,7 @@ See a guru.
|
||||
.br
|
||||
.B "Can't make sense out of name \fIF\fP"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request for statistics about the file system \fIF\fP failed.
|
||||
When running manually,
|
||||
it ignores this file system
|
||||
@ -170,7 +171,7 @@ Check access modes of \fIF\fP.
|
||||
.LP
|
||||
.B "Can't open \fIF\fP"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request attempt to open the file system \fIF\fP failed.
|
||||
When running manually, it ignores this file system
|
||||
and continues checking the next file system given.
|
||||
@ -180,7 +181,7 @@ Check access modes of \fIF\fP.
|
||||
.B "\fIF\fP: (NO WRITE)"
|
||||
.br
|
||||
Either the \-n flag was specified or
|
||||
.I fsck 's
|
||||
.I fsck_ffs 's
|
||||
attempt to open the file system \fIF\fP for writing failed.
|
||||
When running manually,
|
||||
all the diagnostics are printed out,
|
||||
@ -190,7 +191,7 @@ but no modifications are attempted to fix them.
|
||||
.B "file is not a block or character device; OK"
|
||||
.br
|
||||
You have given
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
a regular file name by mistake.
|
||||
Check the type of the file specified.
|
||||
.LP
|
||||
@ -272,9 +273,9 @@ and will be followed by the message:
|
||||
.br
|
||||
.B "\fIF\fP: BAD SUPER BLOCK: \fIB\fP"
|
||||
.br
|
||||
.B "USE -b OPTION TO FSCK TO SPECIFY LOCATION OF AN ALTERNATE"
|
||||
.B "USE -b OPTION TO FSCK_FFS TO SPECIFY LOCATION OF AN ALTERNATE"
|
||||
.br
|
||||
.B "SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck(8)."
|
||||
.B "SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck_ffs(8)."
|
||||
.br
|
||||
The super block has been corrupted.
|
||||
An alternative super block must be selected from among those
|
||||
@ -287,7 +288,7 @@ specifying \-b 32 is a good first choice.
|
||||
.LP
|
||||
.B "INTERNAL INCONSISTENCY: \fIM\fP"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
has had an internal panic, whose message is specified as \fIM\fP.
|
||||
This should never happen.
|
||||
See a guru.
|
||||
@ -295,7 +296,7 @@ See a guru.
|
||||
.LP
|
||||
.B "CAN NOT SEEK: BLK \fIB\fP (CONTINUE)"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request for moving to a specified block number \fIB\fP in
|
||||
the file system failed.
|
||||
This should never happen.
|
||||
@ -308,11 +309,11 @@ Often,
|
||||
however the problem will persist.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
If the block was part of the virtual memory buffer
|
||||
cache,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will terminate with the message ``Fatal I/O error''.
|
||||
.IP NO
|
||||
terminate the program.
|
||||
@ -320,7 +321,7 @@ terminate the program.
|
||||
.LP
|
||||
.B "CAN NOT READ: BLK \fIB\fP (CONTINUE)"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request for reading a specified block number \fIB\fP in
|
||||
the file system failed.
|
||||
This should never happen.
|
||||
@ -335,7 +336,7 @@ It will retry the read and print out the message:
|
||||
.br
|
||||
where \fIN\fP indicates the sectors that could not be read.
|
||||
If
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
ever tries to write back one of the blocks on which the read failed
|
||||
it will print the message:
|
||||
.br
|
||||
@ -345,11 +346,11 @@ where \fIN\fP indicates the sector that was written with zero's.
|
||||
If the disk is experiencing hardware problems, the problem will persist.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
If the block was part of the virtual memory buffer
|
||||
cache,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will terminate with the message ``Fatal I/O error''.
|
||||
.IP NO
|
||||
terminate the program.
|
||||
@ -357,7 +358,7 @@ terminate the program.
|
||||
.LP
|
||||
.B "CAN NOT WRITE: BLK \fIB\fP (CONTINUE)"
|
||||
.br
|
||||
.I Fsck 's
|
||||
.I Fsck_ffs 's
|
||||
request for writing a specified block number \fIB\fP
|
||||
in the file system failed.
|
||||
The disk is write-protected;
|
||||
@ -376,11 +377,11 @@ where \fIN\fP indicates the sectors that could not be written.
|
||||
If the disk is experiencing hardware problems, the problem will persist.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
If the block was part of the virtual memory buffer
|
||||
cache,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will terminate with the message ``Fatal I/O error''.
|
||||
.IP NO
|
||||
terminate the program.
|
||||
@ -390,7 +391,7 @@ terminate the program.
|
||||
.br
|
||||
An internal error has attempted to read non-existent inode \fIDDD\fP.
|
||||
This error causes
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
to exit.
|
||||
See a guru.
|
||||
.NH 2
|
||||
@ -428,13 +429,13 @@ ignore this error condition.
|
||||
.LP
|
||||
.B "PARTIALLY TRUNCATED INODE I=\fII\fP (SALVAGE)"
|
||||
.br
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
has found inode \fII\fP whose size is shorter than the number of
|
||||
blocks allocated to it.
|
||||
This condition should only occur if the system crashes while in the
|
||||
midst of truncating a file.
|
||||
When preen'ing the file system,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
completes the truncation to the specified size.
|
||||
.LP
|
||||
Possible responses to SALVAGE are:
|
||||
@ -447,18 +448,18 @@ ignore this error condition.
|
||||
.B "LINK COUNT TABLE OVERFLOW (CONTINUE)"
|
||||
.br
|
||||
An internal table for
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
containing allocated inodes with a link count of
|
||||
zero cannot allocate more memory.
|
||||
Increase the virtual memory for
|
||||
.I fsck .
|
||||
.I fsck_ffs .
|
||||
.LP
|
||||
Possible responses to the CONTINUE prompt are:
|
||||
.IP YES
|
||||
continue with the program.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
If another allocated inode with a zero link count is found,
|
||||
this error condition is repeated.
|
||||
@ -493,7 +494,7 @@ ignore the rest of the blocks in this inode
|
||||
and continue checking with the next inode in the file system.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
.IP NO
|
||||
terminate the program.
|
||||
@ -502,9 +503,9 @@ terminate the program.
|
||||
.B "BAD STATE DDD TO BLKERR"
|
||||
.br
|
||||
An internal error has scrambled
|
||||
.I fsck 's
|
||||
.I fsck_ffs 's
|
||||
state map to have the impossible value \fIDDD\fP.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
exits immediately.
|
||||
See a guru.
|
||||
.sp
|
||||
@ -533,7 +534,7 @@ ignore the rest of the blocks in this inode
|
||||
and continue checking with the next inode in the file system.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
.IP NO
|
||||
terminate the program.
|
||||
@ -542,17 +543,17 @@ terminate the program.
|
||||
.B "DUP TABLE OVERFLOW (CONTINUE)"
|
||||
.br
|
||||
An internal table in
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
containing duplicate block numbers cannot allocate any more space.
|
||||
Increase the amount of virtual memory available to
|
||||
.I fsck .
|
||||
.I fsck_ffs .
|
||||
.LP
|
||||
Possible responses to the CONTINUE prompt are:
|
||||
.IP YES
|
||||
continue with the program.
|
||||
This error condition will not allow a complete check of the file system.
|
||||
A second run of
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be made to re-check this file system.
|
||||
If another duplicate block is found, this error condition will repeat.
|
||||
.IP NO
|
||||
@ -627,12 +628,12 @@ The files and directories usually found in the root will be recovered
|
||||
in Phase 3 and put into
|
||||
.I lost+found .
|
||||
If the attempt to allocate the root fails,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will exit with the message:
|
||||
.br
|
||||
.B "CANNOT ALLOCATE ROOT INODE" .
|
||||
.IP NO
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will exit.
|
||||
.sp
|
||||
.LP
|
||||
@ -649,12 +650,12 @@ The files and directories usually found in the root will be recovered
|
||||
in Phase 3 and put into
|
||||
.I lost+found .
|
||||
If the attempt to allocate the root fails,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will exit with the message:
|
||||
.br
|
||||
.B "CANNOT ALLOCATE ROOT INODE" .
|
||||
.IP NO
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will then prompt with
|
||||
.B "FIX"
|
||||
.LP
|
||||
@ -680,12 +681,12 @@ The files and directories usually found in the root will be recovered
|
||||
in Phase 3 and put into
|
||||
.I lost+found .
|
||||
If the attempt to allocate the root fails,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will exit with the message:
|
||||
.br
|
||||
.B "CANNOT ALLOCATE ROOT INODE" .
|
||||
.IP NO
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will then prompt with
|
||||
.B "CONTINUE" .
|
||||
.LP
|
||||
@ -834,12 +835,12 @@ leave the directory unchanged.
|
||||
.B "CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS \fIF\fP"
|
||||
.br
|
||||
A directory \fII\fP has been found whose first entry is \fIF\fP.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
cannot resolve this problem.
|
||||
The file system should be mounted and the offending entry \fIF\fP
|
||||
moved elsewhere.
|
||||
The file system should then be unmounted and
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be run again.
|
||||
.sp
|
||||
.LP
|
||||
@ -848,7 +849,7 @@ should be run again.
|
||||
.B "CANNOT FIX, INSUFFICIENT SPACE TO ADD `.'"
|
||||
.br
|
||||
A directory \fII\fP has been found whose first entry is not `.'.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
cannot resolve this problem as it should never happen.
|
||||
See a guru.
|
||||
.sp
|
||||
@ -894,12 +895,12 @@ leave the directory unchanged.
|
||||
.B "CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS \fIF\fP"
|
||||
.br
|
||||
A directory \fII\fP has been found whose second entry is \fIF\fP.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
cannot resolve this problem.
|
||||
The file system should be mounted and the offending entry \fIF\fP
|
||||
moved elsewhere.
|
||||
The file system should then be unmounted and
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be run again.
|
||||
.sp
|
||||
.LP
|
||||
@ -908,12 +909,12 @@ should be run again.
|
||||
.B "CANNOT FIX, INSUFFICIENT SPACE TO ADD `..'"
|
||||
.br
|
||||
A directory \fII\fP has been found whose second entry is not `..'.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
cannot resolve this problem.
|
||||
The file system should be mounted and the second entry in the directory
|
||||
moved elsewhere.
|
||||
The file system should then be unmounted and
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be run again.
|
||||
.sp
|
||||
.LP
|
||||
@ -930,7 +931,7 @@ leave the directory unchanged.
|
||||
.LP
|
||||
.B "\fIN\fP IS AN EXTRANEOUS HARD LINK TO A DIRECTORY \fID\fP (REMOVE)
|
||||
.br
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
has found a hard link, \fIN\fP, to a directory, \fID\fP.
|
||||
When preen'ing the extraneous links are ignored.
|
||||
.LP
|
||||
@ -945,7 +946,7 @@ ignore the error condition.
|
||||
.br
|
||||
An internal error has caused an impossible state \fIS\fP to be passed to the
|
||||
routine that descends the file system directory structure.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
exits.
|
||||
See a guru.
|
||||
.sp
|
||||
@ -954,7 +955,7 @@ See a guru.
|
||||
.br
|
||||
An internal error has caused an impossible state \fIS\fP to be returned
|
||||
from the routine that descends the file system directory structure.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
exits.
|
||||
See a guru.
|
||||
.sp
|
||||
@ -963,7 +964,7 @@ See a guru.
|
||||
.br
|
||||
An internal error has caused an impossible state \fIS\fP to be assigned
|
||||
to the root inode.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
exits.
|
||||
See a guru.
|
||||
.NH 2
|
||||
@ -1008,7 +1009,7 @@ There is no
|
||||
.I lost+found
|
||||
directory in the root directory of the file system;
|
||||
When preen'ing
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
tries to create a \fIlost+found\fP directory.
|
||||
.LP
|
||||
Possible responses to the CREATE prompt are:
|
||||
@ -1069,7 +1070,7 @@ the
|
||||
.I lost+found
|
||||
directory is expanded to make room for the new entry.
|
||||
If the attempted expansion fails
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
prints the message:
|
||||
.br
|
||||
.B "SORRY. NO SPACE IN lost+found DIRECTORY"
|
||||
@ -1116,7 +1117,7 @@ ignore the error condition.
|
||||
.br
|
||||
An internal error has caused an impossible state \fIS\fP to be passed to the
|
||||
routine that descends the file system directory structure.
|
||||
.I Fsck
|
||||
.I Fsck_ffs
|
||||
exits.
|
||||
See a guru.
|
||||
.NH 2
|
||||
@ -1180,7 +1181,7 @@ There is no
|
||||
.I lost+found
|
||||
directory in the root directory of the file system;
|
||||
When preen'ing
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
tries to create a \fIlost+found\fP directory.
|
||||
.LP
|
||||
Possible responses to the CREATE prompt are:
|
||||
@ -1241,7 +1242,7 @@ the
|
||||
.I lost+found
|
||||
directory is expanded to make room for the new entry.
|
||||
If the attempted expansion fails
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
prints the message:
|
||||
.br
|
||||
.B "SORRY. NO SPACE IN lost+found DIRECTORY"
|
||||
@ -1266,7 +1267,7 @@ When preen'ing the link count is adjusted unless the number of references
|
||||
is increasing, a condition that should never occur unless precipitated
|
||||
by a hardware failure.
|
||||
When the number of references is increasing under preen mode,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
exits with the message:
|
||||
.br
|
||||
.B "LINK COUNT INCREASING"
|
||||
@ -1396,14 +1397,14 @@ The numbers in parenthesis breaks the free count down into
|
||||
.br
|
||||
This is an advisory message indicating that
|
||||
the root file system has been modified by
|
||||
.I fsck.
|
||||
.I fsck_ffs.
|
||||
If UNIX is not rebooted immediately,
|
||||
the work done by
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
may be undone by the in-core copies of tables
|
||||
UNIX keeps.
|
||||
When preen'ing,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
will exit with a code of 4.
|
||||
The standard auto-reboot script distributed with 4.3BSD
|
||||
interprets an exit code of 4 by issuing a reboot system call.
|
||||
@ -1413,12 +1414,12 @@ interprets an exit code of 4 by issuing a reboot system call.
|
||||
.br
|
||||
This is an advisory message indicating that
|
||||
the current file system was modified by
|
||||
.I fsck.
|
||||
.I fsck_ffs.
|
||||
If this file system is mounted or is the current root file system,
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
should be halted and UNIX rebooted.
|
||||
If UNIX is not rebooted immediately,
|
||||
the work done by
|
||||
.I fsck
|
||||
.I fsck_ffs
|
||||
may be undone by the in-core copies of tables
|
||||
UNIX keeps.
|
||||
|
@ -1,6 +1,7 @@
|
||||
# $FreeBSD$
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/8/93
|
||||
|
||||
DIR= smm/03.fsck
|
||||
DIR= smm/03.fsck_ffs
|
||||
SRCS= 0.t 1.t 2.t 3.t 4.t
|
||||
MACROS= -ms
|
||||
|
||||
|
@ -205,7 +205,9 @@ char preen; /* just fix normal inconsistencies */
|
||||
char rerun; /* rerun fsck. Only used in non-preen mode */
|
||||
int returntosingle; /* 1 => return to single user mode on exit */
|
||||
char resolved; /* cleared if unresolved changes => not clean */
|
||||
int markclean; /* mark file system clean when done */
|
||||
char havesb; /* superblock has been read */
|
||||
char skipclean; /* skip clean file systems if preening */
|
||||
int fsmodified; /* 1 => write done to file system */
|
||||
int fsreadfd; /* file descriptor for reading file system */
|
||||
int fswritefd; /* file descriptor for writing file system */
|
||||
@ -252,9 +254,6 @@ void cacheino __P((struct dinode *dp, ino_t inumber));
|
||||
void catch __P((int));
|
||||
void catchquit __P((int));
|
||||
int changeino __P((ino_t dir, char *name, ino_t newnum));
|
||||
int checkfstab __P((int preen, int maxrun,
|
||||
int (*docheck)(struct fstab *),
|
||||
int (*chkit)(char *, char *, long, int)));
|
||||
int chkrange __P((ufs_daddr_t blk, int cnt));
|
||||
void ckfini __P((int markclean));
|
||||
int ckinode __P((struct dinode *dp, struct inodesc *));
|
||||
|
@ -62,6 +62,9 @@ static const char rcsid[] =
|
||||
|
||||
#include "fsck.h"
|
||||
|
||||
int returntosingle;
|
||||
|
||||
static void usage __P((void));
|
||||
static int argtoi __P((int flag, char *req, char *str, int base));
|
||||
static int docheck __P((struct fstab *fsp));
|
||||
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
|
||||
@ -75,22 +78,22 @@ main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
int ch;
|
||||
int ret, maxrun = 0;
|
||||
struct rlimit rlimit;
|
||||
int ret = 0;
|
||||
|
||||
sync();
|
||||
while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != -1) {
|
||||
skipclean = 1;
|
||||
markclean = 1;
|
||||
while ((ch = getopt(argc, argv, "b:c:dfm:npy")) != -1) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
preen++;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
skipclean = 0;
|
||||
bflag = argtoi('b', "number", optarg, 10);
|
||||
printf("Alternate super block location: %d\n", bflag);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
skipclean = 0;
|
||||
cvtlevel = argtoi('c', "conversion level", optarg, 10);
|
||||
break;
|
||||
|
||||
@ -99,11 +102,7 @@ main(argc, argv)
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
fflag++;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
maxrun = argtoi('l', "number", optarg, 10);
|
||||
skipclean = 0;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
@ -114,23 +113,29 @@ main(argc, argv)
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
nflag++;
|
||||
yflag = 0;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
preen++;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
case 'Y':
|
||||
yflag++;
|
||||
nflag = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(EEXIT, "%c option?", ch);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (!argc)
|
||||
usage();
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||
(void)signal(SIGINT, catch);
|
||||
if (preen)
|
||||
@ -143,21 +148,11 @@ main(argc, argv)
|
||||
rlimit.rlim_cur = rlimit.rlim_max;
|
||||
(void)setrlimit(RLIMIT_DATA, &rlimit);
|
||||
}
|
||||
if (argc) {
|
||||
while (argc-- > 0) {
|
||||
char *path = blockcheck(*argv);
|
||||
while (argc-- > 0)
|
||||
(void)checkfilesys(blockcheck(*argv++), 0, 0L, 0);
|
||||
|
||||
if (path == NULL)
|
||||
pfatal("Can't check %s\n", *argv);
|
||||
else
|
||||
(void)checkfilesys(path, 0, 0L, 0);
|
||||
++argv;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
ret = checkfstab(preen, maxrun, docheck, checkfilesys);
|
||||
if (returntosingle)
|
||||
exit(2);
|
||||
ret = 2;
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
@ -176,22 +171,6 @@ argtoi(flag, req, str, base)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine whether a filesystem should be checked.
|
||||
*/
|
||||
static int
|
||||
docheck(fsp)
|
||||
register struct fstab *fsp;
|
||||
{
|
||||
|
||||
if (strcmp(fsp->fs_vfstype, "ufs") ||
|
||||
(strcmp(fsp->fs_type, FSTAB_RW) &&
|
||||
strcmp(fsp->fs_type, FSTAB_RO)) ||
|
||||
fsp->fs_passno == 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the specified filesystem.
|
||||
*/
|
||||
@ -415,3 +394,15 @@ getmntpt(name)
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
extern char *__progname;
|
||||
|
||||
(void) fprintf(stderr,
|
||||
"Usage: %s [-dfnpy] [-B be|le] [-b block] [-c level] [-m mode] "
|
||||
"filesystem ...\n",
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -288,45 +288,3 @@ startdisk(dk, checkit)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *
|
||||
blockcheck(origname)
|
||||
char *origname;
|
||||
{
|
||||
struct stat stslash, stblock, stchar;
|
||||
char *newname, *raw;
|
||||
struct fstab *fsinfo;
|
||||
int retried = 0, len;
|
||||
|
||||
newname = origname;
|
||||
retry:
|
||||
if (stat(newname, &stblock) < 0) {
|
||||
printf("Can't stat %s: %s\n", newname, strerror(errno));
|
||||
return (origname);
|
||||
}
|
||||
switch(stblock.st_mode & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
return(newname);
|
||||
case S_IFDIR:
|
||||
if (retried)
|
||||
break;
|
||||
|
||||
len = strlen(origname) - 1;
|
||||
if (len > 0 && origname[len] == '/')
|
||||
/* remove trailing slash */
|
||||
origname[len] = '\0';
|
||||
if ((fsinfo = getfsfile(origname)) == NULL) {
|
||||
printf("Can't resolve %s to character special device",
|
||||
origname);
|
||||
return (0);
|
||||
}
|
||||
newname = fsinfo->fs_spec;
|
||||
retried++;
|
||||
goto retry;
|
||||
}
|
||||
/*
|
||||
* Not a block or character device, just return name and
|
||||
* let the user decide whether to use it.
|
||||
*/
|
||||
return (origname);
|
||||
}
|
||||
|
@ -40,13 +40,21 @@ static const char rcsid[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <fstab.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fsck.h"
|
||||
|
||||
@ -561,7 +569,7 @@ dofix(idesc, msg)
|
||||
if (idesc->id_type == DATA)
|
||||
direrror(idesc->id_number, msg);
|
||||
else
|
||||
pwarn("%s", msg);
|
||||
pwarn(msg);
|
||||
if (preen) {
|
||||
printf(" (SALVAGED)\n");
|
||||
idesc->id_fix = FIX;
|
||||
@ -681,3 +689,46 @@ panic(fmt, va_alist)
|
||||
va_end(ap);
|
||||
exit(EEXIT);
|
||||
}
|
||||
|
||||
char *
|
||||
blockcheck(origname)
|
||||
char *origname;
|
||||
{
|
||||
struct stat stslash, stblock, stchar;
|
||||
char *newname, *raw;
|
||||
struct fstab *fsinfo;
|
||||
int retried = 0, len;
|
||||
|
||||
newname = origname;
|
||||
retry:
|
||||
if (stat(newname, &stblock) < 0) {
|
||||
printf("Can't stat %s: %s\n", newname, strerror(errno));
|
||||
return (origname);
|
||||
}
|
||||
switch(stblock.st_mode & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
return(newname);
|
||||
case S_IFDIR:
|
||||
if (retried)
|
||||
break;
|
||||
|
||||
len = strlen(origname) - 1;
|
||||
if (len > 0 && origname[len] == '/')
|
||||
/* remove trailing slash */
|
||||
origname[len] = '\0';
|
||||
if ((fsinfo = getfsfile(origname)) == NULL) {
|
||||
printf("Can't resolve %s to character special device",
|
||||
origname);
|
||||
return (0);
|
||||
}
|
||||
newname = fsinfo->fs_spec;
|
||||
retried++;
|
||||
goto retry;
|
||||
}
|
||||
/*
|
||||
* Not a block or character device, just return name and
|
||||
* let the user decide whether to use it.
|
||||
*/
|
||||
return (origname);
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
# $FreeBSD$
|
||||
# @(#)Makefile 8.2 (Berkeley) 4/27/95
|
||||
|
||||
PROG= fsck
|
||||
MAN8= fsck.8
|
||||
PROG= fsck_ffs
|
||||
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_ufs
|
||||
LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
|
||||
MAN8= fsck_ffs.8
|
||||
SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
|
||||
pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c
|
||||
pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c
|
||||
CFLAGS+=-W
|
||||
.PATH: ${.CURDIR}/../../sys/ufs/ffs
|
||||
|
||||
|
@ -205,7 +205,9 @@ char preen; /* just fix normal inconsistencies */
|
||||
char rerun; /* rerun fsck. Only used in non-preen mode */
|
||||
int returntosingle; /* 1 => return to single user mode on exit */
|
||||
char resolved; /* cleared if unresolved changes => not clean */
|
||||
int markclean; /* mark file system clean when done */
|
||||
char havesb; /* superblock has been read */
|
||||
char skipclean; /* skip clean file systems if preening */
|
||||
int fsmodified; /* 1 => write done to file system */
|
||||
int fsreadfd; /* file descriptor for reading file system */
|
||||
int fswritefd; /* file descriptor for writing file system */
|
||||
@ -252,9 +254,6 @@ void cacheino __P((struct dinode *dp, ino_t inumber));
|
||||
void catch __P((int));
|
||||
void catchquit __P((int));
|
||||
int changeino __P((ino_t dir, char *name, ino_t newnum));
|
||||
int checkfstab __P((int preen, int maxrun,
|
||||
int (*docheck)(struct fstab *),
|
||||
int (*chkit)(char *, char *, long, int)));
|
||||
int chkrange __P((ufs_daddr_t blk, int cnt));
|
||||
void ckfini __P((int markclean));
|
||||
int ckinode __P((struct dinode *dp, struct inodesc *));
|
||||
|
@ -62,6 +62,9 @@ static const char rcsid[] =
|
||||
|
||||
#include "fsck.h"
|
||||
|
||||
int returntosingle;
|
||||
|
||||
static void usage __P((void));
|
||||
static int argtoi __P((int flag, char *req, char *str, int base));
|
||||
static int docheck __P((struct fstab *fsp));
|
||||
static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
|
||||
@ -75,22 +78,22 @@ main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
int ch;
|
||||
int ret, maxrun = 0;
|
||||
struct rlimit rlimit;
|
||||
int ret = 0;
|
||||
|
||||
sync();
|
||||
while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != -1) {
|
||||
skipclean = 1;
|
||||
markclean = 1;
|
||||
while ((ch = getopt(argc, argv, "b:c:dfm:npy")) != -1) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
preen++;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
skipclean = 0;
|
||||
bflag = argtoi('b', "number", optarg, 10);
|
||||
printf("Alternate super block location: %d\n", bflag);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
skipclean = 0;
|
||||
cvtlevel = argtoi('c', "conversion level", optarg, 10);
|
||||
break;
|
||||
|
||||
@ -99,11 +102,7 @@ main(argc, argv)
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
fflag++;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
maxrun = argtoi('l', "number", optarg, 10);
|
||||
skipclean = 0;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
@ -114,23 +113,29 @@ main(argc, argv)
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
case 'N':
|
||||
nflag++;
|
||||
yflag = 0;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
preen++;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
case 'Y':
|
||||
yflag++;
|
||||
nflag = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(EEXIT, "%c option?", ch);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (!argc)
|
||||
usage();
|
||||
|
||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||
(void)signal(SIGINT, catch);
|
||||
if (preen)
|
||||
@ -143,21 +148,11 @@ main(argc, argv)
|
||||
rlimit.rlim_cur = rlimit.rlim_max;
|
||||
(void)setrlimit(RLIMIT_DATA, &rlimit);
|
||||
}
|
||||
if (argc) {
|
||||
while (argc-- > 0) {
|
||||
char *path = blockcheck(*argv);
|
||||
while (argc-- > 0)
|
||||
(void)checkfilesys(blockcheck(*argv++), 0, 0L, 0);
|
||||
|
||||
if (path == NULL)
|
||||
pfatal("Can't check %s\n", *argv);
|
||||
else
|
||||
(void)checkfilesys(path, 0, 0L, 0);
|
||||
++argv;
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
ret = checkfstab(preen, maxrun, docheck, checkfilesys);
|
||||
if (returntosingle)
|
||||
exit(2);
|
||||
ret = 2;
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
@ -176,22 +171,6 @@ argtoi(flag, req, str, base)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine whether a filesystem should be checked.
|
||||
*/
|
||||
static int
|
||||
docheck(fsp)
|
||||
register struct fstab *fsp;
|
||||
{
|
||||
|
||||
if (strcmp(fsp->fs_vfstype, "ufs") ||
|
||||
(strcmp(fsp->fs_type, FSTAB_RW) &&
|
||||
strcmp(fsp->fs_type, FSTAB_RO)) ||
|
||||
fsp->fs_passno == 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the specified filesystem.
|
||||
*/
|
||||
@ -415,3 +394,15 @@ getmntpt(name)
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
extern char *__progname;
|
||||
|
||||
(void) fprintf(stderr,
|
||||
"Usage: %s [-dfnpy] [-B be|le] [-b block] [-c level] [-m mode] "
|
||||
"filesystem ...\n",
|
||||
__progname);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -288,45 +288,3 @@ startdisk(dk, checkit)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *
|
||||
blockcheck(origname)
|
||||
char *origname;
|
||||
{
|
||||
struct stat stslash, stblock, stchar;
|
||||
char *newname, *raw;
|
||||
struct fstab *fsinfo;
|
||||
int retried = 0, len;
|
||||
|
||||
newname = origname;
|
||||
retry:
|
||||
if (stat(newname, &stblock) < 0) {
|
||||
printf("Can't stat %s: %s\n", newname, strerror(errno));
|
||||
return (origname);
|
||||
}
|
||||
switch(stblock.st_mode & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
return(newname);
|
||||
case S_IFDIR:
|
||||
if (retried)
|
||||
break;
|
||||
|
||||
len = strlen(origname) - 1;
|
||||
if (len > 0 && origname[len] == '/')
|
||||
/* remove trailing slash */
|
||||
origname[len] = '\0';
|
||||
if ((fsinfo = getfsfile(origname)) == NULL) {
|
||||
printf("Can't resolve %s to character special device",
|
||||
origname);
|
||||
return (0);
|
||||
}
|
||||
newname = fsinfo->fs_spec;
|
||||
retried++;
|
||||
goto retry;
|
||||
}
|
||||
/*
|
||||
* Not a block or character device, just return name and
|
||||
* let the user decide whether to use it.
|
||||
*/
|
||||
return (origname);
|
||||
}
|
||||
|
@ -40,13 +40,21 @@ static const char rcsid[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ufs/dir.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <fstab.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fsck.h"
|
||||
|
||||
@ -561,7 +569,7 @@ dofix(idesc, msg)
|
||||
if (idesc->id_type == DATA)
|
||||
direrror(idesc->id_number, msg);
|
||||
else
|
||||
pwarn("%s", msg);
|
||||
pwarn(msg);
|
||||
if (preen) {
|
||||
printf(" (SALVAGED)\n");
|
||||
idesc->id_fix = FIX;
|
||||
@ -681,3 +689,46 @@ panic(fmt, va_alist)
|
||||
va_end(ap);
|
||||
exit(EEXIT);
|
||||
}
|
||||
|
||||
char *
|
||||
blockcheck(origname)
|
||||
char *origname;
|
||||
{
|
||||
struct stat stslash, stblock, stchar;
|
||||
char *newname, *raw;
|
||||
struct fstab *fsinfo;
|
||||
int retried = 0, len;
|
||||
|
||||
newname = origname;
|
||||
retry:
|
||||
if (stat(newname, &stblock) < 0) {
|
||||
printf("Can't stat %s: %s\n", newname, strerror(errno));
|
||||
return (origname);
|
||||
}
|
||||
switch(stblock.st_mode & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
return(newname);
|
||||
case S_IFDIR:
|
||||
if (retried)
|
||||
break;
|
||||
|
||||
len = strlen(origname) - 1;
|
||||
if (len > 0 && origname[len] == '/')
|
||||
/* remove trailing slash */
|
||||
origname[len] = '\0';
|
||||
if ((fsinfo = getfsfile(origname)) == NULL) {
|
||||
printf("Can't resolve %s to character special device",
|
||||
origname);
|
||||
return (0);
|
||||
}
|
||||
newname = fsinfo->fs_spec;
|
||||
retried++;
|
||||
goto retry;
|
||||
}
|
||||
/*
|
||||
* Not a block or character device, just return name and
|
||||
* let the user decide whether to use it.
|
||||
*/
|
||||
return (origname);
|
||||
}
|
||||
|
@ -288,45 +288,3 @@ startdisk(dk, checkit)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *
|
||||
blockcheck(origname)
|
||||
char *origname;
|
||||
{
|
||||
struct stat stslash, stblock, stchar;
|
||||
char *newname, *raw;
|
||||
struct fstab *fsinfo;
|
||||
int retried = 0, len;
|
||||
|
||||
newname = origname;
|
||||
retry:
|
||||
if (stat(newname, &stblock) < 0) {
|
||||
printf("Can't stat %s: %s\n", newname, strerror(errno));
|
||||
return (origname);
|
||||
}
|
||||
switch(stblock.st_mode & S_IFMT) {
|
||||
case S_IFCHR:
|
||||
case S_IFBLK:
|
||||
return(newname);
|
||||
case S_IFDIR:
|
||||
if (retried)
|
||||
break;
|
||||
|
||||
len = strlen(origname) - 1;
|
||||
if (len > 0 && origname[len] == '/')
|
||||
/* remove trailing slash */
|
||||
origname[len] = '\0';
|
||||
if ((fsinfo = getfsfile(origname)) == NULL) {
|
||||
printf("Can't resolve %s to character special device",
|
||||
origname);
|
||||
return (0);
|
||||
}
|
||||
newname = fsinfo->fs_spec;
|
||||
retried++;
|
||||
goto retry;
|
||||
}
|
||||
/*
|
||||
* Not a block or character device, just return name and
|
||||
* let the user decide whether to use it.
|
||||
*/
|
||||
return (origname);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user