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