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