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