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