fstat.1 (6f42902de30e2bf53d1934237b98a0531b9eecea) fstat.1 (78ef79139e8c399d47736f910c030be5c3554c34)
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.

--- 14 unchanged lines hidden (view full) ---

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.\"
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.

--- 14 unchanged lines hidden (view full) ---

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
31.Dd June 17, 2020
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

--- 9 unchanged lines hidden (view full) ---

49A file is considered open by a process if it was explicitly opened,
50is the working directory, root directory, jail root directory,
51active executable text, or kernel trace file for that process.
52If no options are specified,
53.Nm
54reports on all open files in the system.
55.Pp
56The following options are available:
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

--- 9 unchanged lines hidden (view full) ---

49A file is considered open by a process if it was explicitly opened,
50is the working directory, root directory, jail root directory,
51active executable text, or kernel trace file for that process.
52If no options are specified,
53.Nm
54reports on all open files in the system.
55.Pp
56The following options are available:
57.Bl -tag -width indent
57.Bl -tag -width "-N system"
58.It Fl f
59Restrict examination to files open in the same file systems as
60the named file arguments, or to the file system containing the
61current directory if there are no additional filename arguments.
62For example, to find all files open in the file system where the
63directory
64.Pa /usr/src
65resides, type
58.It Fl f
59Restrict examination to files open in the same file systems as
60the named file arguments, or to the file system containing the
61current directory if there are no additional filename arguments.
62For example, to find all files open in the file system where the
63directory
64.Pa /usr/src
65resides, type
66.Dq Li fstat -f /usr/src .
67.It Fl M
66.Ql fstat -f /usr/src .
67.It Fl M Ar core
68Extract values associated with the name list from the specified core
69instead of the default
70.Pa /dev/kmem .
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,
73which is the kernel image the system has booted from.
74.It Fl m
75Include memory-mapped files in the listing; normally these are excluded
76due to the extra processing required.
71.It Fl m
72Include memory-mapped files in the listing; normally these are excluded
73due to the extra processing required.
74.It Fl N Ar system
75Extract the name list from the specified system instead of the default,
76which is the kernel image the system has booted from.
77.It Fl n
78Numerical format.
79Print the device number (maj,min) of the file system
80the file resides in rather than the mount point name; for special
81files, print the
82device number that the special device refers to rather than the filename
83in
84.Pa /dev ;
85and print the mode of the file in octal instead of symbolic form.
77.It Fl n
78Numerical format.
79Print the device number (maj,min) of the file system
80the file resides in rather than the mount point name; for special
81files, print the
82device number that the special device refers to rather than the filename
83in
84.Pa /dev ;
85and print the mode of the file in octal instead of symbolic form.
86.It Fl p
86.It Fl p Ar pid
87Report all files open by the specified process.
88.It Fl s
89Print socket endpoint information.
87Report all files open by the specified process.
88.It Fl s
89Print socket endpoint information.
90.It Fl u
90.It Fl u Ar user
91Report all files open by the specified user.
92.It Fl v
93Verbose mode.
94Print error messages upon failures to locate particular
95system data structures rather than silently ignoring them.
96Most of
97these data structures are dynamically created or deleted and it is
98possible for them to disappear while

--- 4 unchanged lines hidden (view full) ---

103.Nm
104itself is running.
105.It Ar
106Restrict reports to the specified files.
107.El
108.Pp
109The following fields are printed:
110.Bl -tag -width MOUNT
91Report all files open by the specified user.
92.It Fl v
93Verbose mode.
94Print error messages upon failures to locate particular
95system data structures rather than silently ignoring them.
96Most of
97these data structures are dynamically created or deleted and it is
98possible for them to disappear while

--- 4 unchanged lines hidden (view full) ---

