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