1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
.\" $NetBSD: fsdb.8,v 1.2 1995/10/08 23:18:08 thorpej Exp $
.\"
.\" Copyright (c) 1995 John T. Kohl
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd September 14, 1995
.Dt FSDB 8
.Os
.Sh NAME
.Nm fsdb
.Nd FFS debugging/editing tool
.Sh SYNOPSIS
.Nm
.Op Fl d
.Op Fl f
.Op Fl r
.Ar fsname
.Sh DESCRIPTION
.Nm Fsdb
opens
.Ar fsname
(usually a raw disk partition) and runs a command loop
allowing manipulation of the file system's inode data. You are prompted
to enter a command with
.Ic "fsdb (inum X)>"
where
.Va X
is the currently selected i-number. The initial selected inode is the
root of the filesystem (i-number 2).
The command processor uses the
.Xr editline 3
library, so you can use command line editing to reduce typing if desired.
When you exit the command loop, the file system superblock is marked
dirty and any buffered blocks are written to the file system.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl d
Enable additional debugging output (which comes primarily from
.Xr fsck 8 Ns -derived
code).
.It Fl f
Left for historical reasons and has no meaning.
.It Fl r
Open the filesystem read/only, and disables all commands that would
write to it.
.El
.Sh COMMANDS
Besides the built-in
.Xr editline 3
commands,
.Nm
supports these commands:
.Pp
.Bl -tag -width indent -compact
.It Cm help
Print out the list of accepted commands.
.Pp
.It Cm inode Ar i-number
Select inode
.Ar i-number
as the new current inode.
.Pp
.It Cm back
Revert to the previously current inode.
.Pp
.It Cm clri Ar i-number
Clear
.Ar i-number .
.Pp
.It Cm lookup Ar name
.It Cm cd Ar name
Find
.Ar name
in the current directory and make its inode the current inode.
.Ar Name
may be a multi-component name or may begin with slash to indicate that
the root inode should be used to start the lookup. If some component
along the pathname is not found, the last valid directory encountered is
left as the active inode.
This command is valid only if the starting inode is a directory.
.Pp
.It Cm active
.It Cm print
Print out the active inode.
.Pp
.It Cm uplink
Increment the active inode's link count.
.Pp
.It Cm downlink
Decrement the active inode's link count.
.Pp
.It Cm linkcount Ar number
Set the active inode's link count to
.Ar number .
.Pp
.It Cm ls
List the current inode's directory entries. This command is valid only
if the current inode is a directory.
.Pp
.It Cm rm Ar name
.It Cm del Ar name
Remove the entry
.Ar name
from the current directory inode. This command is valid only
if the current inode is a directory.
.Pp
.It Cm ln Ar ino Ar name
Create a link to inode
.Ar ino
under the name
.Ar name
in the current directory inode. This command is valid only
if the current inode is a directory.
.Pp
.It Cm chinum Ar dirslot Ar inum
Change the i-number in directory entry
.Ar dirslot
to
.Ar inum .
.Pp
.It Cm chname Ar dirslot Ar name
Change the name in directory entry
.Ar dirslot
to
.Ar name .
This command cannot expand a directory entry. You can only rename an
entry if the name will fit into the existing directory slot.
.Pp
.It Cm chtype Ar type
Change the type of the current inode to
.Ar type .
.Ar Type
may be one of:
.Em file ,
.Em dir ,
.Em socket ,
or
.Em fifo .
.Pp
.It Cm chmod Ar mode
Change the mode bits of the current inode to
.Ar mode .
You cannot change the file type with this subcommand; use
.Ic chtype
to do that.
.Pp
.It Cm chflags Ar flags
Change the file flags of the current inode to
.Ar flags .
.Pp
.It Cm chown Ar uid
Change the owner of the current inode to
.Ar uid .
.Pp
.It Cm chgrp Ar gid
Change the group of the current inode to
.Ar gid .
.Pp
.It Cm chgen Ar gen
Change the generation number of the current inode to
.Ar gen .
.Pp
.It Cm mtime Ar time
.It Cm ctime Ar time
.It Cm atime Ar time
Change the modification, change, or access time (respectively) on the
current inode to
.Ar time .
.Ar Time
should be in the format
.Em YYYYMMDDHHMMSS[.nsec]
where
.Em nsec
is an optional nanosecond specification. If no nanoseconds are specified, the
.Va mtimensec ,
.Va ctimensec ,
or
.Va atimensec
field will be set to zero.
.Pp
.It Cm quit , q , exit , Em <EOF>
Exit the program.
.El
.Sh SEE ALSO
.Xr editline 3 ,
.Xr fs 5 ,
.Xr clri 8 ,
.Xr fsck 8
.Sh BUGS
Manipulation of ``short'' symlinks doesn't work (in particular, don't
try changing a symlink's type).
.Pp
You must specify modes as numbers rather than symbolic names.
.Pp
There are a bunch of other things that you might want to do which
.Nm
doesn't implement.
.Sh HISTORY
.Nm Fsdb
uses the source code for
.Xr fsck 8
to implement most of the file system manipulation code. The remainder of
.Nm
first appeared in
.Nx ,
written by
.An John T. Kohl .
.Pp
.An Peter Wemm
ported it to
.Fx .
.Sh WARNING
Use this tool with extreme caution--you can damage an FFS file system
beyond what
.Xr fsck 8
can repair.
|