[BACK]Return to fstat.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / fstat

Annotation of src/usr.bin/fstat/fstat.1, Revision 1.31

1.31    ! jmc         1: .\"    $OpenBSD: fstat.1,v 1.30 2004/07/13 23:33:28 jmc Exp $
1.16      aaron       2: .\"
1.1       deraadt     3: .\" Copyright (c) 1987, 1991, 1993
                      4: .\"    The Regents of the University of California.  All rights reserved.
                      5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. Redistributions in binary form must reproduce the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer in the
                     13: .\"    documentation and/or other materials provided with the distribution.
1.25      millert    14: .\" 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    15: .\"    may be used to endorse or promote products derived from this software
                     16: .\"    without specific prior written permission.
                     17: .\"
                     18: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     19: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     20: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     21: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     22: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     23: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     24: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     25: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     26: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     27: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     28: .\" SUCH DAMAGE.
                     29: .\"
                     30: .\"     from: @(#)fstat.1      8.3 (Berkeley) 2/25/94
                     31: .\"
                     32: .Dd February 25, 1994
                     33: .Dt FSTAT 1
1.11      aaron      34: .Os
1.1       deraadt    35: .Sh NAME
                     36: .Nm fstat
1.15      pjanzen    37: .Nd display status of open files
1.1       deraadt    38: .Sh SYNOPSIS
                     39: .Nm fstat
1.18      hugh       40: .Op Fl fnov
1.1       deraadt    41: .Op Fl M Ar core
                     42: .Op Fl N Ar system
                     43: .Op Fl p Ar pid
                     44: .Op Fl u Ar user
1.16      aaron      45: .Op Ar file ...
1.1       deraadt    46: .Sh DESCRIPTION
1.19      aaron      47: .Nm
1.1       deraadt    48: identifies open files.
                     49: A file is considered open by a process if it was explicitly opened,
                     50: is the working directory, root directory, active pure text, or kernel
                     51: trace file for that process.
                     52: If no options are specified,
1.19      aaron      53: .Nm
1.1       deraadt    54: reports on all open files in the system.
                     55: .Pp
1.14      aaron      56: The options are as follows:
1.1       deraadt    57: .Bl -tag -width Ds
                     58: .It Fl f
1.16      aaron      59: Restrict examination to files open in the same file systems as
                     60: the named file arguments, or to the file system containing the
1.1       deraadt    61: current directory if there are no additional filename arguments.
1.16      aaron      62: For example, to find all files open in the file system where the
1.1       deraadt    63: directory
                     64: .Pa /usr/src
                     65: resides, type
1.28      deraadt    66: .Pp
1.31    ! jmc        67: .Dl # fstat -f /usr/src
1.12      deraadt    68: .It Fl M Ar core
1.1       deraadt    69: Extract values associated with the name list from the specified core
1.20      miod       70: instead of the running kernel.
1.12      deraadt    71: .It Fl N Ar system
1.20      miod       72: Extract the name list from the specified system instead of the running kernel.
1.1       deraadt    73: .It Fl n
1.16      aaron      74: Numerical format.
                     75: Print the device number (maj,min) of the file system
1.17      aaron      76: the file resides in rather than the mount point name.
                     77: For special files, print the
1.1       deraadt    78: device number that the special device refers to rather than the filename
                     79: in
1.16      aaron      80: .Pa /dev .
                     81: Also, print the mode of the file in octal instead of symbolic form.
1.18      hugh       82: .It Fl o
                     83: Output file offset.
                     84: Follow the size field with the descriptor's offset.
                     85: Useful for checking progress as a process works through a large file.
1.19      aaron      86: .It Fl p Ar pid
1.1       deraadt    87: Report all files open by the specified process.
1.19      aaron      88: .It Fl u Ar user
1.1       deraadt    89: Report all files open by the specified user.
                     90: .It Fl v
1.16      aaron      91: Verbose mode.
                     92: Print error messages upon failures to locate particular
                     93: system data structures rather than silently ignoring them.
                     94: Most of these data structures are dynamically created or deleted and it is