103.Nm
104itself is running.
105.It Ar
106Restrict reports to the specified files.
107.El
108.Pp
109The following fields are printed:
110.Bl -tag -width MOUNT
111.It Li USER
111.It Sy USER
112The username of the owner of the process (effective uid).
112The username of the owner of the process (effective uid).
113.It Li CMD
113.It Sy CMD
114The command name of the process.
114The command name of the process.
115.It Li PID
115.It Sy PID
116The process id.
116The process id.
117.It Li FD
117.It Sy FD
118The file number in the per-process open file table or one of the following
119special names:
120.Pp
118The file number in the per-process open file table or one of the following
119special names:
120.Pp
121.Bd -literal -offset indent -compact
122jail - jail root directory
123mmap - memory-mapped file
124root - root inode
125text - executable text inode
126tr - kernel trace file
127wd - current working directory
128.Ed
121.Bl -tag -offset indent -compact
122.It Sy jail
123jail root directory
124.It Sy mmap
125memory-mapped file
126.It Sy root
127root inode
128.It Sy text
129executable text inode
130.It Sy tr
131kernel trace file
132.It Sy wd
133current working directory
134.El
129.Pp
135.Pp
130If the file number is followed by an asterisk (``*''), the file is
131not an inode, but rather a socket,
132.Tn FIFO ,
133or there is an error.
136If the file number is followed by an asterisk
137.Pq Ql * ,
138the file is
139not an inode, but rather a socket, FIFO, or there is an error.
134In this case the remainder of the line does not
140In this case the remainder of the line does not
135correspond to the remaining headers -- the format of the line
141correspond to the remaining headers\(em the format of the line
136is described later under
137.Sx SOCKETS .
142is described later under
143.Sx SOCKETS .
138.It Li MOUNT
144.It Sy MOUNT
139If the
140.Fl n
141flag was not specified, this header is present and is the
142pathname that the file system the file resides in is mounted on.
145If the
146.Fl n
147flag was not specified, this header is present and is the
148pathname that the file system the file resides in is mounted on.
143.It Li DEV
149.It Sy DEV
144If the
145.Fl n
146flag is specified, this header is present and is the
147number of the device that this file resides in.
150If the
151.Fl n
152flag is specified, this header is present and is the
153number of the device that this file resides in.
148.It Li INUM
154.It Sy INUM
149The inode number of the file.
155The inode number of the file.
150.It Li MODE
156.It Sy MODE
151The mode of the file.
152If the
153.Fl n
154flag is not specified, the mode is printed
155using a symbolic format (see
156.Xr strmode 3 ) ;
157otherwise, the mode is printed
158as an octal number.
157The mode of the file.
158If the
159.Fl n
160flag is not specified, the mode is printed
161using a symbolic format (see
162.Xr strmode 3 ) ;
163otherwise, the mode is printed
164as an octal number.
159.It Li SZ\&|DV
165.It Sy SZ\&|DV
160If the file is a semaphore,
161prints the current value of the semaphore.
162If the file is not a character or block special, prints the size of
163the file in bytes.
164Otherwise, if the
165.Fl n
166flag is not specified, prints
167the name of the special file as located in
168.Pa /dev .
169If that cannot be
170located, or the
171.Fl n
172flag is specified, prints the major/minor device
173number that the special device refers to.
166If the file is a semaphore,
167prints the current value of the semaphore.
168If the file is not a character or block special, prints the size of
169the file in bytes.
170Otherwise, if the
171.Fl n
172flag is not specified, prints
173the name of the special file as located in
174.Pa /dev .
175If that cannot be
176located, or the
177.Fl n
178flag is specified, prints the major/minor device
179number that the special device refers to.
174.It Li R/W
180.It Sy R/W
175This column describes the access mode that the file allows.
181This column describes the access mode that the file allows.
176The letter ``r'' indicates open for reading;
177the letter ``w'' indicates open for writing.
182The letter
183.Ql r
184indicates open for reading;
185the letter
186.Ql w
187indicates open for writing.
178This field is useful when trying to find the processes that are
179preventing a file system from being down graded to read-only.
188This field is useful when trying to find the processes that are
189preventing a file system from being down graded to read-only.
180.It Li NAME
190.It Sy NAME
181If filename arguments are specified and the
182.Fl f
183flag is not, then
184this field is present and is the name associated with the given file.
185Normally the name cannot be determined since there is no mapping
186from an open file back to the directory entry that was used to open
187that file.
188Also, since different directory entries may reference
189the same file (via
190.Xr ln 1 ) ,
191the name printed may not be the actual
192name that the process originally used to open that file.
193.El
194.Sh SOCKETS
195The formatting of open sockets depends on the protocol domain.
196In all cases the first field is the domain name, the second field
191If filename arguments are specified and the
192.Fl f
193flag is not, then
194this field is present and is the name associated with the given file.
195Normally the name cannot be determined since there is no mapping
196from an open file back to the directory entry that was used to open
197that file.
198Also, since different directory entries may reference
199the same file (via
200.Xr ln 1 ) ,
201the name printed may not be the actual
202name that the process originally used to open that file.
203.El
204.Sh SOCKETS
205The formatting of open sockets depends on the protocol domain.
206In all cases the first field is the domain name, the second field
197is the socket type (stream, dgram, etc), and the third is the socket
207is the socket type (stream, dgram, etc.), and the third is the socket
198flags field (in hex).
199The remaining fields are protocol dependent.
208flags field (in hex).
209The remaining fields are protocol dependent.
200For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb).
201For unix domain sockets, its the address of the socket pcb and the address
210For TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb).
211For UNIX-domain sockets, its the address of the socket pcb and the address
202of the connected pcb (if connected).
203Otherwise the protocol number and address of the socket itself are printed.
204.Pp
205For example, the addresses mentioned above are the addresses which the
212of the connected pcb (if connected).
213Otherwise the protocol number and address of the socket itself are printed.
214.Pp
215For example, the addresses mentioned above are the addresses which the
206.Dq Li netstat -A
207command would print for tcp, udp, and unixdomain.
216.Ql netstat -A
217command would print for TCP, UDP, and UNIX-domain.
208Note that since pipes are implemented using sockets, a pipe appears as a
218Note that since pipes are implemented using sockets, a pipe appears as a
209connected unix domain stream socket.
210A unidirectional unix domain socket indicates the direction of flow with
211an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow
212(``<->'').
219connected UNIX-domain stream socket.
220A unidirectional UNIX-domain socket indicates the direction of flow with
221an arrow
222.Po Ql <-
223or
224.Ql ->
225.Pc ,
226and a full duplex socket shows a double arrow
227.Pq Ql <-> .
213.Pp
214When the
215.Fl s
216flag is used, socket endpoint information is shown after the address of the
217socket.
218For internet sockets the local and remote addresses are shown, separated with
228.Pp
229When the
230.Fl s
231flag is used, socket endpoint information is shown after the address of the
232socket.
233For internet sockets the local and remote addresses are shown, separated with
219a double arrow (``<->'').
220For unix/local sockets either the local or remote address is shown, depending
234a double arrow
235.Pq Ql <-> .
236For UNIX/local sockets either the local or remote address is shown, depending
221on which one is available.
222.Sh SEE ALSO
237on which one is available.
238.Sh SEE ALSO
239.Xr fuser 1 ,
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 ,

--- 13 unchanged lines hidden ---
240.Xr netstat 1 ,
241.Xr nfsstat 1 ,
242.Xr procstat 1 ,
243.Xr ps 1 ,
244.Xr sockstat 1 ,
245.Xr systat 1 ,
246.Xr tcp 4 ,
247.Xr unix 4 ,

--- 13 unchanged lines hidden ---