1.\" $NetBSD: fsdb.8,v 1.23 2014/03/03 12:12:18 blymn 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.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd January 3, 2004 31.Dt FSDB 8 32.Os 33.Sh NAME 34.Nm fsdb 35.Nd FFS debugging/editing tool 36.Sh SYNOPSIS 37.Nm 38.Op Fl dFn 39.Fl f 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. 46You are prompted to enter a command with 47.Dq "fsdb (inum X)\*[Gt]" 48where 49.Va X 50is the currently selected i-number. 51The initial selected inode is the root of the filesystem (i-number 2). 52The command processor uses the 53.Xr editline 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 Ns -derived 62code). 63.Pp 64The 65.Fl F 66option indicates that 67.Ar filesystem 68is a file system image, rather than a raw character device. 69It will be accessed 70.Sq as-is , 71and no attempts will be made to read a disklabel. 72.Pp 73The 74.Fl n 75option disables writing to the device, preventing any changes from being made 76to the filesystem. 77.Sh COMMANDS 78Besides the built-in 79.Xr editline 3 80commands, 81.Nm 82supports these commands: 83.Pp 84.Bl -tag -width indent -compact 85.It Cm help 86Print out the list of accepted commands. 87.Pp 88.It Cm inode Ar i-number 89Select inode 90.Ar i-number 91as the new current inode. 92.Pp 93.It Cm back 94Revert to the previously current inode. 95.Pp 96.It Cm clri Ar i-number 97Clear the inode 98.Ar i-number . 99.Pp 100.It Cm lookup Ar name 101.It Cm cd Ar name 102Find 103.Ar name 104in the current directory and make its inode the current inode. 105.Ar Name 106may be a multi-component name or may begin with slash to indicate that 107the root inode should be used to start the lookup. 108If some component along the pathname is not found, 109the last valid directory encountered is left as the active inode. 110.br 111This command is valid only if the starting inode is a directory. 112.Pp 113.It Cm active 114.It Cm print 115Print out the active inode. 116.Pp 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. 129This command is valid only if the current inode is a directory. 130.Pp 131.It Cm blks 132List the current inode's blocks numbers. 133.Pp 134.It Cm findblk Ar disk block number ... 135Find the inode(s) owning the specified disk block(s) number(s). 136Note that these are not absolute disk blocks numbers, but offsets from the 137start of the partition. 138.Pp 139.It Cm rm Ar name 140.It Cm del Ar name 141Remove the entry 142.Ar name 143from the current directory inode. 144This command is valid only if the current inode is a directory. 145.Pp 146.It Cm ln Ar ino Ar name 147Create a link to inode 148.Ar ino 149under the name 150.Ar name 151in the current directory inode. 152This command is valid only if the current inode is a directory. 153.Pp 154.It Cm chinum Ar dirslot Ar inum 155Change the i-number in directory entry 156.Ar dirslot 157to 158.Ar inum . 159.Pp 160.It Cm chname Ar dirslot Ar name 161Change the name in directory entry 162.Ar dirslot 163to 164.Ar name . 165This command cannot expand a directory entry. 166You can only rename an entry if the name will fit into 167the existing directory slot. 168.Pp 169.It Cm chtype Ar type 170Change the type of the current inode to 171.Ar type . 172.Ar type 173may be one of: 174.Em file , 175.Em dir , 176.Em socket , 177or 178.Em fifo . 179.Pp 180.It Cm chmod Ar mode 181Change the mode bits of the current inode to 182.Ar mode . 183You cannot change the file type with this subcommand; use 184.Ic chtype 185to do that. 186.Pp 187.It Cm chflags Ar flags 188Change the file flags of the current inode to 189.Ar flags . 190.Pp 191.It Cm chown Ar uid 192Change the owner of the current inode to 193.Ar uid . 194.Pp 195.It Cm chgrp Ar gid 196Change the group of the current inode to 197.Ar gid . 198.Pp 199.It Cm chgen Ar gen 200Change the generation number of the current inode to 201.Ar gen . 202.Pp 203.It Cm mtime Ar time 204.It Cm ctime Ar time 205.It Cm atime Ar time 206Change the modification, change, or access time (respectively) on the 207current inode to 208.Ar time . 209.Ar Time 210should be in the format 211.Em YYYYMMDDHHMMSS[.nsec] 212where 213.Em nsec 214is an optional nanosecond specification. 215If no nanoseconds are specified, the 216.Va mtimensec , 217.Va ctimensec , 218or 219.Va atimensec 220field will be set to zero. 221.Pp 222.It Cm quit, Cm q, Cm exit, Aq Em EOF 223Exit the program. 224.El 225.Sh SEE ALSO 226.Xr editline 3 , 227.Xr fs 5 , 228.Xr clri 8 , 229.Xr fsck 8 230.Sh HISTORY 231.Nm 232uses the source code for 233.Xr fsck 8 234to implement most of the file system manipulation code. 235The remainder of 236.Nm 237first appeared in 238.Nx 1.1 . 239.Sh WARNING 240Use this tool with extreme caution -- you can damage an FFS file system 241beyond what 242.Xr fsck 8 243can repair. 244.Sh BUGS 245Manipulation of 246.Dq short 247symlinks doesn't work (in particular, don't 248try changing a symlink's type). 249.br 250You must specify modes as numbers rather than symbolic names. 251.br 252There are a bunch of other things that you might want to do which 253.Nm 254doesn't implement. 255