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: src/usr.bin/fstat/fstat.1,v 1.9.2.7 2002/06/21 15:26:59 charnier Exp $ 34.\" $DragonFly: src/usr.bin/fstat/fstat.1,v 1.2 2003/06/17 04:29:26 dillon Exp $ 35.\" 36.Dd February 25, 1994 37.Dt FSTAT 1 38.Os 39.Sh NAME 40.Nm fstat 41.Nd file status 42.Sh SYNOPSIS 43.Nm 44.Op Fl fmnv 45.Op Fl M Ar core 46.Op Fl N Ar system 47.Op Fl p Ar pid 48.Op Fl u Ar user 49.Op Ar 50.Sh DESCRIPTION 51The 52.Nm 53utility identifies open files. 54A file is considered open by a process if it was explicitly opened, 55is the working directory, root directory, active executable text, or kernel 56trace file for that process. 57If no options are specified, 58.Nm 59reports on all open files in the system. 60.Pp 61Options: 62.Bl -tag -width Ds 63.It Fl f 64Restrict examination to files open in the same filesystems as 65the named file arguments, or to the filesystem containing the 66current directory if there are no additional filename arguments. 67For example, to find all files open in the filesystem where the 68directory 69.Pa /usr/src 70resides, type 71.Dq Li fstat -f /usr/src . 72.It Fl M 73Extract values associated with the name list from the specified core 74instead of the default 75.Pa /dev/kmem . 76.It Fl N 77Extract the name list from the specified system instead of the default 78.Pa /kernel . 79.It Fl m 80Include memory-mapped files in the listing; normally these are excluded 81due to the extra processing required. 82.It Fl n 83Numerical format. Print the device number (maj,min) of the filesystem 84the file resides in rather than the mount point name; for special 85files, print the 86device number that the special device refers to rather than the filename 87in 88.Pa /dev ; 89and print the mode of the file in octal instead of symbolic form. 90.It Fl p 91Report all files open by the specified process. 92.It Fl u 93Report all files open by the specified user. 94.It Fl v 95Verbose mode. Print error messages upon failures to locate particular 96system data structures rather than silently ignoring them. Most of 97these data structures are dynamically created or deleted and it is 98possible for them to disappear while 99.Nm 100is running. This 101is normal and unavoidable since the rest of the system is running while 102.Nm 103itself is running. 104.It Ar 105Restrict reports to the specified files. 106.El 107.Pp 108The following fields are printed: 109.Bl -tag -width MOUNT 110.It Li USER 111The username of the owner of the process (effective uid). 112.It Li CMD 113The command name of the process. 114.It Li PID 115The process id. 116.It Li FD 117The file number in the per-process open file table or one of the following 118special names: 119.Pp 120.Bd -literal -offset indent -compact 121text - executable text inode 122wd - current working directory 123root - root inode 124tr - kernel trace file 125mmap - memory-mapped file 126.Ed 127.Pp 128If the file number is followed by an asterisk (``*''), the file is 129not an inode, but rather a socket, 130.Tn FIFO , 131or there is an error. 132In this case the remainder of the line doesn't 133correspond to the remaining headers -- the format of the line 134is described later under 135.Sx Sockets . 136.It Li MOUNT 137If the 138.Fl n 139flag wasn't specified, this header is present and is the 140pathname that the filesystem the file resides in is mounted on. 141.It Li DEV 142If the 143.Fl n 144flag is specified, this header is present and is the 145major/minor number of the device that this file resides in. 146.It Li INUM 147The inode number of the file. 148.It Li MODE 149The mode of the file. If the 150.Fl n 151flag isn't specified, the mode is printed 152using a symbolic format (see 153.Xr strmode 3 ) ; 154otherwise, the mode is printed 155as an octal number. 156.It Li SZ\&|DV 157If the file is not a character or block special, prints the size of 158the file in bytes. Otherwise, if the 159.Fl n 160flag is not specified, prints 161the name of the special file as located in 162.Pa /dev . 163If that cannot be 164located, or the 165.Fl n 166flag is specified, prints the major/minor device 167number that the special device refers to. 168.It Li R/W 169This column describes the access mode that the file allows. 170The letter ``r'' indicates open for reading; 171the letter ``w'' indicates open for writing. 172This field is useful when trying to find the processes that are 173preventing a filesystem from being down graded to read-only. 174.It Li NAME 175If filename arguments are specified and the 176.Fl f 177flag is not, then 178this field is present and is the name associated with the given file. 179Normally the name cannot be determined since there is no mapping 180from an open file back to the directory entry that was used to open 181that file. Also, since different directory entries may reference 182the same file (via 183.Xr ln 1 ) , 184the name printed may not be the actual 185name that the process originally used to open that file. 186.El 187.Sh SOCKETS 188The formating of open sockets depends on the protocol domain. 189In all cases the first field is the domain name, the second field 190is the socket type (stream, dgram, etc), and the third is the socket 191flags field (in hex). 192The remaining fields are protocol dependent. 193For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb). 194For unix domain sockets, its the address of the socket pcb and the address 195of the connected pcb (if connected). 196Otherwise the protocol number and address of the socket itself are printed. 197The attempt is to make enough information available to 198permit further analysis without duplicating 199.Xr netstat 1 . 200.Pp 201For example, the addresses mentioned above are the addresses which the 202.Dq Li netstat -A 203command would print for tcp, udp, and unixdomain. 204Note that since pipes are implemented using sockets, a pipe appears as a 205connected unix domain stream socket. 206A unidirectional unix domain socket indicates the direction of flow with 207an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow 208(``<->''). 209.Sh BUGS 210Since 211.Nm 212takes a snapshot of the system, it is only correct for a very short period 213of time. 214.Sh SEE ALSO 215.Xr netstat 1 , 216.Xr nfsstat 1 , 217.Xr ps 1 , 218.Xr sockstat 1 , 219.Xr systat 1 , 220.Xr tcp 4 , 221.Xr unix 4 , 222.Xr iostat 8 , 223.Xr pstat 8 , 224.Xr vmstat 8 225.Sh HISTORY 226The 227.Nm 228command appeared in 229.Bx 4.3 tahoe . 230