1.1       deraadt    95: possible for them to disappear while
1.19      aaron      96: .Nm
1.16      aaron      97: is running.
1.17      aaron      98: This is normal and unavoidable since the rest of the system is running while
1.19      aaron      99: .Nm
1.1       deraadt   100: itself is running.
1.16      aaron     101: .It Ar file ...
1.1       deraadt   102: Restrict reports to the specified files.
                    103: .El
                    104: .Pp
                    105: The following fields are printed:
                    106: .Bl -tag -width MOUNT
                    107: .It Li USER
1.10      aaron     108: The username of the owner of the process (effective UID).
1.1       deraadt   109: .It Li CMD
                    110: The command name of the process.
                    111: .It Li PID
1.10      aaron     112: The process ID.
1.1       deraadt   113: .It Li FD
                    114: The file number in the per-process open file table or one of the following
                    115: special names:
1.29      otto      116: .Bd -literal -offset indent
1.26      jmc       117: text   \- pure text inode
                    118: wd     \- current working directory
                    119: root   \- root inode
                    120: tr     \- kernel trace file
1.1       deraadt   121: .Ed
                    122: .Pp
1.16      aaron     123: If the file number is followed by an asterisk
                    124: .Pq Ql * ,
                    125: the file is not an inode, but rather a socket,
1.1       deraadt   126: .Tn FIFO ,
                    127: or there is an error.
                    128: In this case the remainder of the line doesn't
                    129: correspond to the remaining headers -- the format of the line
                    130: is described later under
1.27      jmc       131: .Sx SOCKETS .
1.1       deraadt   132: .It Li MOUNT
                    133: If the
                    134: .Fl n
                    135: flag wasn't specified, this header is present and is the
1.16      aaron     136: pathname that the file system the file resides in is mounted on.
1.1       deraadt   137: .It Li DEV
                    138: If the
                    139: .Fl n
                    140: flag is specified, this header is present and is the
                    141: major/minor number of the device that this file resides in.
                    142: .It Li INUM
                    143: The inode number of the file.
                    144: .It Li MODE
1.17      aaron     145: The mode of the file.
                    146: If the
1.1       deraadt   147: .Fl n
                    148: flag isn't specified, the mode is printed
                    149: using a symbolic format (see
                    150: .Xr strmode 3 ) ;
                    151: otherwise, the mode is printed
                    152: as an octal number.
                    153: .It Li SZ\&|DV
1.10      aaron     154: If the file is not a character or block special file, prints the size of
1.16      aaron     155: the file in bytes.
                    156: Otherwise, if the
1.1       deraadt   157: .Fl n
                    158: flag is not specified, prints
                    159: the name of the special file as located in
                    160: .Pa /dev .
1.16      aaron     161: If that cannot be located, or the
1.1       deraadt   162: .Fl n
                    163: flag is specified, prints the major/minor device
                    164: number that the special device refers to.
                    165: .It Li R/W
                    166: This column describes the access mode that the file allows.
1.16      aaron     167: The letter
                    168: .Sq r
                    169: indicates open for reading;
                    170: the letter
                    171: .Sq w
                    172: indicates open for writing.
1.1       deraadt   173: This field is useful when trying to find the processes that are
1.16      aaron     174: preventing a file system from being downgraded to read-only.
1.1       deraadt   175: .It Li NAME
                    176: If filename arguments are specified and the
                    177: .Fl f
                    178: flag is not, then
                    179: this field is present and is the name associated with the given file.
                    180: Normally the name cannot be determined since there is no mapping
                    181: from an open file back to the directory entry that was used to open
1.16      aaron     182: that file.
                    183: Also, since different directory entries may reference
1.1       deraadt   184: the same file (via
1.24      jmc       185: .Xr ln 1 ) ,
1.1       deraadt   186: the name printed may not be the actual
                    187: name that the process originally used to open that file.
                    188: .El
                    189: .Sh SOCKETS
1.13      alex      190: The formatting of open sockets depends on the protocol domain.
1.1       deraadt   191: In all cases the first field is the domain name, the second field
                    192: is the socket type (stream, dgram, etc), and the third is the socket
                    193: flags field (in hex).
                    194: The remaining fields are protocol dependent.
