1.\" $NetBSD: fsdb.8,v 1.26 2017/08/05 20:25:41 wiz Exp $ 2.\" 3.\" Copyright (c) 1996, 2017 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 August 3, 2017 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)>" 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 saveblks Ar filename 140Save the current inode's data into 141.Ar filename . 142.Pp 143.It Cm rm Ar name 144.It Cm del Ar name 145Remove the entry 146.Ar name 147from the current directory inode. 148This command is valid only if the current inode is a directory. 149.Pp 150.It Cm ln Ar ino Ar name 151Create a link to inode 152.Ar ino 153under the name 154.Ar name 155in the current directory inode. 156This command is valid only if the current inode is a directory. 157.Pp 158.It Cm chinum Ar dirslot Ar inum 159Change the i-number in directory entry 160.Ar dirslot 161to 162.Ar inum . 163.Pp 164.It Cm chname Ar dirslot Ar name 165Change the name in directory entry 166.Ar dirslot 167to 168.Ar name . 169This command cannot expand a directory entry. 170You can only rename an entry if the name will fit into 171the existing directory slot. 172.Pp 173.It Cm chtype Ar type 174Change the type of the current inode to 175.Ar type . 176.Ar type 177may be one of: 178.Em file , 179.Em dir , 180.Em socket , 181or 182.Em fifo . 183.Pp 184.It Cm chmod Ar mode 185Change the mode bits of the current inode to 186.Ar mode . 187You cannot change the file type with this subcommand; use 188.Ic chtype 189to do that. 190.Pp 191.It Cm chflags Ar flags 192Change the file flags of the current inode to 193.Ar flags . 194.Pp 195.It Cm chown Ar uid 196Change the owner of the current inode to 197.Ar uid . 198.Pp 199.It Cm chgrp Ar gid 200Change the group of the current inode to 201.Ar gid . 202.Pp 203.It Cm chgen Ar gen 204Change the generation number of the current inode to 205.Ar gen . 206.Pp 207.It Cm mtime Ar time 208.It Cm ctime Ar time 209.It Cm atime Ar time 210Change the modification, change, or access time (respectively) on the 211current inode to 212.Ar time . 213.Ar Time 214should be in the format 215.Em YYYYMMDDHHMMSS[.nsec] 216where 217.Em nsec 218is an optional nanosecond specification. 219If no nanoseconds are specified, the 220.Va mtimensec , 221.Va ctimensec , 222or 223.Va atimensec 224field will be set to zero. 225.Pp 226.It Cm quit , Cm q , Cm exit , Aq Em EOF 227Exit the program. 228.El 229.Sh SEE ALSO 230.Xr editline 3 , 231.Xr fs 5 , 232.Xr clri 8 , 233.Xr fsck 8 234.Sh HISTORY 235.Nm 236uses the source code for 237.Xr fsck 8 238to implement most of the file system manipulation code. 239The remainder of 240.Nm 241first appeared in 242.Nx 1.1 . 243.Sh WARNING 244Use this tool with extreme caution -- you can damage an FFS file system 245beyond what 246.Xr fsck 8 247can repair. 248.Sh BUGS 249Manipulation of 250.Dq short 251symlinks doesn't work (in particular, don't 252try changing a symlink's type). 253.br 254You must specify modes as numbers rather than symbolic names. 255.br 256There are a bunch of other things that you might want to do which 257.Nm 258doesn't implement. 259