1995-11-03 22:38:54 +00:00
|
|
|
.\" $NetBSD: fsdb.8,v 1.2 1995/10/08 23:18:08 thorpej Exp $
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1995 John T. Kohl
|
|
|
|
.\" 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.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR `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 AUTHOR 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-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1997-01-13 00:25:51 +00:00
|
|
|
.\"
|
2006-08-24 09:14:02 +00:00
|
|
|
.Dd August 24, 2006
|
1995-11-03 22:38:54 +00:00
|
|
|
.Dt FSDB 8
|
2001-07-10 11:04:34 +00:00
|
|
|
.Os
|
1995-11-03 22:38:54 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fsdb
|
|
|
|
.Nd FFS debugging/editing tool
|
|
|
|
.Sh SYNOPSIS
|
2000-11-20 16:52:27 +00:00
|
|
|
.Nm
|
1995-11-03 22:38:54 +00:00
|
|
|
.Op Fl d
|
2001-07-15 07:53:42 +00:00
|
|
|
.Op Fl f
|
1997-04-15 09:02:48 +00:00
|
|
|
.Op Fl r
|
1996-09-30 20:04:24 +00:00
|
|
|
.Ar fsname
|
1995-11-03 22:38:54 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-07-06 19:34:18 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility opens
|
1995-11-03 22:38:54 +00:00
|
|
|
.Ar fsname
|
|
|
|
(usually a raw disk partition) and runs a command loop
|
2004-07-02 21:45:06 +00:00
|
|
|
allowing manipulation of the file system's inode data.
|
|
|
|
You are prompted
|
1995-11-03 22:38:54 +00:00
|
|
|
to enter a command with
|
|
|
|
.Ic "fsdb (inum X)>"
|
|
|
|
where
|
|
|
|
.Va X
|
2004-07-02 21:45:06 +00:00
|
|
|
is the currently selected i-number.
|
|
|
|
The initial selected inode is the
|
2002-08-21 18:11:48 +00:00
|
|
|
root of the file system (i-number 2).
|
1995-11-03 22:38:54 +00:00
|
|
|
The command processor uses the
|
1999-04-13 02:42:53 +00:00
|
|
|
.Xr editline 3
|
1995-11-03 22:38:54 +00:00
|
|
|
library, so you can use command line editing to reduce typing if desired.
|
2002-08-21 18:11:48 +00:00
|
|
|
When you exit the command loop, the file system superblock is marked
|
|
|
|
dirty and any buffered blocks are written to the file system.
|
1995-11-03 22:38:54 +00:00
|
|
|
.Pp
|
1998-06-15 07:12:20 +00:00
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Fl d
|
|
|
|
Enable additional debugging output (which comes primarily from
|
2001-01-16 09:15:57 +00:00
|
|
|
.Xr fsck 8 Ns -derived
|
1995-11-03 22:38:54 +00:00
|
|
|
code).
|
1998-06-15 07:12:20 +00:00
|
|
|
.It Fl f
|
|
|
|
Left for historical reasons and has no meaning.
|
|
|
|
.It Fl r
|
2002-08-21 18:11:48 +00:00
|
|
|
Open the file system read/only, and disables all commands that would
|
1997-04-15 09:02:48 +00:00
|
|
|
write to it.
|
1998-06-15 07:12:20 +00:00
|
|
|
.El
|
1995-11-03 22:38:54 +00:00
|
|
|
.Sh COMMANDS
|
2001-07-15 07:53:42 +00:00
|
|
|
Besides the built-in
|
1999-04-13 02:42:53 +00:00
|
|
|
.Xr editline 3
|
1995-11-03 22:38:54 +00: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
|
1999-12-20 07:47:57 +00:00
|
|
|
.It Cm clri Ar i-number
|
2001-07-15 07:53:42 +00:00
|
|
|
Clear
|
1999-12-20 07:47:57 +00:00
|
|
|
.Ar i-number .
|
1995-11-03 22:38:54 +00:00
|
|
|
.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
|
2004-07-02 21:45:06 +00:00
|
|
|
the root inode should be used to start the lookup.
|
|
|
|
If some component
|
1995-11-03 22:38:54 +00:00
|
|
|
along the pathname is not found, the last valid directory encountered is
|
|
|
|
left as the active inode.
|
|
|
|
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
|
2002-01-26 15:53:23 +00:00
|
|
|
.It Cm blocks
|
|
|
|
Print out the block list of the active inode.
|
2002-03-15 18:12:13 +00:00
|
|
|
Note that the printout can become long for large files, since all
|
2002-01-26 15:53:23 +00:00
|
|
|
indirect block pointers will also be printed.
|
2006-06-02 12:55:26 +00:00
|
|
|
.Pp
|
2006-09-18 11:55:10 +00:00
|
|
|
.It Cm findblk Ar disk_block_number ...
|
2006-06-02 12:55:26 +00:00
|
|
|
Find the inode(s) owning the specified disk block(s) number(s).
|
|
|
|
Note that these are not absolute disk blocks numbers, but offsets from the
|
|
|
|
start of the partition.
|
|
|
|
.Pp
|
1995-11-03 22:38:54 +00:00
|
|
|
.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
|
2004-07-02 21:45:06 +00:00
|
|
|
List the current inode's directory entries.
|
|
|
|
This command is valid only
|
2001-07-15 07:53:42 +00:00
|
|
|
if the current inode is a directory.
|
1995-11-03 22:38:54 +00:00
|
|
|
.Pp
|
|
|
|
.It Cm rm Ar name
|
|
|
|
.It Cm del Ar name
|
|
|
|
Remove the entry
|
|
|
|
.Ar name
|
2004-07-02 21:45:06 +00:00
|
|
|
from the current directory inode.
|
|
|
|
This command is valid only
|
1995-11-03 22:38:54 +00:00
|
|
|
if the current inode is a directory.
|
|
|
|
.Pp
|
|
|
|
.It Cm ln Ar ino Ar name
|
|
|
|
Create a link to inode
|
|
|
|
.Ar ino
|
|
|
|
under the name
|
|
|
|
.Ar name
|
2004-07-02 21:45:06 +00:00
|
|
|
in the current directory inode.
|
|
|
|
This command is valid only
|
1995-11-03 22:38:54 +00:00
|
|
|
if the current inode is a directory.
|
|
|
|
.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 .
|
2004-07-02 21:45:06 +00:00
|
|
|
This command cannot expand a directory entry.
|
|
|
|
You can only rename an
|
1995-11-03 22:38:54 +00:00
|
|
|
entry if the name will fit into the existing directory slot.
|
|
|
|
.Pp
|
|
|
|
.It Cm chtype Ar type
|
|
|
|
Change the type of the current inode to
|
|
|
|
.Ar type .
|
1998-06-15 07:12:20 +00:00
|
|
|
.Ar Type
|
1995-11-03 22:38:54 +00:00
|
|
|
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
|
2006-08-23 22:44:00 +00:00
|
|
|
.It Cm btime Ar time
|
1995-11-03 22:38:54 +00:00
|
|
|
.It Cm mtime Ar time
|
|
|
|
.It Cm ctime Ar time
|
|
|
|
.It Cm atime Ar time
|
2006-08-23 22:44:00 +00:00
|
|
|
Change the creation (birth), modification, change, or access
|
|
|
|
time (respectively) on the current inode to
|
1995-11-03 22:38:54 +00:00
|
|
|
.Ar time .
|
|
|
|
.Ar Time
|
|
|
|
should be in the format
|
|
|
|
.Em YYYYMMDDHHMMSS[.nsec]
|
|
|
|
where
|
|
|
|
.Em nsec
|
2004-07-02 21:45:06 +00:00
|
|
|
is an optional nanosecond specification.
|
|
|
|
If no nanoseconds are specified, the
|
2006-08-23 22:44:00 +00:00
|
|
|
.Va birthnsec ,
|
1995-11-03 22:38:54 +00:00
|
|
|
.Va mtimensec ,
|
|
|
|
.Va ctimensec ,
|
|
|
|
or
|
2001-07-15 07:53:42 +00:00
|
|
|
.Va atimensec
|
1995-11-03 22:38:54 +00:00
|
|
|
field will be set to zero.
|
2006-08-24 09:14:02 +00:00
|
|
|
Note that
|
|
|
|
.Cm btime
|
|
|
|
is available on UFS2 file systems only.
|
1995-11-03 22:38:54 +00:00
|
|
|
.Pp
|
2001-02-01 16:38:02 +00:00
|
|
|
.It Cm quit , q , exit , Em <EOF>
|
1995-11-03 22:38:54 +00:00
|
|
|
Exit the program.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
1999-04-13 02:42:53 +00:00
|
|
|
.Xr editline 3 ,
|
1995-11-03 22:38:54 +00:00
|
|
|
.Xr fs 5 ,
|
1997-01-13 00:25:51 +00:00
|
|
|
.Xr clri 8 ,
|
|
|
|
.Xr fsck 8
|
1995-11-03 22:38:54 +00:00
|
|
|
.Sh HISTORY
|
2002-07-06 19:34:18 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility uses the source code for
|
1995-11-03 22:38:54 +00:00
|
|
|
.Xr fsck 8
|
2004-07-02 21:45:06 +00:00
|
|
|
to implement most of the file system manipulation code.
|
|
|
|
The remainder of
|
1995-11-03 22:38:54 +00:00
|
|
|
.Nm
|
1998-06-15 07:12:20 +00:00
|
|
|
first appeared in
|
2000-01-23 01:30:05 +00:00
|
|
|
.Nx ,
|
1998-06-15 07:12:20 +00:00
|
|
|
written by
|
|
|
|
.An John T. Kohl .
|
2000-11-10 17:46:15 +00:00
|
|
|
.Pp
|
1998-06-15 07:12:20 +00:00
|
|
|
.An Peter Wemm
|
|
|
|
ported it to
|
2000-01-23 01:30:05 +00:00
|
|
|
.Fx .
|
2005-01-18 10:09:38 +00:00
|
|
|
.Sh BUGS
|
2005-02-12 23:23:53 +00:00
|
|
|
Manipulation of ``short'' symlinks has no effect.
|
|
|
|
In particular, one should not
|
|
|
|
try changing a symlink's type.
|
2005-01-18 10:09:38 +00:00
|
|
|
.Pp
|
|
|
|
You must specify modes as numbers rather than symbolic names.
|
|
|
|
.Pp
|
|
|
|
There are a bunch of other things that you might want to do which
|
|
|
|
.Nm
|
2005-02-12 23:23:53 +00:00
|
|
|
does not implement.
|
1995-11-03 22:38:54 +00:00
|
|
|
.Sh WARNING
|
2003-08-30 07:49:42 +00:00
|
|
|
Use this tool with extreme caution--you can damage an FFS file system
|
1995-11-03 22:38:54 +00:00
|
|
|
beyond what
|
|
|
|
.Xr fsck 8
|
2001-07-15 07:53:42 +00:00
|
|
|
can repair.
|