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