FSTAT(1) | MidnightBSD General Commands Manual | FSTAT(1) |
fstat
— identify
active files
fstat |
[-fmnsv ] [-M
core] [-N
system] [-p
pid] [-u
user] [file ...] |
The fstat
utility identifies open files. A
file is considered open by a process if it was explicitly opened, is the
working directory, root directory, jail root directory, active executable
text, or kernel trace file for that process. If no options are specified,
fstat
reports on all open files in the system.
The following options are available:
-f
fstat -f /usr/src
’.-M
core-m
-N
system-n
-p
pid-s
-u
user-v
fstat
is running. This is
normal and unavoidable since the rest of the system is running while
fstat
itself is running.The following fields are printed:
If the file number is followed by an asterisk
(‘*
’), the file is not an inode,
but rather a socket, FIFO, or there is an error. In this case the
remainder of the line does not correspond to the remaining
headers— the format of the line is described later under
SOCKETS.
-n
flag was not specified, this header is
present and is the pathname that the file system the file resides in is
mounted on.-n
flag is specified, this header is
present and is the number of the device that this file resides in.-n
flag is not
specified, the mode is printed using a symbolic format (see
strmode(3));
otherwise, the mode is printed as an octal number.-n
flag is not
specified, prints the name of the special file as located in
/dev. If that cannot be located, or the
-n
flag is specified, prints the major/minor
device number that the special device refers to.r
’ indicates open for reading; the
letter ‘w
’ indicates open for
writing. This field is useful when trying to find the processes that are
preventing a file system from being down graded to read-only.-f
flag is not, then this field is present and is the name associated with
the given file. Normally the name cannot be determined since there is no
mapping from an open file back to the directory entry that was used to
open that file. Also, since different directory entries may reference the
same file (via ln(1)), the
name printed may not be the actual name that the process originally used
to open that file.The formatting of open sockets depends on the protocol domain. In all cases the first field is the domain name, the second field is the socket type (stream, dgram, etc.), and the third is the socket flags field (in hex). The remaining fields are protocol dependent. For TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb). For UNIX-domain sockets, its the address of the socket pcb and the address of the connected pcb (if connected). Otherwise the protocol number and address of the socket itself are printed.
For example, the addresses mentioned above are the addresses which
the ‘netstat -A
’ command would print
for TCP, UDP, and UNIX-domain. Note that since pipes are implemented using
sockets, a pipe appears as a connected UNIX-domain stream socket. A
unidirectional UNIX-domain socket indicates the direction of flow with an
arrow (‘<-
’ or
‘->
’), and a full duplex socket
shows a double arrow
(‘<->
’).
When the -s
flag is used, socket endpoint
information is shown after the address of the socket. For internet sockets
the local and remote addresses are shown, separated with a double arrow
(‘<->
’). For UNIX/local sockets
either the local or remote address is shown, depending on which one is
available.
fuser(1), netstat(1), nfsstat(1), procstat(1), ps(1), sockstat(1), systat(1), tcp(4), unix(4), iostat(8), pstat(8), vmstat(8)
The fstat
command appeared in
4.3BSD-Tahoe.
Since fstat
takes a snapshot of the
system, it is only correct for a very short period of time.
June 17, 2020 | midnightbsd-3.1 |