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