2002-02-07 06:15:06 +03:00
|
|
|
.\" $NetBSD: fstat.1,v 1.19 2002/02/07 03:15:11 ross Exp $
|
1997-01-09 23:18:21 +03:00
|
|
|
.\"
|
1994-05-09 11:07:32 +04:00
|
|
|
.\" Copyright (c) 1987, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
1994-06-14 02:04:11 +04:00
|
|
|
.\" from: @(#)fstat.1 8.3 (Berkeley) 2/25/94
|
2002-02-07 06:15:06 +03:00
|
|
|
.\" $NetBSD: fstat.1,v 1.19 2002/02/07 03:15:11 ross Exp $
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
1999-02-18 09:09:25 +03:00
|
|
|
.Dd February 18, 1999
|
1993-03-21 12:45:37 +03:00
|
|
|
.Dt FSTAT 1
|
1999-03-22 21:16:34 +03:00
|
|
|
.Os
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh NAME
|
|
|
|
.Nm fstat
|
1999-11-15 17:48:32 +03:00
|
|
|
.Nd display status of open files
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh SYNOPSIS
|
1997-10-18 19:28:04 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
.Op Fl fnv
|
|
|
|
.Op Fl M Ar core
|
|
|
|
.Op Fl N Ar system
|
1994-05-09 11:07:32 +04:00
|
|
|
.Op Fl p Ar pid
|
1993-03-21 12:45:37 +03:00
|
|
|
.Op Fl u Ar user
|
2001-12-01 22:13:18 +03:00
|
|
|
.Op Ar filename ...
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh DESCRIPTION
|
1997-10-18 19:28:04 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
identifies open files.
|
|
|
|
A file is considered open by a process if it was explicitly opened,
|
|
|
|
is the working directory, root directory, active pure text, or kernel
|
|
|
|
trace file for that process.
|
|
|
|
If no options are specified,
|
1997-10-18 19:28:04 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
reports on all open files in the system.
|
|
|
|
.Pp
|
|
|
|
Options:
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Fl f
|
1994-05-09 11:07:32 +04:00
|
|
|
Restrict examination to files open in the same filesystems as
|
|
|
|
the named file arguments, or to the filesystem containing the
|
|
|
|
current directory if there are no additional filename arguments.
|
1993-03-21 12:45:37 +03:00
|
|
|
For example, to find all files open in the filesystem where the
|
|
|
|
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
|
|
|
|
Extract the name list from the specified system instead of the default
|
1994-08-06 10:11:03 +04:00
|
|
|
.Pa /netbsd .
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Fl n
|
|
|
|
Numerical format. Print the device number (maj,min) of the filesystem
|
|
|
|
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
|
|
|
|
Verbose mode. Print error messages upon failures to locate particular
|
|
|
|
system data structures rather than silently ignoring them. Most of
|
|
|
|
these data structures are dynamically created or deleted and it is
|
|
|
|
possible for them to disappear while
|
1997-10-18 19:28:04 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
is running. This
|
|
|
|
is normal and unavoidable since the rest of the system is running while
|
1997-10-18 19:28:04 +04:00
|
|
|
.Nm
|
1993-03-21 12:45:37 +03:00
|
|
|
itself is running.
|
|
|
|
.It Ar filename ...
|
|
|
|
Restrict reports to the specified files.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The following fields are printed:
|
|
|
|
.Bl -tag -width MOUNT
|
|
|
|
.It Li USER
|
1999-02-18 09:09:25 +03:00
|
|
|
The username of the owner of the process (effective UID).
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Li CMD
|
|
|
|
The command name of the process.
|
|
|
|
.It Li PID
|
1999-02-18 09:09:25 +03:00
|
|
|
The process ID.
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Li FD
|
|
|
|
The file number in the per-process open file table or one of the following
|
|
|
|
special names:
|
|
|
|
.Pp
|
2002-02-07 06:15:06 +03:00
|
|
|
.Bl -tag -width MOUNT -offset indent -compact
|
1999-02-18 09:09:25 +03:00
|
|
|
.It Li text
|
|
|
|
pure text inode
|
|
|
|
.It Li wd
|
|
|
|
current working directory
|
|
|
|
.It Li root
|
|
|
|
root inode
|
|
|
|
.It Li tr
|
|
|
|
kernel trace file
|
|
|
|
.El
|
1993-03-21 12:45:37 +03:00
|
|
|
.Pp
|
1999-02-18 09:09:25 +03:00
|
|
|
If the file number is followed by an asterisk
|
|
|
|
.Pq Dq * ,
|
|
|
|
the file is not an inode, but rather a socket,
|
1993-03-21 12:45:37 +03:00
|
|
|
.Tn FIFO ,
|
|
|
|
or there is an error.
|
|
|
|
In this case the remainder of the line doesn't
|
|
|
|
correspond to the remaining headers -- the format of the line
|
|
|
|
is described later under
|
|
|
|
.Sx Sockets .
|
|
|
|
.It Li MOUNT
|
|
|
|
If the
|
|
|
|
.Fl n
|
|
|
|
flag wasn't specified, this header is present and is the
|
|
|
|
pathname that the filesystem the file resides in is mounted on.
|
|
|
|
.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
|
|
|
|
The mode of the file. If the
|
|
|
|
.Fl n
|
|
|
|
flag isn't specified, the mode is printed
|
|
|
|
using a symbolic format (see
|
|
|
|
.Xr strmode 3 ) ;
|
|
|
|
otherwise, the mode is printed
|
|
|
|
as an octal number.
|
|
|
|
.It Li SZ\&|DV
|
1999-02-18 09:09:25 +03:00
|
|
|
If the file is not a character or block special file, prints the size of
|
1993-03-21 12:45:37 +03:00
|
|
|
the file in bytes. Otherwise, if the
|
|
|
|
.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.
|
1994-05-09 11:07:32 +04:00
|
|
|
.It Li R/W
|
|
|
|
This column describes the access mode that the file allows.
|
1999-02-18 09:09:25 +03:00
|
|
|
The letter
|
|
|
|
.Dq r
|
|
|
|
indicates open for reading;
|
|
|
|
the letter
|
|
|
|
.Dq
|
|
|
|
indicates open for writing.
|
1994-05-09 11:07:32 +04:00
|
|
|
This field is useful when trying to find the processes that are
|
1999-02-18 09:09:25 +03:00
|
|
|
preventing a filesystem from being downgraded to read-only.
|
1993-03-21 12:45:37 +03: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
|
|
|
|
that file. Also, since different directory entries may reference
|
|
|
|
the same file (via
|
1999-03-16 12:54:50 +03:00
|
|
|
.Xr ln 1 ) ,
|
1993-03-21 12:45:37 +03:00
|
|
|
the name printed may not be the actual
|
|
|
|
name that the process originally used to open that file.
|
|
|
|
.El
|
|
|
|
.Sh SOCKETS
|
1999-11-20 01:29:24 +03:00
|
|
|
The formatting of open sockets depends on the protocol domain.
|
1993-03-21 12:45:37 +03:00
|
|
|
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.
|
1999-02-18 09:09:25 +03:00
|
|
|
For TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb).
|
1998-04-28 10:00:51 +04:00
|
|
|
For
|
|
|
|
.Ux
|
|
|
|
domain sockets, its the address of the socket pcb and the address
|
1993-03-21 12:45:37 +03:00
|
|
|
of the connected pcb (if connected).
|
|
|
|
Otherwise the protocol number and address of the socket itself are printed.
|
2001-05-07 03:48:31 +04:00
|
|
|
The attempt is to make enough information available to
|
1993-03-21 12:45:37 +03: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
|
2001-05-07 03:48:31 +04:00
|
|
|
command would print for TCP, UDP, and
|
1998-04-28 10:00:51 +04:00
|
|
|
.Ux
|
|
|
|
domain.
|
1993-03-21 12:45:37 +03:00
|
|
|
Note that since pipes are implemented using sockets, a pipe appears as a
|
1998-04-28 10:00:51 +04:00
|
|
|
connected
|
|
|
|
.Ux
|
|
|
|
domain stream socket.
|
|
|
|
A unidirectional
|
|
|
|
.Ux
|
1999-02-18 09:09:25 +03:00
|
|
|
domain socket indicates the direction of flow with an arrow
|
|
|
|
.Po
|
|
|
|
.Dq <-
|
|
|
|
or
|
|
|
|
.Dq ->
|
|
|
|
.Pc ,
|
|
|
|
and a full duplex socket shows a double arrow
|
|
|
|
.Pq Dq <-> .
|
|
|
|
.Pp
|
|
|
|
For internet sockets
|
|
|
|
.Nm fstat
|
|
|
|
also attempts to print the internet address and port for the
|
|
|
|
local end of a connection.
|
|
|
|
If the socket is connected, it also prints the remote internet address
|
|
|
|
and port.
|
|
|
|
A
|
|
|
|
.Pq Dq *
|
|
|
|
is used to indicate an INADDR_ANY binding.
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr netstat 1 ,
|
|
|
|
.Xr nfsstat 1 ,
|
|
|
|
.Xr ps 1 ,
|
|
|
|
.Xr systat 1 ,
|
2001-05-07 03:48:31 +04:00
|
|
|
.Xr vmstat 1 ,
|
1993-03-21 12:45:37 +03:00
|
|
|
.Xr iostat 8 ,
|
2001-05-07 03:48:31 +04:00
|
|
|
.Xr pstat 8
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
|
|
|
.Bx 4.3 tahoe .
|
2001-12-01 22:13:18 +03:00
|
|
|
.Sh BUGS
|
|
|
|
Since
|
|
|
|
.Nm
|
|
|
|
takes a snapshot of the system, it is only correct for a very short period
|
|
|
|
of time.
|
|
|
|
.Pp
|
|
|
|
Moreover, because DNS resolution and YP lookups cause many file
|
|
|
|
descriptor changes,
|
|
|
|
.Nm
|
|
|
|
does not attempt to translate the internet address and port numbers into
|
|
|
|
symbolic names.
|