xref: /openbsd/sbin/fsdb/fsdb.8 (revision 3fd4512f)
1*3fd4512fSjmc.\"	$OpenBSD: fsdb.8,v 1.15 2007/02/20 22:23:57 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.
18be0fe854Sniklas.\" 3. All advertising materials mentioning features or use of this software
19be0fe854Sniklas.\"    must display the following acknowledgement:
20be0fe854Sniklas.\"        This product includes software developed by the NetBSD
21be0fe854Sniklas.\"        Foundation, Inc. and its contributors.
22be0fe854Sniklas.\" 4. Neither the name of The NetBSD Foundation nor the names of its
23be0fe854Sniklas.\"    contributors may be used to endorse or promote products derived
24be0fe854Sniklas.\"    from this software without specific prior written permission.
25df930be7Sderaadt.\"
26be0fe854Sniklas.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27be0fe854Sniklas.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28be0fe854Sniklas.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29be0fe854Sniklas.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30be0fe854Sniklas.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31be0fe854Sniklas.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32be0fe854Sniklas.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33be0fe854Sniklas.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34be0fe854Sniklas.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35be0fe854Sniklas.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36df930be7Sderaadt.\" POSSIBILITY OF SUCH DAMAGE.
37df930be7Sderaadt.\"
38df930be7Sderaadt.Dd September 14, 1995
39df930be7Sderaadt.Dt FSDB 8
4019244f19Smichaels.Os
41df930be7Sderaadt.Sh NAME
42df930be7Sderaadt.Nm fsdb
43df930be7Sderaadt.Nd FFS debugging/editing tool
44df930be7Sderaadt.Sh SYNOPSIS
457349792aSaaron.Nm fsdb
46df930be7Sderaadt.Op Fl d
47df930be7Sderaadt.Fl f Ar fsname
48df930be7Sderaadt.Sh DESCRIPTION
49df930be7Sderaadt.Nm
50df930be7Sderaadtopens
51df930be7Sderaadt.Ar fsname
52df930be7Sderaadt(usually a raw disk partition) and runs a command loop
539615e1d4Saaronallowing manipulation of the file system's inode data.
549615e1d4SaaronYou are prompted to enter a command with
55df930be7Sderaadt.Ic "fsdb (inum X)>"
56df930be7Sderaadtwhere
57df930be7Sderaadt.Va X
589615e1d4Saaronis the currently selected i-number.
599615e1d4SaaronThe initial selected inode is the root of the file system (i-number 2).
609615e1d4Saaron.Pp
61df930be7SderaadtThe command processor uses the
623874c371Smillert.Xr editline 3
63df930be7Sderaadtlibrary, so you can use command line editing to reduce typing if desired.
64df930be7SderaadtWhen you exit the command loop, the file system superblock is marked
65df930be7Sderaadtdirty and any buffered blocks are written to the file system.
66df930be7Sderaadt.Pp
679615e1d4SaaronThe options are as follows:
689615e1d4Saaron.Bl -tag -width Ds
699615e1d4Saaron.It Fl d
709615e1d4SaaronEnables additional debugging output (which comes primarily from
71df930be7Sderaadt.Xr fsck 8 -derived
72df930be7Sderaadtcode).
73*3fd4512fSjmc.It Fl f Ar fsname
74*3fd4512fSjmcOpen file system
75*3fd4512fSjmc.Ar fsname .
769615e1d4Saaron.El
779615e1d4Saaron.Pp
78df930be7SderaadtBesides the built-in
793874c371Smillert.Xr editline 3
80df930be7Sderaadtcommands,
81df930be7Sderaadt.Nm
82df930be7Sderaadtsupports these commands:
83df930be7Sderaadt.Pp
84df930be7Sderaadt.Bl -tag -width indent -compact
85df930be7Sderaadt.It Cm help
86df930be7SderaadtPrint out the list of accepted commands.
87df930be7Sderaadt.Pp
88df930be7Sderaadt.It Cm inode Ar i-number
89df930be7SderaadtSelect inode
90df930be7Sderaadt.Ar i-number
91df930be7Sderaadtas the new current inode.
92df930be7Sderaadt.Pp
93df930be7Sderaadt.It Cm back
94df930be7SderaadtRevert to the previously current inode.
95df930be7Sderaadt.Pp
96a354c96aSfgsch.It Cm clri Ar i-number
97a354c96aSfgschClear the inode
98a354c96aSfgsch.Ar i-number .
99df930be7Sderaadt.Pp
1009615e1d4Saaron.It Cm lookup Ar name , Cm cd Ar name
101df930be7SderaadtFind
102df930be7Sderaadt.Ar name
103df930be7Sderaadtin the current directory and make its inode the current inode.
104df930be7Sderaadt.Ar Name
105df930be7Sderaadtmay be a multi-component name or may begin with slash to indicate that
1069615e1d4Saaronthe root inode should be used to start the lookup.
1079615e1d4SaaronIf some component
108df930be7Sderaadtalong the pathname is not found, the last valid directory encountered is
109df930be7Sderaadtleft as the active inode.
110de517754Saaron.Pp
111df930be7SderaadtThis command is valid only if the starting inode is a directory.
112df930be7Sderaadt.Pp
1139615e1d4Saaron.It Cm active , Cm print
114df930be7SderaadtPrint out the active inode.
115df930be7Sderaadt.Pp
116df930be7Sderaadt.It Cm uplink
117df930be7SderaadtIncrement the active inode's link count.
118df930be7Sderaadt.Pp
119df930be7Sderaadt.It Cm downlink
120df930be7SderaadtDecrement the active inode's link count.
121df930be7Sderaadt.Pp
122df930be7Sderaadt.It Cm linkcount Ar number
123df930be7SderaadtSet the active inode's link count to
124df930be7Sderaadt.Ar number .
125df930be7Sderaadt.Pp
126df930be7Sderaadt.It Cm ls
1279615e1d4SaaronList the current inode's directory entries.
1289615e1d4SaaronThis command is valid only if the current inode is a directory.
129df930be7Sderaadt.Pp
1309615e1d4Saaron.It Cm rm Ar name , Cm del Ar name
131df930be7SderaadtRemove the entry
132df930be7Sderaadt.Ar name
1339615e1d4Saaronfrom the current directory inode.
1349615e1d4SaaronThis command is valid only if the current inode is a directory.
135df930be7Sderaadt.Pp
136df930be7Sderaadt.It Cm ln Ar ino Ar name
137df930be7SderaadtCreate a link to inode
138df930be7Sderaadt.Ar ino
139df930be7Sderaadtunder the name
140df930be7Sderaadt.Ar name
1419615e1d4Saaronin the current directory inode.
1429615e1d4SaaronThis command is valid only if the current inode is a directory.
143df930be7Sderaadt.Pp
144df930be7Sderaadt.It Cm chinum Ar dirslot Ar inum
145df930be7SderaadtChange the i-number in directory entry
146df930be7Sderaadt.Ar dirslot
147df930be7Sderaadtto
148df930be7Sderaadt.Ar inum .
149df930be7Sderaadt.Pp
150df930be7Sderaadt.It Cm chname Ar dirslot Ar name
151df930be7SderaadtChange the name in directory entry
152df930be7Sderaadt.Ar dirslot
153df930be7Sderaadtto
154df930be7Sderaadt.Ar name .
1559615e1d4SaaronThis command cannot expand a directory entry.
1569615e1d4SaaronYou can only rename an
157df930be7Sderaadtentry if the name will fit into the existing directory slot.
158df930be7Sderaadt.Pp
159df930be7Sderaadt.It Cm chtype Ar type
160df930be7SderaadtChange the type of the current inode to
161df930be7Sderaadt.Ar type .
162df930be7Sderaadt.Ar type
163df930be7Sderaadtmay be one of:
164df930be7Sderaadt.Em file ,
165df930be7Sderaadt.Em dir ,
166df930be7Sderaadt.Em socket ,
167df930be7Sderaadtor
168df930be7Sderaadt.Em fifo .
169df930be7Sderaadt.Pp
170df930be7Sderaadt.It Cm chmod Ar mode
171df930be7SderaadtChange the mode bits of the current inode to
172df930be7Sderaadt.Ar mode .
173df930be7SderaadtYou cannot change the file type with this subcommand; use
174df930be7Sderaadt.Ic chtype
175df930be7Sderaadtto do that.
176df930be7Sderaadt.Pp
177df930be7Sderaadt.It Cm chflags Ar flags
178df930be7SderaadtChange the file flags of the current inode to
179df930be7Sderaadt.Ar flags .
180df930be7Sderaadt.Pp
181df930be7Sderaadt.It Cm chown Ar uid
182df930be7SderaadtChange the owner of the current inode to
183df930be7Sderaadt.Ar uid .
184df930be7Sderaadt.Pp
18500829d25Smillert.It Cm chlen Ar length
1863874c371SmillertChange the length of the current inode to
18700829d25Smillert.Ar length .
18800829d25Smillert.Pp
189df930be7Sderaadt.It Cm chgrp Ar gid
190df930be7SderaadtChange the group of the current inode to
191df930be7Sderaadt.Ar gid .
192df930be7Sderaadt.Pp
193df930be7Sderaadt.It Cm chgen Ar gen
194df930be7SderaadtChange the generation number of the current inode to
195df930be7Sderaadt.Ar gen .
196df930be7Sderaadt.Pp
1979615e1d4Saaron.It Xo Cm mtime Ar time ,
1989615e1d4Saaron.Cm ctime Ar time ,
1999615e1d4Saaron.Cm atime Ar time
2009615e1d4Saaron.Xc
201df930be7SderaadtChange the modification, change, or access time (respectively) on the
202df930be7Sderaadtcurrent inode to
203df930be7Sderaadt.Ar time .
204df930be7Sderaadt.Ar Time
205df930be7Sderaadtshould be in the format
206df930be7Sderaadt.Em YYYYMMDDHHMMSS[.nsec]
207df930be7Sderaadtwhere
208df930be7Sderaadt.Em nsec
2099615e1d4Saaronis an optional nanosecond specification.
2109615e1d4SaaronIf no nanoseconds are specified, the
211df930be7Sderaadt.Va mtimensec ,
212df930be7Sderaadt.Va ctimensec ,
213df930be7Sderaadtor
214df930be7Sderaadt.Va atimensec
215df930be7Sderaadtfield will be set to zero.
216df930be7Sderaadt.Pp
2179615e1d4Saaron.It Xo Cm quit ,
2189615e1d4Saaron.Cm q , Cm exit, Em <EOF>
2199615e1d4Saaron.Xc
220df930be7SderaadtExit the program.
221df930be7Sderaadt.El
222df930be7Sderaadt.Sh SEE ALSO
2233874c371Smillert.Xr editline 3 ,
224df930be7Sderaadt.Xr fs 5 ,
2257acc01d2Saaron.Xr clri 8 ,
2267acc01d2Saaron.Xr fsck 8
2279615e1d4Saaron.Sh HISTORY
2289615e1d4Saaron.Nm
2299615e1d4Saaronuses the source code for
2309615e1d4Saaron.Xr fsck 8
2319615e1d4Saaronto implement most of the file system manipulation code.
2329615e1d4SaaronThe remainder of
2339615e1d4Saaron.Nm
2349615e1d4Saaronfirst appeared in
2359615e1d4Saaron.Nx 1.1 .
236df930be7Sderaadt.Sh BUGS
23795675cd5SaaronManipulation of
23895675cd5Saaron.Dq short
23995675cd5Saaronsymlinks doesn't work (in particular, don't
240df930be7Sderaadttry changing a symlink's type).
2415eaf1a72Saaron.Pp
242df930be7SderaadtYou must specify modes as numbers rather than symbolic names.
2435eaf1a72Saaron.Pp
244df930be7SderaadtThere are a bunch of other things that you might want to do which
245df930be7Sderaadt.Nm
246df930be7Sderaadtdoesn't implement.
247df930be7Sderaadt.Sh WARNING
248de517754SaaronUse this tool with extreme caution \(en you can damage an FFS file system
249df930be7Sderaadtbeyond what
250df930be7Sderaadt.Xr fsck 8
251df930be7Sderaadtcan repair.
252