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