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