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