1994-05-27 12:33:43 +00:00
|
|
|
.\" Copyright (c) 1987, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)fstat.1 8.3 (Berkeley) 2/25/94
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 12:33:43 +00:00
|
|
|
.\"
|
2002-03-27 22:59:11 +00:00
|
|
|
.Dd March 27, 2002
|
1994-05-27 12:33:43 +00:00
|
|
|
.Dt FSTAT 1
|
2001-07-10 14:16:33 +00:00
|
|
|
.Os
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fstat
|
2002-03-27 22:59:11 +00:00
|
|
|
.Nd identify active files
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh SYNOPSIS
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
2000-04-05 05:45:40 +00:00
|
|
|
.Op Fl fmnv
|
1994-05-27 12:33:43 +00:00
|
|
|
.Op Fl M Ar core
|
|
|
|
.Op Fl N Ar system
|
|
|
|
.Op Fl p Ar pid
|
|
|
|
.Op Fl u Ar user
|
2002-04-12 21:31:24 +00:00
|
|
|
.Op Ar
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility identifies open files.
|
1994-05-27 12:33:43 +00:00
|
|
|
A file is considered open by a process if it was explicitly opened,
|
2005-01-30 08:03:20 +00:00
|
|
|
is the working directory, root directory, jail root directory,
|
|
|
|
active executable text, or kernel trace file for that process.
|
1994-05-27 12:33:43 +00:00
|
|
|
If no options are specified,
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
reports on all open files in the system.
|
|
|
|
.Pp
|
2004-07-26 19:53:44 +00:00
|
|
|
The following options are available:
|
|
|
|
.Bl -tag -width indent
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl f
|
2002-12-12 17:26:04 +00:00
|
|
|
Restrict examination to files open in the same file systems as
|
|
|
|
the named file arguments, or to the file system containing the
|
1994-05-27 12:33:43 +00:00
|
|
|
current directory if there are no additional filename arguments.
|
2002-12-12 17:26:04 +00:00
|
|
|
For example, to find all files open in the file system where the
|
1994-05-27 12:33:43 +00:00
|
|
|
directory
|
|
|
|
.Pa /usr/src
|
|
|
|
resides, type
|
|
|
|
.Dq Li fstat -f /usr/src .
|
|
|
|
.It Fl M
|
|
|
|
Extract values associated with the name list from the specified core
|
|
|
|
instead of the default
|
|
|
|
.Pa /dev/kmem .
|
|
|
|
.It Fl N
|
2004-03-26 10:48:35 +00:00
|
|
|
Extract the name list from the specified system instead of the default,
|
|
|
|
which is the kernel image the system has booted from.
|
2000-04-05 05:45:40 +00:00
|
|
|
.It Fl m
|
|
|
|
Include memory-mapped files in the listing; normally these are excluded
|
|
|
|
due to the extra processing required.
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl n
|
2004-07-02 22:22:35 +00:00
|
|
|
Numerical format.
|
|
|
|
Print the device number (maj,min) of the file system
|
1994-05-27 12:33:43 +00:00
|
|
|
the file resides in rather than the mount point name; for special
|
|
|
|
files, print the
|
|
|
|
device number that the special device refers to rather than the filename
|
|
|
|
in
|
|
|
|
.Pa /dev ;
|
|
|
|
and print the mode of the file in octal instead of symbolic form.
|
|
|
|
.It Fl p
|
|
|
|
Report all files open by the specified process.
|
|
|
|
.It Fl u
|
|
|
|
Report all files open by the specified user.
|
|
|
|
.It Fl v
|
2004-07-02 22:22:35 +00:00
|
|
|
Verbose mode.
|
|
|
|
Print error messages upon failures to locate particular
|
|
|
|
system data structures rather than silently ignoring them.
|
|
|
|
Most of
|
1994-05-27 12:33:43 +00:00
|
|
|
these data structures are dynamically created or deleted and it is
|
|
|
|
possible for them to disappear while
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
2004-07-02 22:22:35 +00:00
|
|
|
is running.
|
|
|
|
This
|
2004-07-03 00:24:45 +00:00
|
|
|
is normal and unavoidable since the rest of the system is running while
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
itself is running.
|
2002-04-12 21:31:24 +00:00
|
|
|
.It Ar
|
1994-05-27 12:33:43 +00:00
|
|
|
Restrict reports to the specified files.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following fields are printed:
|
|
|
|
.Bl -tag -width MOUNT
|
|
|
|
.It Li USER
|
|
|
|
The username of the owner of the process (effective uid).
|
|
|
|
.It Li CMD
|
|
|
|
The command name of the process.
|
|
|
|
.It Li PID
|
|
|
|
The process id.
|
|
|
|
.It Li FD
|
|
|
|
The file number in the per-process open file table or one of the following
|
|
|
|
special names:
|
|
|
|
.Pp
|
2000-12-19 16:00:12 +00:00
|
|
|
.Bd -literal -offset indent -compact
|
2005-01-30 08:03:20 +00:00
|
|
|
jail - jail root directory
|
|
|
|
mmap - memory-mapped file
|
1994-05-27 12:33:43 +00:00
|
|
|
root - root inode
|
2005-01-30 08:03:20 +00:00
|
|
|
text - executable text inode
|
1994-05-27 12:33:43 +00:00
|
|
|
tr - kernel trace file
|
2005-01-30 08:03:20 +00:00
|
|
|
wd - current working directory
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
If the file number is followed by an asterisk (``*''), the file is
|
|
|
|
not an inode, but rather a socket,
|
|
|
|
.Tn FIFO ,
|
|
|
|
or there is an error.
|
2005-02-13 22:25:33 +00:00
|
|
|
In this case the remainder of the line does not
|
1994-05-27 12:33:43 +00:00
|
|
|
correspond to the remaining headers -- the format of the line
|
|
|
|
is described later under
|
|
|
|
.Sx Sockets .
|
|
|
|
.It Li MOUNT
|
|
|
|
If the
|
|
|
|
.Fl n
|
2005-02-13 22:25:33 +00:00
|
|
|
flag was not specified, this header is present and is the
|
2002-12-12 17:26:04 +00:00
|
|
|
pathname that the file system the file resides in is mounted on.
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Li DEV
|
|
|
|
If the
|
|
|
|
.Fl n
|
|
|
|
flag is specified, this header is present and is the
|
|
|
|
major/minor number of the device that this file resides in.
|
|
|
|
.It Li INUM
|
|
|
|
The inode number of the file.
|
|
|
|
.It Li MODE
|
2004-07-02 22:22:35 +00:00
|
|
|
The mode of the file.
|
|
|
|
If the
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl n
|
2005-02-13 22:25:33 +00:00
|
|
|
flag is not specified, the mode is printed
|
1994-05-27 12:33:43 +00:00
|
|
|
using a symbolic format (see
|
|
|
|
.Xr strmode 3 ) ;
|
|
|
|
otherwise, the mode is printed
|
|
|
|
as an octal number.
|
|
|
|
.It Li SZ\&|DV
|
|
|
|
If the file is not a character or block special, prints the size of
|
2004-07-02 22:22:35 +00:00
|
|
|
the file in bytes.
|
|
|
|
Otherwise, if the
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl n
|
|
|
|
flag is not specified, prints
|
|
|
|
the name of the special file as located in
|
|
|
|
.Pa /dev .
|
|
|
|
If that cannot be
|
|
|
|
located, or the
|
|
|
|
.Fl n
|
|
|
|
flag is specified, prints the major/minor device
|
|
|
|
number that the special device refers to.
|
|
|
|
.It Li R/W
|
|
|
|
This column describes the access mode that the file allows.
|
|
|
|
The letter ``r'' indicates open for reading;
|
|
|
|
the letter ``w'' indicates open for writing.
|
|
|
|
This field is useful when trying to find the processes that are
|
2002-12-12 17:26:04 +00:00
|
|
|
preventing a file system from being down graded to read-only.
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Li NAME
|
|
|
|
If filename arguments are specified and the
|
|
|
|
.Fl 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
|
2004-07-02 22:22:35 +00:00
|
|
|
that file.
|
|
|
|
Also, since different directory entries may reference
|
1994-05-27 12:33:43 +00:00
|
|
|
the same file (via
|
1996-04-07 00:06:21 +00:00
|
|
|
.Xr ln 1 ) ,
|
1994-05-27 12:33:43 +00:00
|
|
|
the name printed may not be the actual
|
|
|
|
name that the process originally used to open that file.
|
|
|
|
.El
|
|
|
|
.Sh SOCKETS
|
|
|
|
The formating 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.
|
2001-07-15 08:06:20 +00:00
|
|
|
The attempt is to make enough information available to
|
1994-05-27 12:33:43 +00:00
|
|
|
permit further analysis without duplicating
|
|
|
|
.Xr netstat 1 .
|
|
|
|
.Pp
|
|
|
|
For example, the addresses mentioned above are the addresses which the
|
|
|
|
.Dq Li netstat -A
|
|
|
|
command would print for tcp, udp, and unixdomain.
|
|
|
|
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
|
|
|
|
(``<->'').
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr netstat 1 ,
|
|
|
|
.Xr nfsstat 1 ,
|
|
|
|
.Xr ps 1 ,
|
1999-09-06 13:14:24 +00:00
|
|
|
.Xr sockstat 1 ,
|
1994-05-27 12:33:43 +00:00
|
|
|
.Xr systat 1 ,
|
1999-09-06 13:14:24 +00:00
|
|
|
.Xr tcp 4 ,
|
|
|
|
.Xr unix 4 ,
|
1994-05-27 12:33:43 +00:00
|
|
|
.Xr iostat 8 ,
|
1996-01-20 07:29:11 +00:00
|
|
|
.Xr pstat 8 ,
|
|
|
|
.Xr vmstat 8
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
|
|
|
.Bx 4.3 tahoe .
|
2005-01-18 13:43:56 +00:00
|
|
|
.Sh BUGS
|
|
|
|
Since
|
|
|
|
.Nm
|
|
|
|
takes a snapshot of the system, it is only correct for a very short period
|
|
|
|
of time.
|