xref: /freebsd/usr.bin/fstat/fstat.1 (revision 906c1e27fc15d09fe630e425166401aaea7020a5)
1.\" Copyright (c) 1987, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)fstat.1	8.3 (Berkeley) 2/25/94
33.\"
34.Dd February 25, 1994
35.Dt FSTAT 1
36.Os BSD 4
37.Sh NAME
38.Nm fstat
39.Nd file status
40.Sh SYNOPSIS
41.Nm fstat
42.Op Fl fnv
43.Op Fl M Ar core
44.Op Fl N Ar system
45.Op Fl p Ar pid
46.Op Fl u Ar user
47.Op Ar filename...
48.Sh DESCRIPTION
49.Nm Fstat
50identifies open files.
51A file is considered open by a process if it was explicitly opened,
52is the working directory, root directory, active pure text, or kernel
53trace file for that process.
54If no options are specified,
55.Nm fstat
56reports on all open files in the system.
57.Pp
58Options:
59.Bl -tag -width Ds
60.It Fl f
61Restrict examination to files open in the same filesystems as
62the named file arguments, or to the filesystem containing the
63current directory if there are no additional filename arguments.
64For example, to find all files open in the filesystem where the
65directory
66.Pa /usr/src
67resides, type
68.Dq Li fstat -f /usr/src .
69.It Fl M
70Extract values associated with the name list from the specified core
71instead of the default
72.Pa /dev/kmem .
73.It Fl N
74Extract the name list from the specified system instead of the default
75.Pa /kernel .
76.It Fl n
77Numerical format.  Print the device number (maj,min) of the filesystem
78the file resides in rather than the mount point name; for special
79files, print the
80device number that the special device refers to rather than the filename
81in
82.Pa /dev ;
83and print the mode of the file in octal instead of symbolic form.
84.It Fl p
85Report all files open by the specified process.
86.It Fl u
87Report all files open by the specified user.
88.It Fl v
89Verbose mode.  Print error messages upon failures to locate particular
90system data structures rather than silently ignoring them.  Most of
91these data structures are dynamically created or deleted and it is
92possible for them to disappear while
93.Nm fstat
94is running.  This
95is normal and  unavoidable since the rest of the system is running while
96.Nm fstat
97itself is running.
98.It Ar filename ...
99Restrict reports to the specified files.
100.El
101.Pp
102The following fields are printed:
103.Bl -tag -width MOUNT
104.It Li USER
105The username of the owner of the process (effective uid).
106.It Li CMD
107The command name of the process.
108.It Li PID
109The process id.
110.It Li FD
111The file number in the per-process open file table or one of the following
112special names:
113.Pp
114.Bd -ragged -offset indent -compact
115text	- pure text inode
116wd 	- current working directory
117root	- root inode
118tr	- kernel trace file
119.Ed
120.Pp
121If the file number is followed by an asterisk (``*''), the file is
122not an inode, but rather a socket,
123.Tn FIFO ,
124or there is an error.
125In this case the remainder of the line doesn't
126correspond to the remaining headers -- the format of the line
127is described later under
128.Sx Sockets .
129.It Li MOUNT
130If the
131.Fl n
132flag wasn't specified, this header is present and is the
133pathname that the filesystem the file resides in is mounted on.
134.It Li DEV
135If the
136.Fl n
137flag is specified, this header is present and is the
138major/minor number of the device that this file resides in.
139.It Li INUM
140The inode number of the file.
141.It Li MODE
142The mode of the file.  If the
143.Fl n
144flag isn't specified, the mode is printed
145using a symbolic format (see
146.Xr strmode 3 ) ;
147otherwise, the mode is printed
148as an octal number.
149.It Li SZ\&|DV
150If the file is not a character or block special, prints the size of
151the file in bytes.  Otherwise, if the
152.Fl n
153flag is not specified, prints
154the name of the special file as located in
155.Pa /dev .
156If that cannot be
157located, or the
158.Fl n
159flag is specified, prints the major/minor device
160number that the special device refers to.
161.It Li R/W
162This column describes the access mode that the file allows.
163The letter ``r'' indicates open for reading;
164the letter ``w'' indicates open for writing.
165This field is useful when trying to find the processes that are
166preventing a filesystem from being down graded to read-only.
167.It Li NAME
168If filename arguments are specified and the
169.Fl f
170flag is not, then
171this field is present and is the name associated with the given file.
172Normally the name cannot be determined since there is no mapping
173from an open file back to the directory entry that was used to open
174that file.  Also, since different directory entries may reference
175the same file (via
176.Xr ln 1 ) ,
177the name printed may not be the actual
178name that the process originally used to open that file.
179.El
180.Sh SOCKETS
181The formating of open sockets depends on the protocol domain.
182In all cases the first field is the domain name, the second field
183is the socket type (stream, dgram, etc), and the third is the socket
184flags field (in hex).
185The remaining fields are protocol dependent.
186For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb).
187For unix domain sockets, its the address of the socket pcb and the address
188of the connected pcb (if connected).
189Otherwise the protocol number and address of the socket itself are printed.
190The attempt is to make enough information available to
191permit further analysis without duplicating
192.Xr netstat 1 .
193.Pp
194For example, the addresses mentioned above are the addresses which the
195.Dq Li netstat -A
196command would print for tcp, udp, and unixdomain.
197Note that since pipes are implemented using sockets, a pipe appears as a
198connected unix domain stream socket.
199A unidirectional unix domain socket indicates the direction of flow with
200an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow
201(``<->'').
202.Sh BUGS
203Since
204.Nm fstat
205takes a snapshot of the system, it is only correct for a very short period
206of time.
207.Sh SEE ALSO
208.Xr netstat 1 ,
209.Xr nfsstat 1 ,
210.Xr ps 1 ,
211.Xr systat 1 ,
212.Xr iostat 8 ,
213.Xr pstat 8 ,
214.Xr vmstat 8
215.Sh HISTORY
216The
217.Nm
218command appeared in
219.Bx 4.3 tahoe .
220