xref: /freebsd/sbin/fsdb/fsdb.8 (revision 9806e231322307da0109e101ae2ef997a4a22290)
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 September 14, 1995
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.It Cm uplink
121Increment the active inode's link count.
122.Pp
123.It Cm downlink
124Decrement the active inode's link count.
125.Pp
126.It Cm linkcount Ar number
127Set the active inode's link count to
128.Ar number .
129.Pp
130.It Cm ls
131List the current inode's directory entries.
132This command is valid only
133if the current inode is a directory.
134.Pp
135.It Cm rm Ar name
136.It Cm del Ar name
137Remove the entry
138.Ar name
139from the current directory inode.
140This command is valid only
141if the current inode is a directory.
142.Pp
143.It Cm ln Ar ino Ar name
144Create a link to inode
145.Ar ino
146under the name
147.Ar name
148in the current directory inode.
149This command is valid only
150if the current inode is a directory.
151.Pp
152.It Cm chinum Ar dirslot Ar inum
153Change the i-number in directory entry
154.Ar dirslot
155to
156.Ar inum .
157.Pp
158.It Cm chname Ar dirslot Ar name
159Change the name in directory entry
160.Ar dirslot
161to
162.Ar name .
163This command cannot expand a directory entry.
164You can only rename an
165entry if the name will fit into the existing directory slot.
166.Pp
167.It Cm chtype Ar type
168Change the type of the current inode to
169.Ar type .
170.Ar Type
171may be one of:
172.Em file ,
173.Em dir ,
174.Em socket ,
175or
176.Em fifo .
177.Pp
178.It Cm chmod Ar mode
179Change the mode bits of the current inode to
180.Ar mode .
181You cannot change the file type with this subcommand; use
182.Ic chtype
183to do that.
184.Pp
185.It Cm chflags Ar flags
186Change the file flags of the current inode to
187.Ar flags .
188.Pp
189.It Cm chown Ar uid
190Change the owner of the current inode to
191.Ar uid .
192.Pp
193.It Cm chgrp Ar gid
194Change the group of the current inode to
195.Ar gid .
196.Pp
197.It Cm chgen Ar gen
198Change the generation number of the current inode to
199.Ar gen .
200.Pp
201.It Cm mtime Ar time
202.It Cm ctime Ar time
203.It Cm atime Ar time
204Change the modification, change, or access time (respectively) on the
205current inode to
206.Ar time .
207.Ar Time
208should be in the format
209.Em YYYYMMDDHHMMSS[.nsec]
210where
211.Em nsec
212is an optional nanosecond specification.
213If no nanoseconds are specified, the
214.Va mtimensec ,
215.Va ctimensec ,
216or
217.Va atimensec
218field will be set to zero.
219.Pp
220.It Cm quit , q , exit , Em <EOF>
221Exit the program.
222.El
223.Sh SEE ALSO
224.Xr editline 3 ,
225.Xr fs 5 ,
226.Xr clri 8 ,
227.Xr fsck 8
228.Sh BUGS
229Manipulation of ``short'' symlinks doesn't work (in particular, don't
230try changing a symlink's type).
231.Pp
232You must specify modes as numbers rather than symbolic names.
233.Pp
234There are a bunch of other things that you might want to do which
235.Nm
236doesn't implement.
237.Sh HISTORY
238The
239.Nm
240utility uses the source code for
241.Xr fsck 8
242to implement most of the file system manipulation code.
243The remainder of
244.Nm
245first appeared in
246.Nx ,
247written by
248.An John T. Kohl .
249.Pp
250.An Peter Wemm
251ported it to
252.Fx .
253.Sh WARNING
254Use this tool with extreme caution--you can damage an FFS file system
255beyond what
256.Xr fsck 8
257can repair.
258