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