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