]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/fsdb/fsdb.8
zfs: merge openzfs/zfs@9198de8f1
[FreeBSD/FreeBSD.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 .Dd October 3, 2016
30 .Dt FSDB 8
31 .Os
32 .Sh NAME
33 .Nm fsdb
34 .Nd FFS debugging/editing tool
35 .Sh SYNOPSIS
36 .Nm
37 .Op Fl d
38 .Op Fl f
39 .Op Fl r
40 .Ar fsname
41 .Sh DESCRIPTION
42 The
43 .Nm
44 utility opens
45 .Ar fsname
46 (usually a raw disk partition) and runs a command loop
47 allowing manipulation of the file system's inode data.
48 You are prompted
49 to enter a command with
50 .Ic "fsdb (inum X)>"
51 where
52 .Va X
53 is the currently selected i-number.
54 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.
105 If some component
106 along the pathname is not found, the last valid directory encountered is
107 left as the active inode.
108 This command is valid only if the starting inode is a directory.
109 .Pp
110 .It Cm active
111 .It Cm print
112 Print out the active inode.
113 .Pp
114 .It Cm blocks
115 Print out the block list of the active inode.
116 Note that the printout can become long for large files, since all
117 indirect block pointers will also be printed.
118 .Pp
119 .It Cm findblk Ar disk_block_number ...
120 Find the inode(s) owning the specified disk block(s) number(s).
121 Note that these are not absolute disk blocks numbers, but offsets from the
122 start of the partition.
123 .Pp
124 .It Cm uplink
125 Increment the active inode's link count.
126 .Pp
127 .It Cm downlink
128 Decrement the active inode's link count.
129 .Pp
130 .It Cm linkcount Ar number
131 Set the active inode's link count to
132 .Ar number .
133 .Pp
134 .It Cm ls
135 List the current inode's directory entries.
136 This command is valid only
137 if the current inode is a directory.
138 .Pp
139 .It Cm rm Ar name
140 .It Cm del Ar name
141 Remove the entry
142 .Ar name
143 from the current directory inode.
144 This command is valid only
145 if the current inode is a directory.
146 .Pp
147 .It Cm ln Ar ino Ar name
148 Create a link to inode
149 .Ar ino
150 under the name
151 .Ar name
152 in the current directory inode.
153 This command is valid only
154 if the current inode is a directory.
155 .Pp
156 .It Cm chinum Ar dirslot Ar inum
157 Change the i-number in directory entry
158 .Ar dirslot
159 to
160 .Ar inum .
161 .Pp
162 .It Cm chname Ar dirslot Ar name
163 Change the name in directory entry
164 .Ar dirslot
165 to
166 .Ar name .
167 This command cannot expand a directory entry.
168 You can only rename an
169 entry if the name will fit into the existing directory slot.
170 .Pp
171 .It Cm chtype Ar type
172 Change the type of the current inode to
173 .Ar type .
174 .Ar Type
175 may be one of:
176 .Em file ,
177 .Em dir ,
178 .Em socket ,
179 or
180 .Em fifo .
181 .Pp
182 .It Cm chmod Ar mode
183 Change the mode bits of the current inode to
184 .Ar mode .
185 You cannot change the file type with this subcommand; use
186 .Ic chtype
187 to do that.
188 .Pp
189 .It Cm chflags Ar flags
190 Change the file flags of the current inode to
191 .Ar flags .
192 .Pp
193 .It Cm chown Ar uid
194 Change the owner of the current inode to
195 .Ar uid .
196 .Pp
197 .It Cm chgrp Ar gid
198 Change the group of the current inode to
199 .Ar gid .
200 .Pp
201 .It Cm chgen Ar gen
202 Change the generation number of the current inode to
203 .Ar gen .
204 .Pp
205 .It Cm btime Ar time
206 .It Cm mtime Ar time
207 .It Cm ctime Ar time
208 .It Cm atime Ar time
209 Change the creation (birth), modification, change, or access
210 time (respectively) on the current inode to
211 .Ar time .
212 .Ar Time
213 should be in the format
214 .Em YYYYMMDDHHMMSS[.nsec]
215 where
216 .Em nsec
217 is an optional nanosecond specification.
218 If no nanoseconds are specified, the
219 .Va birthnsec ,
220 .Va mtimensec ,
221 .Va ctimensec ,
222 or
223 .Va atimensec
224 field will be set to zero.
225 Note that
226 .Cm btime
227 is available on UFS2 file systems only.
228 .Pp
229 .It Cm quit , q , exit , Em <EOF>
230 Exit the program.
231 .El
232 .Sh SEE ALSO
233 .Xr editline 3 ,
234 .Xr fs 5 ,
235 .Xr clri 8 ,
236 .Xr fsck 8
237 .Sh HISTORY
238 The
239 .Nm
240 utility appeared in
241 .Bx 4.3 Tahoe .
242 It used 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 appeared in
248 .Nx 1.1
249 written by
250 .An John T. Kohl .
251 It first appeared in
252 .Fx 2.1.5
253 ported by Peter Wemm.
254 .Sh BUGS
255 Manipulation of ``short'' symlinks has no effect.
256 In particular, one should not
257 try changing a symlink's type.
258 .Pp
259 You must specify modes as numbers rather than symbolic names.
260 .Pp
261 There are a bunch of other things that you might want to do which
262 .Nm
263 does not implement.
264 .Sh WARNING
265 Use this tool with extreme caution--you can damage an FFS file system
266 beyond what
267 .Xr fsck 8
268 can repair.