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