1.\" $NetBSD: fsdb.8,v 1.13 2002/02/08 01:30:43 ross Exp $ 2.\" 3.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by John T. Kohl. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd September 14, 1995 38.Dt FSDB 8 39.Os 40.Sh NAME 41.Nm fsdb 42.Nd FFS debugging/editing tool 43.Sh SYNOPSIS 44.Nm 45.Op Fl d 46.Op Fl n 47.Fl f Ar fsname 48.Sh DESCRIPTION 49.Nm 50opens 51.Ar fsname 52(usually a raw disk partition) and runs a command loop 53allowing manipulation of the file system's inode data. You are prompted 54to enter a command with 55.Dq "fsdb (inum X)\*[Gt]" 56where 57.Va X 58is the currently selected i-number. The initial selected inode is the 59root of the filesystem (i-number 2). 60The command processor uses the 61.Xr editline 3 62library, so you can use command line editing to reduce typing if desired. 63When you exit the command loop, the file system superblock is marked 64dirty and any buffered blocks are written to the file system. 65.Pp 66The 67.Fl d 68option enables additional debugging output (which comes primarily from 69.Xr fsck 8 -derived 70code). 71.Pp 72The 73.Fl n 74option disable writing to the device, preventing any changes from being made 75to the filesystem. 76.Sh COMMANDS 77Besides the built-in 78.Xr editline 3 79commands, 80.Nm 81supports these commands: 82.Pp 83.Bl -tag -width indent -compact 84.It Cm help 85Print out the list of accepted commands. 86.Pp 87.It Cm inode Ar i-number 88Select inode 89.Ar i-number 90as the new current inode. 91.Pp 92.It Cm back 93Revert to the previously current inode. 94.Pp 95.It Cm clri 96Clear the current inode. 97.Pp 98.It Cm lookup Ar name 99.It Cm cd Ar name 100Find 101.Ar name 102in the current directory and make its inode the current inode. 103.Ar Name 104may be a multi-component name or may begin with slash to indicate that 105the root inode should be used to start the lookup. If some component 106along the pathname is not found, the last valid directory encountered is 107left as the active inode. 108.br 109This command is valid only if the starting inode is a directory. 110.Pp 111.It Cm active 112.It Cm print 113Print out the active inode. 114.Pp 115.It Cm uplink 116Increment the active inode's link count. 117.Pp 118.It Cm downlink 119Decrement the active inode's link count. 120.Pp 121.It Cm linkcount Ar number 122Set the active inode's link count to 123.Ar number . 124.Pp 125.It Cm ls 126List the current inode's directory entries. This command is valid only 127if the current inode is a directory. 128.Pp 129.It Cm blks 130List the current inode's blocks numbers. 131.Pp 132.It Cm rm Ar name 133.It Cm del Ar name 134Remove the entry 135.Ar name 136from the current directory inode. This command is valid only 137if the current inode is a directory. 138.Pp 139.It Cm ln Ar ino Ar name 140Create a link to inode 141.Ar ino 142under the name 143.Ar name 144in the current directory inode. This command is valid only 145if the current inode is a directory. 146.Pp 147.It Cm chinum Ar dirslot Ar inum 148Change the i-number in directory entry 149.Ar dirslot 150to 151.Ar inum . 152.Pp 153.It Cm chname Ar dirslot Ar name 154Change the name in directory entry 155.Ar dirslot 156to 157.Ar name . 158This command cannot expand a directory entry. You can only rename an 159entry if the name will fit into the existing directory slot. 160.Pp 161.It Cm chtype Ar type 162Change the type of the current inode to 163.Ar type . 164.Ar type 165may be one of: 166.Em file , 167.Em dir , 168.Em socket , 169or 170.Em fifo . 171.Pp 172.It Cm chmod Ar mode 173Change the mode bits of the current inode to 174.Ar mode . 175You cannot change the file type with this subcommand; use 176.Ic chtype 177to do that. 178.Pp 179.It Cm chflags Ar flags 180Change the file flags of the current inode to 181.Ar flags . 182.Pp 183.It Cm chown Ar uid 184Change the owner of the current inode to 185.Ar uid . 186.Pp 187.It Cm chgrp Ar gid 188Change the group of the current inode to 189.Ar gid . 190.Pp 191.It Cm chgen Ar gen 192Change the generation number of the current inode to 193.Ar gen . 194.Pp 195.It Cm mtime Ar time 196.It Cm ctime Ar time 197.It Cm atime Ar time 198Change the modification, change, or access time (respectively) on the 199current inode to 200.Ar time . 201.Ar Time 202should be in the format 203.Em YYYYMMDDHHMMSS[.nsec] 204where 205.Em nsec 206is an optional nanosecond specification. If no nanoseconds are specified, the 207.Va mtimensec , 208.Va ctimensec , 209or 210.Va atimensec 211field will be set to zero. 212.Pp 213.It Cm quit, Cm q, Cm exit, Em \*[Lt]EOF\*[Gt] 214Exit the program. 215.El 216.Sh SEE ALSO 217.Xr editline 3 , 218.Xr fs 5 , 219.Xr clri 8 , 220.Xr fsck 8 221.Sh HISTORY 222.Nm 223uses the source code for 224.Xr fsck 8 225to implement most of the file system manipulation code. The remainder of 226.Nm 227first appeared in 228.Nx 1.1 . 229.Sh WARNING 230Use this tool with extreme caution -- you can damage an FFS file system 231beyond what 232.Xr fsck 8 233can repair. 234.Sh BUGS 235Manipulation of ``short'' symlinks doesn't work (in particular, don't 236try changing a symlink's type). 237.br 238You must specify modes as numbers rather than symbolic names. 239.br 240There are a bunch of other things that you might want to do which 241.Nm 242doesn't implement. 243