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