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