xref: /openbsd/sbin/fsdb/fsdb.8 (revision 48c01a1f)
1*48c01a1fSjmc.\"	$OpenBSD: fsdb.8,v 1.20 2020/04/23 21:28:08 jmc Exp $
200829d25Smillert.\"	$NetBSD: fsdb.8,v 1.5 1997/01/11 05:51:40 lukem Exp $
3df930be7Sderaadt.\"
4be0fe854Sniklas.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
5df930be7Sderaadt.\" All rights reserved.
6df930be7Sderaadt.\"
7be0fe854Sniklas.\" This code is derived from software contributed to The NetBSD Foundation
8be0fe854Sniklas.\" by John T. Kohl.
9be0fe854Sniklas.\"
10df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without
11df930be7Sderaadt.\" modification, are permitted provided that the following conditions
12df930be7Sderaadt.\" are met:
13df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright
14df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer.
15df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright
16df930be7Sderaadt.\"    notice, this list of conditions and the following disclaimer in the
17df930be7Sderaadt.\"    documentation and/or other materials provided with the distribution.
18df930be7Sderaadt.\"
19be0fe854Sniklas.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20be0fe854Sniklas.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21be0fe854Sniklas.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22be0fe854Sniklas.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
23be0fe854Sniklas.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24be0fe854Sniklas.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25be0fe854Sniklas.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26be0fe854Sniklas.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27be0fe854Sniklas.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28be0fe854Sniklas.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29df930be7Sderaadt.\" POSSIBILITY OF SUCH DAMAGE.
30df930be7Sderaadt.\"
31*48c01a1fSjmc.Dd $Mdocdate: April 23 2020 $
32df930be7Sderaadt.Dt FSDB 8
3319244f19Smichaels.Os
34df930be7Sderaadt.Sh NAME
35df930be7Sderaadt.Nm fsdb
36df930be7Sderaadt.Nd FFS debugging/editing tool
37df930be7Sderaadt.Sh SYNOPSIS
387349792aSaaron.Nm fsdb
39df930be7Sderaadt.Op Fl d
40df930be7Sderaadt.Fl f Ar fsname
41df930be7Sderaadt.Sh DESCRIPTION
42df930be7Sderaadt.Nm
43df930be7Sderaadtopens
44df930be7Sderaadt.Ar fsname
45df930be7Sderaadt(usually a raw disk partition) and runs a command loop
469615e1d4Saaronallowing manipulation of the file system's inode data.
479615e1d4SaaronYou are prompted to enter a command with
48df930be7Sderaadt.Ic "fsdb (inum X)>"
49df930be7Sderaadtwhere
50df930be7Sderaadt.Va X
519615e1d4Saaronis the currently selected i-number.
529615e1d4SaaronThe initial selected inode is the root of the file system (i-number 2).
539615e1d4Saaron.Pp
54df930be7SderaadtThe command processor uses the
553874c371Smillert.Xr editline 3
56df930be7Sderaadtlibrary, so you can use command line editing to reduce typing if desired.
57df930be7SderaadtWhen you exit the command loop, the file system superblock is marked
58df930be7Sderaadtdirty and any buffered blocks are written to the file system.
59df930be7Sderaadt.Pp
609615e1d4SaaronThe options are as follows:
619615e1d4Saaron.Bl -tag -width Ds
629615e1d4Saaron.It Fl d
639615e1d4SaaronEnables additional debugging output (which comes primarily from
64bf1c21e6Sschwarze.Xr fsck 8 Ns -derived
65df930be7Sderaadtcode).
663fd4512fSjmc.It Fl f Ar fsname
673fd4512fSjmcOpen file system
683fd4512fSjmc.Ar fsname .
699615e1d4Saaron.El
709615e1d4Saaron.Pp
71df930be7SderaadtBesides the built-in
723874c371Smillert.Xr editline 3
73df930be7Sderaadtcommands,
74df930be7Sderaadt.Nm
75df930be7Sderaadtsupports these commands:
76df930be7Sderaadt.Pp
77df930be7Sderaadt.Bl -tag -width indent -compact
78df930be7Sderaadt.It Cm help
79df930be7SderaadtPrint out the list of accepted commands.
80df930be7Sderaadt.Pp
81df930be7Sderaadt.It Cm inode Ar i-number
82df930be7SderaadtSelect inode
83df930be7Sderaadt.Ar i-number
84df930be7Sderaadtas the new current inode.
85df930be7Sderaadt.Pp
86df930be7Sderaadt.It Cm back
87df930be7SderaadtRevert to the previously current inode.
88df930be7Sderaadt.Pp
89a354c96aSfgsch.It Cm clri Ar i-number
90a354c96aSfgschClear the inode
91a354c96aSfgsch.Ar i-number .
92df930be7Sderaadt.Pp
939615e1d4Saaron.It Cm lookup Ar name , Cm cd Ar name
94df930be7SderaadtFind
95df930be7Sderaadt.Ar name
96df930be7Sderaadtin the current directory and make its inode the current inode.
97df930be7Sderaadt.Ar Name
98df930be7Sderaadtmay be a multi-component name or may begin with slash to indicate that
999615e1d4Saaronthe root inode should be used to start the lookup.
1009615e1d4SaaronIf some component
101df930be7Sderaadtalong the pathname is not found, the last valid directory encountered is
102df930be7Sderaadtleft as the active inode.
103de517754Saaron.Pp
104df930be7SderaadtThis command is valid only if the starting inode is a directory.
105df930be7Sderaadt.Pp
1069615e1d4Saaron.It Cm active , Cm print
107df930be7SderaadtPrint out the active inode.
108df930be7Sderaadt.Pp
109df930be7Sderaadt.It Cm uplink
110df930be7SderaadtIncrement the active inode's link count.
111df930be7Sderaadt.Pp
112df930be7Sderaadt.It Cm downlink
113df930be7SderaadtDecrement the active inode's link count.
114df930be7Sderaadt.Pp
115df930be7Sderaadt.It Cm linkcount Ar number
116df930be7SderaadtSet the active inode's link count to
117df930be7Sderaadt.Ar number .
118df930be7Sderaadt.Pp
119df930be7Sderaadt.It Cm ls
1209615e1d4SaaronList the current inode's directory entries.
1219615e1d4SaaronThis command is valid only if the current inode is a directory.
122df930be7Sderaadt.Pp
1239615e1d4Saaron.It Cm rm Ar name , Cm del Ar name
124df930be7SderaadtRemove the entry
125df930be7Sderaadt.Ar name
1269615e1d4Saaronfrom the current directory inode.
1279615e1d4SaaronThis command is valid only if the current inode is a directory.
128df930be7Sderaadt.Pp
129*48c01a1fSjmc.It Cm ln Ar ino name
130df930be7SderaadtCreate a link to inode
131df930be7Sderaadt.Ar ino
132df930be7Sderaadtunder the name
133df930be7Sderaadt.Ar name
1349615e1d4Saaronin the current directory inode.
1359615e1d4SaaronThis command is valid only if the current inode is a directory.
136df930be7Sderaadt.Pp
137*48c01a1fSjmc.It Cm chinum Ar dirslot inum
138df930be7SderaadtChange the i-number in directory entry
139df930be7Sderaadt.Ar dirslot
140df930be7Sderaadtto
141df930be7Sderaadt.Ar inum .
142df930be7Sderaadt.Pp
143*48c01a1fSjmc.It Cm chname Ar dirslot name
144df930be7SderaadtChange the name in directory entry
145df930be7Sderaadt.Ar dirslot
146df930be7Sderaadtto
147df930be7Sderaadt.Ar name .
1489615e1d4SaaronThis command cannot expand a directory entry.
1499615e1d4SaaronYou can only rename an
150df930be7Sderaadtentry if the name will fit into the existing directory slot.
151df930be7Sderaadt.Pp
152df930be7Sderaadt.It Cm chtype Ar type
153df930be7SderaadtChange the type of the current inode to
154df930be7Sderaadt.Ar type .
155df930be7Sderaadt.Ar type
156df930be7Sderaadtmay be one of:
157df930be7Sderaadt.Em file ,
158df930be7Sderaadt.Em dir ,
159df930be7Sderaadt.Em socket ,
160df930be7Sderaadtor
161df930be7Sderaadt.Em fifo .
162df930be7Sderaadt.Pp
163df930be7Sderaadt.It Cm chmod Ar mode
164df930be7SderaadtChange the mode bits of the current inode to
165df930be7Sderaadt.Ar mode .
166df930be7SderaadtYou cannot change the file type with this subcommand; use
167df930be7Sderaadt.Ic chtype
168df930be7Sderaadtto do that.
169df930be7Sderaadt.Pp
170df930be7Sderaadt.It Cm chflags Ar flags
171df930be7SderaadtChange the file flags of the current inode to
172df930be7Sderaadt.Ar flags .
173df930be7Sderaadt.Pp
174df930be7Sderaadt.It Cm chown Ar uid
175df930be7SderaadtChange the owner of the current inode to
176df930be7Sderaadt.Ar uid .
177df930be7Sderaadt.Pp
17800829d25Smillert.It Cm chlen Ar length
1793874c371SmillertChange the length of the current inode to
18000829d25Smillert.Ar length .
18100829d25Smillert.Pp
182df930be7Sderaadt.It Cm chgrp Ar gid
183df930be7SderaadtChange the group of the current inode to
184df930be7Sderaadt.Ar gid .
185df930be7Sderaadt.Pp
186df930be7Sderaadt.It Cm chgen Ar gen
187df930be7SderaadtChange the generation number of the current inode to
188df930be7Sderaadt.Ar gen .
189df930be7Sderaadt.Pp
1909615e1d4Saaron.It Xo Cm mtime Ar time ,
1919615e1d4Saaron.Cm ctime Ar time ,
1929615e1d4Saaron.Cm atime Ar time
1939615e1d4Saaron.Xc
194df930be7SderaadtChange the modification, change, or access time (respectively) on the
195df930be7Sderaadtcurrent inode to
196df930be7Sderaadt.Ar time .
197df930be7Sderaadt.Ar Time
198df930be7Sderaadtshould be in the format
199df930be7Sderaadt.Em YYYYMMDDHHMMSS[.nsec]
200df930be7Sderaadtwhere
201df930be7Sderaadt.Em nsec
2029615e1d4Saaronis an optional nanosecond specification.
2039615e1d4SaaronIf no nanoseconds are specified, the
204df930be7Sderaadt.Va mtimensec ,
205df930be7Sderaadt.Va ctimensec ,
206df930be7Sderaadtor
207df930be7Sderaadt.Va atimensec
208df930be7Sderaadtfield will be set to zero.
209df930be7Sderaadt.Pp
2101dbbcc3aSschwarze.It Cm quit , q , exit , Em <EOF>
211df930be7SderaadtExit the program.
212df930be7Sderaadt.El
213df930be7Sderaadt.Sh SEE ALSO
2143874c371Smillert.Xr editline 3 ,
215df930be7Sderaadt.Xr fs 5 ,
2167acc01d2Saaron.Xr clri 8 ,
2177acc01d2Saaron.Xr fsck 8
2189615e1d4Saaron.Sh HISTORY
2199615e1d4Saaron.Nm
2209615e1d4Saaronuses the source code for
2219615e1d4Saaron.Xr fsck 8
2229615e1d4Saaronto implement most of the file system manipulation code.
2239615e1d4SaaronThe remainder of
2249615e1d4Saaron.Nm
2259615e1d4Saaronfirst appeared in
2269615e1d4Saaron.Nx 1.1 .
227df930be7Sderaadt.Sh BUGS
22895675cd5SaaronManipulation of
22995675cd5Saaron.Dq short
23095675cd5Saaronsymlinks doesn't work (in particular, don't
231df930be7Sderaadttry changing a symlink's type).
2325eaf1a72Saaron.Pp
233df930be7SderaadtYou must specify modes as numbers rather than symbolic names.
2345eaf1a72Saaron.Pp
235df930be7SderaadtThere are a bunch of other things that you might want to do which
236df930be7Sderaadt.Nm
237df930be7Sderaadtdoesn't implement.
238df930be7Sderaadt.Sh WARNING
239de517754SaaronUse this tool with extreme caution \(en you can damage an FFS file system
240df930be7Sderaadtbeyond what
241df930be7Sderaadt.Xr fsck 8
242df930be7Sderaadtcan repair.
243