1.10      aaron     195: For TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb).
                    196: For Unix domain sockets, it's the address of the socket pcb and the address
1.1       deraadt   197: of the connected pcb (if connected).
                    198: Otherwise the protocol number and address of the socket itself are printed.
1.11      aaron     199: The attempt is to make enough information available to
1.1       deraadt   200: permit further analysis without duplicating
                    201: .Xr netstat 1 .
                    202: .Pp
                    203: For example, the addresses mentioned above are the addresses which the
1.16      aaron     204: .Ic netstat -A
1.10      aaron     205: command would print for TCP, UDP, and Unix domain.
1.1       deraadt   206: Note that since pipes are implemented using sockets, a pipe appears as a
1.10      aaron     207: connected Unix domain stream socket.
                    208: A unidirectional Unix domain socket indicates the direction of flow with
1.16      aaron     209: an arrow
                    210: .Pf ( Dq <-
                    211: or
                    212: .Dq -> ) ,
                    213: and a full duplex socket shows a double arrow
1.26      jmc       214: .Pq Dq <-> .
1.4       deraadt   215: .Pp
1.19      aaron     216: For
                    217: .Dv AF_INET
                    218: sockets,
                    219: .Nm
1.4       deraadt   220: also attempts to print the internet address and port for the
                    221: local end of a connection.
                    222: If the socket is connected, it also prints the remote internet address
                    223: and port.
1.16      aaron     224: A
                    225: .Ql *
                    226: is used to indicate an
                    227: .Dv INADDR_ANY
                    228: binding.
                    229: In this case, the
                    230: use of the arrow
                    231: .Pf ( Dq <--
                    232: or
                    233: .Dq --> )
                    234: indicates the direction the socket connection was created.
1.8       art       235: .Sh PIPES
                    236: Every pipe is printed as an address which is the same for both sides of
1.16      aaron     237: the pipe and a state that is built of the letters
                    238: .Dq RWE .
1.26      jmc       239: W \- The pipe blocks waiting for the reader to read data.
                    240: R \- The pipe blocks waiting for the writer to write data.
                    241: E \- The pipe is in EOF state.
1.21      deraadt   242: .Sh CRYPTO
1.22      deraadt   243: Each
                    244: .Xr crypto 4
                    245: device is printed with only the kernel address of the device private data.
1.21      deraadt   246: .Sh KQUEUE
1.22      deraadt   247: Each
                    248: .Xr kqueue 2
                    249: is printed with some information as to queue length.
1.23      avsm      250: Since these things are normally serviced quickly, it is likely that
1.21      deraadt   251: nothing of real importance can be discerned.
                    252: .Sh SYSTRACE
                    253: Each systrace device is printed with only the kernel address of the
                    254: device private data.
1.1       deraadt   255: .Sh SEE ALSO
                    256: .Xr netstat 1 ,
                    257: .Xr nfsstat 1 ,
                    258: .Xr ps 1 ,
                    259: .Xr systat 1 ,
                    260: .Xr iostat 8 ,
                    261: .Xr pstat 8 ,
1.30      jmc       262: .Xr tcpdrop 8 ,
1.1       deraadt   263: .Xr vmstat 8
                    264: .Sh HISTORY
                    265: The
                    266: .Nm
                    267: command appeared in
                    268: .Bx 4.3 tahoe .
1.29      otto      269: .Sh CAVEATS
                    270: Sockets in use by the kernel, such as those opened by
                    271: .Xr nfsd 8 ,
                    272: will not be seen by
                    273: .Nm ,
                    274: even though they appear in
                    275: .Xr netstat 1 .
1.19      aaron     276: .Sh BUGS
                    277: Since
                    278: .Nm
                    279: takes a snapshot of the system, it is only correct for a very short period
                    280: of time.
                    281: .Pp
                    282: Moreover, because DNS resolution and YP lookups cause many file
                    283: descriptor changes,
                    284: .Nm
                    285: does not attempt to translate the internet address and port numbers into
                    286: symbolic names.