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