xref: /freebsd/usr.bin/fstat/fstat.1 (revision 41466b50c1d5bfd1cf6adaae547a579a75d7c04e)
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.\" $FreeBSD$
34.\"
35.Dd February 25, 1994
36.Dt FSTAT 1
37.Os
38.Sh NAME
39.Nm fstat
40.Nd file status
41.Sh SYNOPSIS
42.Nm
43.Op Fl fmnv
44.Op Fl M Ar core
45.Op Fl N Ar system
46.Op Fl p Ar pid
47.Op Fl u Ar user
48.Op Ar filename...
49.Sh DESCRIPTION
50.Nm Fstat
51identifies open files.
52A file is considered open by a process if it was explicitly opened,
53is the working directory, root directory, active executable text, or kernel
54trace file for that process.
55If no options are specified,
56.Nm
57reports on all open files in the system.
58.Pp
59Options:
60.Bl -tag -width Ds
61.It Fl f
62Restrict examination to files open in the same filesystems as
63the named file arguments, or to the filesystem containing the
64current directory if there are no additional filename arguments.
65For example, to find all files open in the filesystem where the
66directory
67.Pa /usr/src
68resides, type
69.Dq Li fstat -f /usr/src .
70.It Fl M
71Extract values associated with the name list from the specified core
72instead of the default
73.Pa /dev/kmem .
74.It Fl N
75Extract the name list from the specified system instead of the default
76.Pa /kernel .
77.It Fl m
78Include memory-mapped files in the listing; normally these are excluded
79due to the extra processing required.
80.It Fl n
81Numerical format.  Print the device number (maj,min) of the filesystem
82the file resides in rather than the mount point name; for special
83files, print the
84device number that the special device refers to rather than the filename
85in
86.Pa /dev ;
87and print the mode of the file in octal instead of symbolic form.
88.It Fl p
89Report all files open by the specified process.
90.It Fl u
91Report all files open by the specified user.
92.It Fl v
93Verbose mode.  Print error messages upon failures to locate particular
94system data structures rather than silently ignoring them.  Most of
95these data structures are dynamically created or deleted and it is
96possible for them to disappear while
97.Nm
98is running.  This
99is normal and  unavoidable since the rest of the system is running while
100.Nm
101itself is running.
102.It Ar filename ...
103Restrict reports to the specified files.
104.El
105.Pp
106The following fields are printed:
107.Bl -tag -width MOUNT
108.It Li USER
109The username of the owner of the process (effective uid).
110.It Li CMD
111The command name of the process.
112.It Li PID
113The process id.
114.It Li FD
115The file number in the per-process open file table or one of the following
116special names:
117.Pp
118.Bd -literal -offset indent -compact
119text	- executable text inode
120wd 	- current working directory
121root	- root inode
122tr	- kernel trace file
123mmap	- memory-mapped file
124.Ed
125.Pp
126If the file number is followed by an asterisk (``*''), the file is
127not an inode, but rather a socket,
128.Tn FIFO ,
129or there is an error.
130In this case the remainder of the line doesn't
131correspond to the remaining headers -- the format of the line
132is described later under
133.Sx Sockets .
134.It Li MOUNT
135If the
136.Fl n
137flag wasn't specified, this header is present and is the
138pathname that the filesystem the file resides in is mounted on.
139.It Li DEV
140If the
141.Fl n
142flag is specified, this header is present and is the
143major/minor number of the device that this file resides in.
144.It Li INUM
145The inode number of the file.
146.It Li MODE
147The mode of the file.  If the
148.Fl n
149flag isn't specified, the mode is printed
150using a symbolic format (see
151.Xr strmode 3 ) ;
152otherwise, the mode is printed
153as an octal number.
154.It Li SZ\&|DV
155If the file is not a character or block special, prints the size of
156the file in bytes.  Otherwise, if the
157.Fl n
158flag is not specified, prints
159the name of the special file as located in
160.Pa /dev .
161If that cannot be
162located, or the
163.Fl n
164flag is specified, prints the major/minor device
165number that the special device refers to.
166.It Li R/W
167This column describes the access mode that the file allows.
168The letter ``r'' indicates open for reading;
169the letter ``w'' indicates open for writing.
170This field is useful when trying to find the processes that are
171preventing a filesystem from being down graded to read-only.
172.It Li NAME
173If filename arguments are specified and the
174.Fl f
175flag is not, then
176this field is present and is the name associated with the given file.
177Normally the name cannot be determined since there is no mapping
178from an open file back to the directory entry that was used to open
179that file.  Also, since different directory entries may reference
180the same file (via
181.Xr ln 1 ) ,
182the name printed may not be the actual
183name that the process originally used to open that file.
184.El
185.Sh SOCKETS
186The formating of open sockets depends on the protocol domain.
187In all cases the first field is the domain name, the second field
188is the socket type (stream, dgram, etc), and the third is the socket
189flags field (in hex).
190The remaining fields are protocol dependent.
191For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb).
192For unix domain sockets, its the address of the socket pcb and the address
193of the connected pcb (if connected).
194Otherwise the protocol number and address of the socket itself are printed.
195The attempt is to make enough information available to
196permit further analysis without duplicating
197.Xr netstat 1 .
198.Pp
199For example, the addresses mentioned above are the addresses which the
200.Dq Li netstat -A
201command would print for tcp, udp, and unixdomain.
202Note that since pipes are implemented using sockets, a pipe appears as a
203connected unix domain stream socket.
204A unidirectional unix domain socket indicates the direction of flow with
205an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow
206(``<->'').
207.Sh BUGS
208Since
209.Nm
210takes a snapshot of the system, it is only correct for a very short period
211of time.
212.Sh SEE ALSO
213.Xr netstat 1 ,
214.Xr nfsstat 1 ,
215.Xr ps 1 ,
216.Xr sockstat 1 ,
217.Xr systat 1 ,
218.Xr tcp 4 ,
219.Xr unix 4 ,
220.Xr iostat 8 ,
221.Xr pstat 8 ,
222.Xr vmstat 8
223.Sh HISTORY
224The
225.Nm
226command appeared in
227.Bx 4.3 tahoe .
228