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