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