xref: /dragonfly/sbin/fsdb/fsdb.8 (revision 2cd2d2b5)
1.\"	$NetBSD: fsdb.8,v 1.2 1995/10/08 23:18:08 thorpej Exp $
2.\"
3.\" Copyright (c) 1995 John T. Kohl
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20.\" DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27.\" POSSIBILITY OF SUCH DAMAGE.
28.\"
29.\" $FreeBSD: src/sbin/fsdb/fsdb.8,v 1.12.2.8 2003/02/23 20:17:15 trhodes Exp $
30.\" $DragonFly: src/sbin/fsdb/fsdb.8,v 1.2 2003/06/17 04:27:32 dillon Exp $
31.\"
32.Dd September 14, 1995
33.Dt FSDB 8
34.Os
35.Sh NAME
36.Nm fsdb
37.Nd FFS debugging/editing tool
38.Sh SYNOPSIS
39.Nm
40.Op Fl d
41.Op Fl f
42.Op Fl r
43.Ar fsname
44.Sh DESCRIPTION
45The
46.Nm
47utility opens
48.Ar fsname
49(usually a raw disk partition) and runs a command loop
50allowing manipulation of the file system's inode data.  You are prompted
51to enter a command with
52.Ic "fsdb (inum X)>"
53where
54.Va X
55is the currently selected i-number.  The initial selected inode is the
56root of the file system (i-number 2).
57The command processor uses the
58.Xr editline 3
59library, so you can use command line editing to reduce typing if desired.
60When you exit the command loop, the file system superblock is marked
61dirty and any buffered blocks are written to the file system.
62.Pp
63The following options are available:
64.Bl -tag -width indent
65.It Fl d
66Enable additional debugging output (which comes primarily from
67.Xr fsck 8 Ns -derived
68code).
69.It Fl f
70Left for historical reasons and has no meaning.
71.It Fl r
72Open the file system read/only, and disables all commands that would
73write to it.
74.El
75.Sh COMMANDS
76Besides the built-in
77.Xr editline 3
78commands,
79.Nm
80supports these commands:
81.Pp
82.Bl -tag -width indent -compact
83.It Cm help
84Print out the list of accepted commands.
85.Pp
86.It Cm inode Ar i-number
87Select inode
88.Ar i-number
89as the new current inode.
90.Pp
91.It Cm back
92Revert to the previously current inode.
93.Pp
94.It Cm clri Ar i-number
95Clear
96.Ar i-number .
97.Pp
98.It Cm lookup Ar name
99.It Cm cd Ar name
100Find
101.Ar name
102in the current directory and make its inode the current inode.
103.Ar Name
104may be a multi-component name or may begin with slash to indicate that
105the root inode should be used to start the lookup.  If some component
106along the pathname is not found, the last valid directory encountered is
107left as the active inode.
108This command is valid only if the starting inode is a directory.
109.Pp
110.It Cm active
111.It Cm print
112Print out the active inode.
113.Pp
114.It Cm blocks
115Print out the block list of the active inode.
116Note that the printout can become long for large files, since all
117indirect block pointers will also be printed.
118.It Cm uplink
119Increment the active inode's link count.
120.Pp
121.It Cm downlink
122Decrement the active inode's link count.
123.Pp
124.It Cm linkcount Ar number
125Set the active inode's link count to
126.Ar number .
127.Pp
128.It Cm ls
129List the current inode's directory entries.  This command is valid only
130if the current inode is a directory.
131.Pp
132.It Cm rm Ar name
133.It Cm del Ar name
134Remove the entry
135.Ar name
136from the current directory inode.  This command is valid only
137if the current inode is a directory.
138.Pp
139.It Cm ln Ar ino Ar name
140Create a link to inode
141.Ar ino
142under the name
143.Ar name
144in the current directory inode.  This command is valid only
145if the current inode is a directory.
146.Pp
147.It Cm chinum Ar dirslot Ar inum
148Change the i-number in directory entry
149.Ar dirslot
150to
151.Ar inum .
152.Pp
153.It Cm chname Ar dirslot Ar name
154Change the name in directory entry
155.Ar dirslot
156to
157.Ar name .
158This command cannot expand a directory entry.  You can only rename an
159entry if the name will fit into the existing directory slot.
160.Pp
161.It Cm chtype Ar type
162Change the type of the current inode to
163.Ar type .
164.Ar Type
165may be one of:
166.Em file ,
167.Em dir ,
168.Em socket ,
169or
170.Em fifo .
171.Pp
172.It Cm chmod Ar mode
173Change the mode bits of the current inode to
174.Ar mode .
175You cannot change the file type with this subcommand; use
176.Ic chtype
177to do that.
178.Pp
179.It Cm chflags Ar flags
180Change the file flags of the current inode to
181.Ar flags .
182.Pp
183.It Cm chown Ar uid
184Change the owner of the current inode to
185.Ar uid .
186.Pp
187.It Cm chgrp Ar gid
188Change the group of the current inode to
189.Ar gid .
190.Pp
191.It Cm chgen Ar gen
192Change the generation number of the current inode to
193.Ar gen .
194.Pp
195.It Cm mtime Ar time
196.It Cm ctime Ar time
197.It Cm atime Ar time
198Change the modification, change, or access time (respectively) on the
199current inode to
200.Ar time .
201.Ar Time
202should be in the format
203.Em YYYYMMDDHHMMSS[.nsec]
204where
205.Em nsec
206is an optional nanosecond specification.  If no nanoseconds are specified, the
207.Va mtimensec ,
208.Va ctimensec ,
209or
210.Va atimensec
211field will be set to zero.
212.Pp
213.It Cm quit , q , exit , Em <EOF>
214Exit the program.
215.El
216.Sh SEE ALSO
217.Xr editline 3 ,
218.Xr fs 5 ,
219.Xr clri 8 ,
220.Xr fsck 8
221.Sh BUGS
222Manipulation of ``short'' symlinks doesn't work (in particular, don't
223try changing a symlink's type).
224.Pp
225You must specify modes as numbers rather than symbolic names.
226.Pp
227There are a bunch of other things that you might want to do which
228.Nm
229doesn't implement.
230.Sh HISTORY
231The
232.Nm
233utility uses the source code for
234.Xr fsck 8
235to implement most of the file system manipulation code.  The remainder of
236.Nm
237first appeared in
238.Nx ,
239written by
240.An John T. Kohl .
241.Pp
242.An Peter Wemm
243ported it to
244.Fx .
245.Sh WARNING
246Use this tool with extreme caution--you can damage an FFS file system
247beyond what
248.Xr fsck 8
249can repair.
250