xref: /freebsd/sbin/fsdb/fsdb.8 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
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.Dd October 3, 2016
30.Dt FSDB 8
31.Os
32.Sh NAME
33.Nm fsdb
34.Nd FFS debugging/editing tool
35.Sh SYNOPSIS
36.Nm
37.Op Fl d
38.Op Fl f
39.Op Fl r
40.Ar fsname
41.Sh DESCRIPTION
42The
43.Nm
44utility opens
45.Ar fsname
46(usually a raw disk partition) and runs a command loop
47allowing manipulation of the file system's inode data.
48You are prompted
49to enter a command with
50.Ic "fsdb (inum X)>"
51where
52.Va X
53is the currently selected i-number.
54The initial selected inode is the
55root of the file system (i-number 2).
56The command processor uses the
57.Xr editline 3
58library, so you can use command line editing to reduce typing if desired.
59When you exit the command loop, the file system superblock is marked
60dirty and any buffered blocks are written to the file system.
61.Pp
62The following options are available:
63.Bl -tag -width indent
64.It Fl d
65Enable additional debugging output (which comes primarily from
66.Xr fsck 8 Ns -derived
67code).
68.It Fl f
69Left for historical reasons and has no meaning.
70.It Fl r
71Open the file system read/only, and disables all commands that would
72write to it.
73.El
74.Sh COMMANDS
75Besides the built-in
76.Xr editline 3
77commands,
78.Nm
79supports these commands:
80.Pp
81.Bl -tag -width indent -compact
82.It Cm help
83Print out the list of accepted commands.
84.Pp
85.It Cm inode Ar i-number
86Select inode
87.Ar i-number
88as the new current inode.
89.Pp
90.It Cm back
91Revert to the previously current inode.
92.Pp
93.It Cm clri Ar i-number
94Clear
95.Ar i-number .
96.Pp
97.It Cm lookup Ar name
98.It Cm cd Ar name
99Find
100.Ar name
101in the current directory and make its inode the current inode.
102.Ar Name
103may be a multi-component name or may begin with slash to indicate that
104the root inode should be used to start the lookup.
105If 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.Pp
119.It Cm findblk Ar disk_block_number ...
120Find the inode(s) owning the specified disk block(s) number(s).
121Note that these are not absolute disk blocks numbers, but offsets from the
122start of the partition.
123.Pp
124.It Cm uplink
125Increment the active inode's link count.
126.Pp
127.It Cm downlink
128Decrement the active inode's link count.
129.Pp
130.It Cm linkcount Ar number
131Set the active inode's link count to
132.Ar number .
133.Pp
134.It Cm ls
135List the current inode's directory entries.
136This command is valid only
137if the current inode is a directory.
138.Pp
139.It Cm rm Ar name
140.It Cm del Ar name
141Remove the entry
142.Ar name
143from the current directory inode.
144This command is valid only
145if the current inode is a directory.
146.Pp
147.It Cm ln Ar ino Ar name
148Create a link to inode
149.Ar ino
150under the name
151.Ar name
152in the current directory inode.
153This command is valid only
154if the current inode is a directory.
155.Pp
156.It Cm chinum Ar dirslot Ar inum
157Change the i-number in directory entry
158.Ar dirslot
159to
160.Ar inum .
161.Pp
162.It Cm chname Ar dirslot Ar name
163Change the name in directory entry
164.Ar dirslot
165to
166.Ar name .
167This command cannot expand a directory entry.
168You can only rename an
169entry if the name will fit into the existing directory slot.
170.Pp
171.It Cm chtype Ar type
172Change the type of the current inode to
173.Ar type .
174.Ar Type
175may be one of:
176.Em file ,
177.Em dir ,
178.Em socket ,
179or
180.Em fifo .
181.Pp
182.It Cm chmod Ar mode
183Change the mode bits of the current inode to
184.Ar mode .
185You cannot change the file type with this subcommand; use
186.Ic chtype
187to do that.
188.Pp
189.It Cm chflags Ar flags
190Change the file flags of the current inode to
191.Ar flags .
192.Pp
193.It Cm chown Ar uid
194Change the owner of the current inode to
195.Ar uid .
196.Pp
197.It Cm chgrp Ar gid
198Change the group of the current inode to
199.Ar gid .
200.Pp
201.It Cm chgen Ar gen
202Change the generation number of the current inode to
203.Ar gen .
204.Pp
205.It Cm btime Ar time
206.It Cm mtime Ar time
207.It Cm ctime Ar time
208.It Cm atime Ar time
209Change the creation (birth), modification, change, or access
210time (respectively) on the current inode to
211.Ar time .
212.Ar Time
213should be in the format
214.Em YYYYMMDDHHMMSS[.nsec]
215where
216.Em nsec
217is an optional nanosecond specification.
218If no nanoseconds are specified, the
219.Va birthnsec ,
220.Va mtimensec ,
221.Va ctimensec ,
222or
223.Va atimensec
224field will be set to zero.
225Note that
226.Cm btime
227is available on UFS2 file systems only.
228.Pp
229.It Cm quit , q , exit , Em <EOF>
230Exit the program.
231.El
232.Sh SEE ALSO
233.Xr editline 3 ,
234.Xr fs 5 ,
235.Xr clri 8 ,
236.Xr fsck 8
237.Sh HISTORY
238The
239.Nm
240utility appeared in
241.Bx 4.3 Tahoe .
242It used the source code for
243.Xr fsck 8
244to implement most of the file system manipulation code.
245The remainder of
246.Nm
247appeared in
248.Nx 1.1
249written by
250.An John T. Kohl .
251It first appeared in
252.Fx 2.1.5
253ported by Peter Wemm.
254.Sh BUGS
255Manipulation of ``short'' symlinks has no effect.
256In particular, one should not
257try changing a symlink's type.
258.Pp
259You must specify modes as numbers rather than symbolic names.
260.Pp
261There are a bunch of other things that you might want to do which
262.Nm
263does not implement.
264.Sh WARNING
265Use this tool with extreme caution--you can damage an FFS file system
266beyond what
267.Xr fsck 8
268can repair.
269