xref: /netbsd/usr.bin/fstat/fstat.1 (revision c4a72b64)
1.\"	$NetBSD: fstat.1,v 1.22 2002/11/07 13:52:04 enami 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.22 2002/11/07 13:52:04 enami 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
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.
81Print 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.
94Print error messages upon failures to locate particular
95system data structures rather than silently ignoring them.
96Most of
97these data structures are dynamically created or deleted and it is
98possible for them to disappear while
99.Nm
100is running.
101This
102is normal and  unavoidable since the rest of the system is running while
103.Nm
104itself is running.
105.It Ar
106Restrict reports to the specified files.
107.El
108.Pp
109The following fields are printed:
110.Bl -tag -width MOUNT
111.It Li USER
112The username of the owner of the process (effective UID).
113.It Li CMD
114The command name of the process.
115.It Li PID
116The process ID.
117.It Li FD
118The file number in the per-process open file table or one of the following
119special names:
120.Pp
121.Bl -tag -width MOUNT -offset indent -compact
122.It Li text
123pure text inode
124.It Li wd
125current working directory
126.It Li root
127root inode
128.It Li tr
129kernel trace file
130.El
131.Pp
132If the file number is followed by an asterisk
133.Pq Dq * ,
134the file is not an inode, but rather a socket,
135.Tn FIFO ,
136or there is an error.
137In this case the remainder of the line doesn't
138correspond to the remaining headers -- the format of the line
139is described later under
140.Sx SOCKETS .
141.It Li MOUNT
142If the
143.Fl n
144flag wasn't specified, this header is present and is the
145pathname that the filesystem the file resides in is mounted on.
146.It Li DEV
147If the
148.Fl n
149flag is specified, this header is present and is the
150major/minor number of the device that this file resides in.
151.It Li INUM
152The inode number of the file.
153.It Li MODE
154The mode of the file.
155If the
156.Fl n
157flag isn't specified, the mode is printed
158using a symbolic format (see
159.Xr strmode 3 ) ;
160otherwise, the mode is printed
161as an octal number.
162.It Li SZ\&|DV
163If the file is not a character or block special file, prints the size of
164the file in bytes.
165Otherwise, if the
166.Fl n
167flag is not specified, prints
168the name of the special file as located in
169.Pa /dev .
170If that cannot be
171located, or the
172.Fl n
173flag is specified, prints the major/minor device
174number that the special device refers to.
175.It Li R/W
176This column describes the access mode that the file allows.
177The letter
178.Dq r
179indicates open for reading;
180the letter
181.Dq w
182indicates open for writing.
183This field is useful when trying to find the processes that are
184preventing a filesystem from being downgraded to read-only.
185.It Li NAME
186If filename arguments are specified and the
187.Fl f
188flag is not, then
189this field is present and is the name associated with the given file.
190Normally the name cannot be determined since there is no mapping
191from an open file back to the directory entry that was used to open
192that file.
193Also, since different directory entries may reference
194the same file (via
195.Xr ln 1 ) ,
196the name printed may not be the actual
197name that the process originally used to open that file.
198.El
199.Sh SOCKETS
200The formatting of open sockets depends on the protocol domain.
201In all cases the first field is the domain name, the second field
202is the socket type (stream, dgram, etc), and the third is the socket
203flags field (in hex).
204The remaining fields are protocol dependent.
205For TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb).
206For
207.Ux
208domain sockets, its the address of the socket pcb and the address
209of the connected pcb (if connected).
210Otherwise the protocol number and address of the socket itself are printed.
211The attempt is to make enough information available to
212permit further analysis without duplicating
213.Xr netstat 1 .
214.Pp
215For example, the addresses mentioned above are the addresses which the
216.Dq Li netstat -A
217command would print for TCP, UDP, and
218.Ux
219domain.
220Note that since pipes are implemented using sockets, a pipe appears as a
221connected
222.Ux
223domain stream socket.
224A unidirectional
225.Ux
226domain socket indicates the direction of flow with an arrow
227.Po
228.Dq \*[Lt]-
229or
230.Dq -\*[Gt]
231.Pc ,
232and a full duplex socket shows a double arrow
233.Pq Dq \*[Lt]-\*[Gt] .
234.Pp
235For internet sockets
236.Nm fstat
237also attempts to print the internet address and port for the
238local end of a connection.
239If the socket is connected, it also prints the remote internet address
240and port.
241An asterisk
242.Pq Dq *
243is used to indicate an INADDR_ANY binding.
244.Sh SEE ALSO
245.Xr netstat 1 ,
246.Xr nfsstat 1 ,
247.Xr ps 1 ,
248.Xr systat 1 ,
249.Xr vmstat 1 ,
250.Xr iostat 8 ,
251.Xr pstat 8
252.Sh HISTORY
253The
254.Nm
255command appeared in
256.Bx 4.3 tahoe .
257.Sh BUGS
258Since
259.Nm
260takes a snapshot of the system, it is only correct for a very short period
261of time.
262.Pp
263Moreover, because DNS resolution and YP lookups cause many file
264descriptor changes,
265.Nm
266does not attempt to translate the internet address and port numbers into
267symbolic names.
268