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