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