2008-04-30 17:10:46 +04:00
|
|
|
.\" $NetBSD: fsdb.8,v 1.22 2008/04/30 13:10:53 martin Exp $
|
1995-10-09 02:18:08 +03:00
|
|
|
.\"
|
1996-02-28 01:28:09 +03:00
|
|
|
.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
|
1995-10-09 02:08:36 +03:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
1996-02-28 01:28:09 +03:00
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by John T. Kohl.
|
|
|
|
.\"
|
1995-10-09 02:08:36 +03:00
|
|
|
.\" 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.
|
|
|
|
.\"
|
1996-02-28 01:28:09 +03:00
|
|
|
.\" 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
|
2001-11-16 13:25:42 +03:00
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
1997-07-31 04:21:53 +04:00
|
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
1996-02-28 01:28:09 +03:00
|
|
|
.\" 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
|
1995-10-09 02:08:36 +03:00
|
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2004-01-04 03:12:04 +03:00
|
|
|
.Dd January 3, 2004
|
1995-10-09 02:08:36 +03:00
|
|
|
.Dt FSDB 8
|
2001-06-05 15:22:41 +04:00
|
|
|
.Os
|
1995-10-09 02:08:36 +03:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fsdb
|
|
|
|
.Nd FFS debugging/editing tool
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm
|
2004-01-04 03:12:04 +03:00
|
|
|
.Op Fl dFn
|
1995-10-09 02:08:36 +03:00
|
|
|
.Fl f Ar fsname
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm
|
2001-11-16 13:25:42 +03:00
|
|
|
opens
|
1995-10-09 02:08:36 +03:00
|
|
|
.Ar fsname
|
|
|
|
(usually a raw disk partition) and runs a command loop
|
2002-10-01 17:40:23 +04:00
|
|
|
allowing manipulation of the file system's inode data.
|
|
|
|
You are prompted to enter a command with
|
2002-02-08 04:21:55 +03:00
|
|
|
.Dq "fsdb (inum X)\*[Gt]"
|
1995-10-09 02:08:36 +03:00
|
|
|
where
|
|
|
|
.Va X
|
2002-10-01 17:40:23 +04:00
|
|
|
is the currently selected i-number.
|
|
|
|
The initial selected inode is the root of the filesystem (i-number 2).
|
1995-10-09 02:08:36 +03:00
|
|
|
The command processor uses the
|
1997-01-11 08:51:40 +03:00
|
|
|
.Xr editline 3
|
1995-10-09 02:08:36 +03:00
|
|
|
library, so you can use command line editing to reduce typing if desired.
|
|
|
|
When you exit the command loop, the file system superblock is marked
|
|
|
|
dirty and any buffered blocks are written to the file system.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fl d
|
|
|
|
option enables additional debugging output (which comes primarily from
|
2003-06-28 03:06:50 +04:00
|
|
|
.Xr fsck 8 Ns -derived
|
1995-10-09 02:08:36 +03:00
|
|
|
code).
|
1999-03-09 19:11:47 +03:00
|
|
|
.Pp
|
|
|
|
The
|
2004-01-03 22:57:42 +03:00
|
|
|
.Fl F
|
|
|
|
option indicates that
|
|
|
|
.Ar filesystem
|
|
|
|
is a file system image, rather than a raw character device.
|
|
|
|
It will be accessed
|
|
|
|
.Sq as-is ,
|
|
|
|
and no attempts will be made to read a disklabel.
|
|
|
|
.Pp
|
|
|
|
The
|
1999-03-09 19:11:47 +03:00
|
|
|
.Fl n
|
2005-05-25 04:02:49 +04:00
|
|
|
option disables writing to the device, preventing any changes from being made
|
1999-03-09 19:11:47 +03:00
|
|
|
to the filesystem.
|
1995-10-09 02:08:36 +03:00
|
|
|
.Sh COMMANDS
|
2001-11-16 13:25:42 +03:00
|
|
|
Besides the built-in
|
1997-01-11 08:51:40 +03:00
|
|
|
.Xr editline 3
|
1995-10-09 02:08:36 +03:00
|
|
|
commands,
|
|
|
|
.Nm
|
|
|
|
supports these commands:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -compact
|
|
|
|
.It Cm help
|
|
|
|
Print out the list of accepted commands.
|
|
|
|
.Pp
|
|
|
|
.It Cm inode Ar i-number
|
|
|
|
Select inode
|
|
|
|
.Ar i-number
|
|
|
|
as the new current inode.
|
|
|
|
.Pp
|
|
|
|
.It Cm back
|
|
|
|
Revert to the previously current inode.
|
|
|
|
.Pp
|
|
|
|
.It Cm clri
|
|
|
|
Clear the current inode.
|
|
|
|
.Pp
|
|
|
|
.It Cm lookup Ar name
|
|
|
|
.It Cm cd Ar name
|
|
|
|
Find
|
|
|
|
.Ar name
|
|
|
|
in the current directory and make its inode the current inode.
|
|
|
|
.Ar Name
|
|
|
|
may be a multi-component name or may begin with slash to indicate that
|
2002-10-01 17:40:23 +04:00
|
|
|
the root inode should be used to start the lookup.
|
|
|
|
If some component along the pathname is not found,
|
|
|
|
the last valid directory encountered is left as the active inode.
|
1995-10-09 02:08:36 +03:00
|
|
|
.br
|
|
|
|
This command is valid only if the starting inode is a directory.
|
|
|
|
.Pp
|
|
|
|
.It Cm active
|
|
|
|
.It Cm print
|
|
|
|
Print out the active inode.
|
|
|
|
.Pp
|
|
|
|
.It Cm uplink
|
|
|
|
Increment the active inode's link count.
|
|
|
|
.Pp
|
|
|
|
.It Cm downlink
|
|
|
|
Decrement the active inode's link count.
|
|
|
|
.Pp
|
|
|
|
.It Cm linkcount Ar number
|
|
|
|
Set the active inode's link count to
|
|
|
|
.Ar number .
|
|
|
|
.Pp
|
|
|
|
.It Cm ls
|
2002-10-01 17:40:23 +04:00
|
|
|
List the current inode's directory entries.
|
|
|
|
This command is valid only if the current inode is a directory.
|
1995-10-09 02:08:36 +03:00
|
|
|
.Pp
|
1999-03-09 19:11:47 +03:00
|
|
|
.It Cm blks
|
|
|
|
List the current inode's blocks numbers.
|
|
|
|
.Pp
|
2003-04-26 12:42:49 +04:00
|
|
|
.It Cm findblk Ar disk block number ...
|
2005-05-25 04:02:49 +04:00
|
|
|
Find the inode(s) owning the specified disk block(s) number(s).
|
2003-04-26 12:42:49 +04:00
|
|
|
Note that these are not absolute disk blocks numbers, but offsets from the
|
2003-05-10 03:05:53 +04:00
|
|
|
start of the partition.
|
2003-04-26 12:42:49 +04:00
|
|
|
.Pp
|
1995-10-09 02:08:36 +03:00
|
|
|
.It Cm rm Ar name
|
|
|
|
.It Cm del Ar name
|
|
|
|
Remove the entry
|
|
|
|
.Ar name
|
2002-10-01 17:40:23 +04:00
|
|
|
from the current directory inode.
|
|
|
|
This command is valid only if the current inode is a directory.
|
1995-10-09 02:08:36 +03:00
|
|
|
.Pp
|
|
|
|
.It Cm ln Ar ino Ar name
|
|
|
|
Create a link to inode
|
|
|
|
.Ar ino
|
|
|
|
under the name
|
|
|
|
.Ar name
|
2002-10-01 17:40:23 +04:00
|
|
|
in the current directory inode.
|
|
|
|
This command is valid only if the current inode is a directory.
|
1995-10-09 02:08:36 +03:00
|
|
|
.Pp
|
|
|
|
.It Cm chinum Ar dirslot Ar inum
|
|
|
|
Change the i-number in directory entry
|
|
|
|
.Ar dirslot
|
|
|
|
to
|
|
|
|
.Ar inum .
|
|
|
|
.Pp
|
|
|
|
.It Cm chname Ar dirslot Ar name
|
|
|
|
Change the name in directory entry
|
|
|
|
.Ar dirslot
|
|
|
|
to
|
|
|
|
.Ar name .
|
2002-10-01 17:40:23 +04:00
|
|
|
This command cannot expand a directory entry.
|
|
|
|
You can only rename an entry if the name will fit into
|
|
|
|
the existing directory slot.
|
1995-10-09 02:08:36 +03:00
|
|
|
.Pp
|
|
|
|
.It Cm chtype Ar type
|
|
|
|
Change the type of the current inode to
|
|
|
|
.Ar type .
|
|
|
|
.Ar type
|
|
|
|
may be one of:
|
|
|
|
.Em file ,
|
|
|
|
.Em dir ,
|
|
|
|
.Em socket ,
|
|
|
|
or
|
|
|
|
.Em fifo .
|
|
|
|
.Pp
|
|
|
|
.It Cm chmod Ar mode
|
|
|
|
Change the mode bits of the current inode to
|
|
|
|
.Ar mode .
|
|
|
|
You cannot change the file type with this subcommand; use
|
|
|
|
.Ic chtype
|
|
|
|
to do that.
|
|
|
|
.Pp
|
|
|
|
.It Cm chflags Ar flags
|
|
|
|
Change the file flags of the current inode to
|
|
|
|
.Ar flags .
|
|
|
|
.Pp
|
|
|
|
.It Cm chown Ar uid
|
|
|
|
Change the owner of the current inode to
|
|
|
|
.Ar uid .
|
|
|
|
.Pp
|
|
|
|
.It Cm chgrp Ar gid
|
|
|
|
Change the group of the current inode to
|
|
|
|
.Ar gid .
|
|
|
|
.Pp
|
|
|
|
.It Cm chgen Ar gen
|
|
|
|
Change the generation number of the current inode to
|
|
|
|
.Ar gen .
|
|
|
|
.Pp
|
|
|
|
.It Cm mtime Ar time
|
|
|
|
.It Cm ctime Ar time
|
|
|
|
.It Cm atime Ar time
|
|
|
|
Change the modification, change, or access time (respectively) on the
|
2001-11-16 13:25:42 +03:00
|
|
|
current inode to
|
1995-10-09 02:08:36 +03:00
|
|
|
.Ar time .
|
|
|
|
.Ar Time
|
|
|
|
should be in the format
|
|
|
|
.Em YYYYMMDDHHMMSS[.nsec]
|
|
|
|
where
|
|
|
|
.Em nsec
|
2002-10-01 17:40:23 +04:00
|
|
|
is an optional nanosecond specification.
|
|
|
|
If no nanoseconds are specified, the
|
1995-10-09 02:08:36 +03:00
|
|
|
.Va mtimensec ,
|
|
|
|
.Va ctimensec ,
|
|
|
|
or
|
2001-11-16 13:25:42 +03:00
|
|
|
.Va atimensec
|
1995-10-09 02:08:36 +03:00
|
|
|
field will be set to zero.
|
|
|
|
.Pp
|
2005-05-25 14:01:34 +04:00
|
|
|
.It Cm quit, Cm q, Cm exit, Aq Em EOF
|
1995-10-09 02:08:36 +03:00
|
|
|
Exit the program.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
1997-01-11 08:51:40 +03:00
|
|
|
.Xr editline 3 ,
|
1995-10-09 02:08:36 +03:00
|
|
|
.Xr fs 5 ,
|
1998-05-22 22:27:50 +04:00
|
|
|
.Xr clri 8 ,
|
|
|
|
.Xr fsck 8
|
1995-10-09 02:08:36 +03:00
|
|
|
.Sh HISTORY
|
|
|
|
.Nm
|
|
|
|
uses the source code for
|
|
|
|
.Xr fsck 8
|
2002-10-01 17:40:23 +04:00
|
|
|
to implement most of the file system manipulation code.
|
|
|
|
The remainder of
|
1995-10-09 02:08:36 +03:00
|
|
|
.Nm
|
2001-11-16 13:25:42 +03:00
|
|
|
first appeared in
|
1996-02-06 05:25:04 +03:00
|
|
|
.Nx 1.1 .
|
1995-10-09 02:08:36 +03:00
|
|
|
.Sh WARNING
|
1997-09-14 18:56:57 +04:00
|
|
|
Use this tool with extreme caution -- you can damage an FFS file system
|
1995-10-09 02:08:36 +03:00
|
|
|
beyond what
|
|
|
|
.Xr fsck 8
|
2001-11-16 13:25:42 +03:00
|
|
|
can repair.
|
2001-11-16 14:21:37 +03:00
|
|
|
.Sh BUGS
|
2005-05-25 04:02:49 +04:00
|
|
|
Manipulation of
|
|
|
|
.Dq short
|
|
|
|
symlinks doesn't work (in particular, don't
|
2001-11-16 14:21:37 +03:00
|
|
|
try changing a symlink's type).
|
|
|
|
.br
|
|
|
|
You must specify modes as numbers rather than symbolic names.
|
|
|
|
.br
|
|
|
|
There are a bunch of other things that you might want to do which
|
|
|
|
.Nm
|
|
|
|
doesn't implement.
|