1.\" Copyright (c) 1987, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)fstat.1 8.3 (Berkeley) 2/25/94 33.\" $FreeBSD$ 34.\" 35.Dd March 27, 2002 36.Dt FSTAT 1 37.Os 38.Sh NAME 39.Nm fstat 40.Nd identify active files 41.Sh SYNOPSIS 42.Nm 43.Op Fl fmnv 44.Op Fl M Ar core 45.Op Fl N Ar system 46.Op Fl p Ar pid 47.Op Fl u Ar user 48.Op Ar 49.Sh DESCRIPTION 50The 51.Nm 52utility identifies open files. 53A file is considered open by a process if it was explicitly opened, 54is the working directory, root directory, active executable text, or kernel 55trace file for that process. 56If no options are specified, 57.Nm 58reports on all open files in the system. 59.Pp 60Options: 61.Bl -tag -width Ds 62.It Fl f 63Restrict examination to files open in the same filesystems as 64the named file arguments, or to the filesystem containing the 65current directory if there are no additional filename arguments. 66For example, to find all files open in the filesystem where the 67directory 68.Pa /usr/src 69resides, type 70.Dq Li fstat -f /usr/src . 71.It Fl M 72Extract values associated with the name list from the specified core 73instead of the default 74.Pa /dev/kmem . 75.It Fl N 76Extract the name list from the specified system instead of the default 77.Pa /boot/kernel/kernel . 78.It Fl m 79Include memory-mapped files in the listing; normally these are excluded 80due to the extra processing required. 81.It Fl n 82Numerical format. Print the device number (maj,min) of the filesystem 83the file resides in rather than the mount point name; for special 84files, print the 85device number that the special device refers to rather than the filename 86in 87.Pa /dev ; 88and print the mode of the file in octal instead of symbolic form. 89.It Fl p 90Report all files open by the specified process. 91.It Fl u 92Report all files open by the specified user. 93.It Fl v 94Verbose mode. Print error messages upon failures to locate particular 95system data structures rather than silently ignoring them. Most of 96these data structures are dynamically created or deleted and it is 97possible for them to disappear while 98.Nm 99is running. This 100is normal and unavoidable since the rest of the system is running while 101.Nm 102itself is running. 103.It Ar 104Restrict reports to the specified files. 105.El 106.Pp 107The following fields are printed: 108.Bl -tag -width MOUNT 109.It Li USER 110The username of the owner of the process (effective uid). 111.It Li CMD 112The command name of the process. 113.It Li PID 114The process id. 115.It Li FD 116The file number in the per-process open file table or one of the following 117special names: 118.Pp 119.Bd -literal -offset indent -compact 120text - executable text inode 121wd - current working directory 122root - root inode 123tr - kernel trace file 124mmap - memory-mapped file 125.Ed 126.Pp 127If the file number is followed by an asterisk (``*''), the file is 128not an inode, but rather a socket, 129.Tn FIFO , 130or there is an error. 131In this case the remainder of the line doesn't 132correspond to the remaining headers -- the format of the line 133is described later under 134.Sx Sockets . 135.It Li MOUNT 136If the 137.Fl n 138flag wasn't specified, this header is present and is the 139pathname that the filesystem the file resides in is mounted on. 140.It Li DEV 141If the 142.Fl n 143flag is specified, this header is present and is the 144major/minor number of the device that this file resides in. 145.It Li INUM 146The inode number of the file. 147.It Li MODE 148The mode of the file. If the 149.Fl n 150flag isn't specified, the mode is printed 151using a symbolic format (see 152.Xr strmode 3 ) ; 153otherwise, the mode is printed 154as an octal number. 155.It Li SZ\&|DV 156If the file is not a character or block special, prints the size of 157the file in bytes. Otherwise, if the 158.Fl n 159flag is not specified, prints 160the name of the special file as located in 161.Pa /dev . 162If that cannot be 163located, or the 164.Fl n 165flag is specified, prints the major/minor device 166number that the special device refers to. 167.It Li R/W 168This column describes the access mode that the file allows. 169The letter ``r'' indicates open for reading; 170the letter ``w'' indicates open for writing. 171This field is useful when trying to find the processes that are 172preventing a filesystem from being down graded to read-only. 173.It Li NAME 174If filename arguments are specified and the 175.Fl f 176flag is not, then 177this field is present and is the name associated with the given file. 178Normally the name cannot be determined since there is no mapping 179from an open file back to the directory entry that was used to open 180that file. Also, since different directory entries may reference 181the same file (via 182.Xr ln 1 ) , 183the name printed may not be the actual 184name that the process originally used to open that file. 185.El 186.Sh SOCKETS 187The formating of open sockets depends on the protocol domain. 188In all cases the first field is the domain name, the second field 189is the socket type (stream, dgram, etc), and the third is the socket 190flags field (in hex). 191The remaining fields are protocol dependent. 192For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb). 193For unix domain sockets, its the address of the socket pcb and the address 194of the connected pcb (if connected). 195Otherwise the protocol number and address of the socket itself are printed. 196The attempt is to make enough information available to 197permit further analysis without duplicating 198.Xr netstat 1 . 199.Pp 200For example, the addresses mentioned above are the addresses which the 201.Dq Li netstat -A 202command would print for tcp, udp, and unixdomain. 203Note that since pipes are implemented using sockets, a pipe appears as a 204connected unix domain stream socket. 205A unidirectional unix domain socket indicates the direction of flow with 206an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow 207(``<->''). 208.Sh BUGS 209Since 210.Nm 211takes a snapshot of the system, it is only correct for a very short period 212of time. 213.Sh SEE ALSO 214.Xr netstat 1 , 215.Xr nfsstat 1 , 216.Xr ps 1 , 217.Xr sockstat 1 , 218.Xr systat 1 , 219.Xr tcp 4 , 220.Xr unix 4 , 221.Xr iostat 8 , 222.Xr pstat 8 , 223.Xr vmstat 8 224.Sh HISTORY 225The 226.Nm 227command appeared in 228.Bx 4.3 tahoe . 229