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