xref: /freebsd/usr.bin/fstat/fstat.1 (revision 78ef79139e8c399d47736f910c030be5c3554c34)
19b50d902SRodney W. Grimes.\" Copyright (c) 1987, 1991, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
59b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
69b50d902SRodney W. Grimes.\" are met:
79b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
89b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
99b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
109b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
119b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
139b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
149b50d902SRodney W. Grimes.\"    without specific prior written permission.
159b50d902SRodney W. Grimes.\"
169b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
179b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
189b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
209b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
219b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
229b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
239b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
249b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
259b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
269b50d902SRodney W. Grimes.\" SUCH DAMAGE.
279b50d902SRodney W. Grimes.\"
289b50d902SRodney W. Grimes.\"     @(#)fstat.1	8.3 (Berkeley) 2/25/94
29c3aac50fSPeter Wemm.\" $FreeBSD$
309b50d902SRodney W. Grimes.\"
31*78ef7913SMateusz Piotrowski.Dd June 17, 2020
329b50d902SRodney W. Grimes.Dt FSTAT 1
3362500372SRuslan Ermilov.Os
349b50d902SRodney W. Grimes.Sh NAME
359b50d902SRodney W. Grimes.Nm fstat
3690eca7b6SGarrett Wollman.Nd identify active files
379b50d902SRodney W. Grimes.Sh SYNOPSIS
388fe908efSRuslan Ermilov.Nm
3991ad311bSJeremie Le Hen.Op Fl fmnsv
409b50d902SRodney W. Grimes.Op Fl M Ar core
419b50d902SRodney W. Grimes.Op Fl N Ar system
429b50d902SRodney W. Grimes.Op Fl p Ar pid
439b50d902SRodney W. Grimes.Op Fl u Ar user
4491966d21SPhilippe Charnier.Op Ar
459b50d902SRodney W. Grimes.Sh DESCRIPTION
46e8937ba0SPhilippe CharnierThe
47e8937ba0SPhilippe Charnier.Nm
48e8937ba0SPhilippe Charnierutility identifies open files.
499b50d902SRodney W. GrimesA file is considered open by a process if it was explicitly opened,
506b020622SPoul-Henning Kampis the working directory, root directory, jail root directory,
516b020622SPoul-Henning Kampactive executable text, or kernel trace file for that process.
529b50d902SRodney W. GrimesIf no options are specified,
538fe908efSRuslan Ermilov.Nm
549b50d902SRodney W. Grimesreports on all open files in the system.
559b50d902SRodney W. Grimes.Pp
562a00e8eaSPhilippe CharnierThe following options are available:
57*78ef7913SMateusz Piotrowski.Bl -tag -width "-N system"
589b50d902SRodney W. Grimes.It Fl f
599b50d902SRodney W. GrimesRestrict examination to files open in the same file systems as
609b50d902SRodney W. Grimesthe named file arguments, or to the file system containing the
619b50d902SRodney W. Grimescurrent directory if there are no additional filename arguments.
629b50d902SRodney W. GrimesFor example, to find all files open in the file system where the
639b50d902SRodney W. Grimesdirectory
649b50d902SRodney W. Grimes.Pa /usr/src
659b50d902SRodney W. Grimesresides, type
66*78ef7913SMateusz Piotrowski.Ql fstat -f /usr/src .
67*78ef7913SMateusz Piotrowski.It Fl M Ar core
689b50d902SRodney W. GrimesExtract values associated with the name list from the specified core
699b50d902SRodney W. Grimesinstead of the default
709b50d902SRodney W. Grimes.Pa /dev/kmem .
71d0482be8SBrian Feldman.It Fl m
72d0482be8SBrian FeldmanInclude memory-mapped files in the listing; normally these are excluded
73d0482be8SBrian Feldmandue to the extra processing required.
74*78ef7913SMateusz Piotrowski.It Fl N Ar system
75*78ef7913SMateusz PiotrowskiExtract the name list from the specified system instead of the default,
76*78ef7913SMateusz Piotrowskiwhich is the kernel image the system has booted from.
779b50d902SRodney W. Grimes.It Fl n
786a3e8b0aSRuslan ErmilovNumerical format.
796a3e8b0aSRuslan ErmilovPrint the device number (maj,min) of the file system
809b50d902SRodney W. Grimesthe file resides in rather than the mount point name; for special
819b50d902SRodney W. Grimesfiles, print the
829b50d902SRodney W. Grimesdevice number that the special device refers to rather than the filename
839b50d902SRodney W. Grimesin
849b50d902SRodney W. Grimes.Pa /dev ;
859b50d902SRodney W. Grimesand print the mode of the file in octal instead of symbolic form.
86*78ef7913SMateusz Piotrowski.It Fl p Ar pid
879b50d902SRodney W. GrimesReport all files open by the specified process.
8891ad311bSJeremie Le Hen.It Fl s
8991ad311bSJeremie Le HenPrint socket endpoint information.
90*78ef7913SMateusz Piotrowski.It Fl u Ar user
919b50d902SRodney W. GrimesReport all files open by the specified user.
929b50d902SRodney W. Grimes.It Fl v
936a3e8b0aSRuslan ErmilovVerbose mode.
946a3e8b0aSRuslan ErmilovPrint error messages upon failures to locate particular
956a3e8b0aSRuslan Ermilovsystem data structures rather than silently ignoring them.
966a3e8b0aSRuslan ErmilovMost of
979b50d902SRodney W. Grimesthese data structures are dynamically created or deleted and it is
989b50d902SRodney W. Grimespossible for them to disappear while
998fe908efSRuslan Ermilov.Nm
1006a3e8b0aSRuslan Ermilovis running.
1016a3e8b0aSRuslan ErmilovThis
1029b50d902SRodney W. Grimesis normal and unavoidable since the rest of the system is running while
1038fe908efSRuslan Ermilov.Nm
1049b50d902SRodney W. Grimesitself is running.
10591966d21SPhilippe Charnier.It Ar
1069b50d902SRodney W. GrimesRestrict reports to the specified files.
1079b50d902SRodney W. Grimes.El
1089b50d902SRodney W. Grimes.Pp
1099b50d902SRodney W. GrimesThe following fields are printed:
1109b50d902SRodney W. Grimes.Bl -tag -width MOUNT
111*78ef7913SMateusz Piotrowski.It Sy USER
1129b50d902SRodney W. GrimesThe username of the owner of the process (effective uid).
113*78ef7913SMateusz Piotrowski.It Sy CMD
1149b50d902SRodney W. GrimesThe command name of the process.
115*78ef7913SMateusz Piotrowski.It Sy PID
1169b50d902SRodney W. GrimesThe process id.
117*78ef7913SMateusz Piotrowski.It Sy FD
1189b50d902SRodney W. GrimesThe file number in the per-process open file table or one of the following
1199b50d902SRodney W. Grimesspecial names:
1209b50d902SRodney W. Grimes.Pp
121*78ef7913SMateusz Piotrowski.Bl -tag -offset indent -compact
122*78ef7913SMateusz Piotrowski.It Sy jail
123*78ef7913SMateusz Piotrowskijail root directory
124*78ef7913SMateusz Piotrowski.It Sy mmap
125*78ef7913SMateusz Piotrowskimemory-mapped file
126*78ef7913SMateusz Piotrowski.It Sy root
127*78ef7913SMateusz Piotrowskiroot inode
128*78ef7913SMateusz Piotrowski.It Sy text
129*78ef7913SMateusz Piotrowskiexecutable text inode
130*78ef7913SMateusz Piotrowski.It Sy tr
131*78ef7913SMateusz Piotrowskikernel trace file
132*78ef7913SMateusz Piotrowski.It Sy wd
133*78ef7913SMateusz Piotrowskicurrent working directory
134*78ef7913SMateusz Piotrowski.El
1359b50d902SRodney W. Grimes.Pp
136*78ef7913SMateusz PiotrowskiIf the file number is followed by an asterisk
137*78ef7913SMateusz Piotrowski.Pq Ql * ,
138*78ef7913SMateusz Piotrowskithe file is
139*78ef7913SMateusz Piotrowskinot an inode, but rather a socket, FIFO, or there is an error.
1400227791bSRuslan ErmilovIn this case the remainder of the line does not
141*78ef7913SMateusz Piotrowskicorrespond to the remaining headers\(em the format of the line
1429b50d902SRodney W. Grimesis described later under
1436e679990SPawel Jakub Dawidek.Sx SOCKETS .
144*78ef7913SMateusz Piotrowski.It Sy MOUNT
1459b50d902SRodney W. GrimesIf the
1469b50d902SRodney W. Grimes.Fl n
1470227791bSRuslan Ermilovflag was not specified, this header is present and is the
1489b50d902SRodney W. Grimespathname that the file system the file resides in is mounted on.
149*78ef7913SMateusz Piotrowski.It Sy DEV
1509b50d902SRodney W. GrimesIf the
1519b50d902SRodney W. Grimes.Fl n
1529b50d902SRodney W. Grimesflag is specified, this header is present and is the
1539f365aa1SEd Schoutennumber of the device that this file resides in.
154*78ef7913SMateusz Piotrowski.It Sy INUM
1559b50d902SRodney W. GrimesThe inode number of the file.
156*78ef7913SMateusz Piotrowski.It Sy MODE
1576a3e8b0aSRuslan ErmilovThe mode of the file.
1586a3e8b0aSRuslan ErmilovIf the
1599b50d902SRodney W. Grimes.Fl n
1600227791bSRuslan Ermilovflag is not specified, the mode is printed
1619b50d902SRodney W. Grimesusing a symbolic format (see
1629b50d902SRodney W. Grimes.Xr strmode 3 ) ;
1639b50d902SRodney W. Grimesotherwise, the mode is printed
1649b50d902SRodney W. Grimesas an octal number.
165*78ef7913SMateusz Piotrowski.It Sy SZ\&|DV
166958aa575SJohn BaldwinIf the file is a semaphore,
167958aa575SJohn Baldwinprints the current value of the semaphore.
1689b50d902SRodney W. GrimesIf the file is not a character or block special, prints the size of
1696a3e8b0aSRuslan Ermilovthe file in bytes.
1706a3e8b0aSRuslan ErmilovOtherwise, if the
1719b50d902SRodney W. Grimes.Fl n
1729b50d902SRodney W. Grimesflag is not specified, prints
1739b50d902SRodney W. Grimesthe name of the special file as located in
1749b50d902SRodney W. Grimes.Pa /dev .
1759b50d902SRodney W. GrimesIf that cannot be
1769b50d902SRodney W. Grimeslocated, or the
1779b50d902SRodney W. Grimes.Fl n
1789b50d902SRodney W. Grimesflag is specified, prints the major/minor device
1799b50d902SRodney W. Grimesnumber that the special device refers to.
180*78ef7913SMateusz Piotrowski.It Sy R/W
1819b50d902SRodney W. GrimesThis column describes the access mode that the file allows.
182*78ef7913SMateusz PiotrowskiThe letter
183*78ef7913SMateusz Piotrowski.Ql r
184*78ef7913SMateusz Piotrowskiindicates open for reading;
185*78ef7913SMateusz Piotrowskithe letter
186*78ef7913SMateusz Piotrowski.Ql w
187*78ef7913SMateusz Piotrowskiindicates open for writing.
1889b50d902SRodney W. GrimesThis field is useful when trying to find the processes that are
1899b50d902SRodney W. Grimespreventing a file system from being down graded to read-only.
190*78ef7913SMateusz Piotrowski.It Sy NAME
1919b50d902SRodney W. GrimesIf filename arguments are specified and the
1929b50d902SRodney W. Grimes.Fl f
1939b50d902SRodney W. Grimesflag is not, then
1949b50d902SRodney W. Grimesthis field is present and is the name associated with the given file.
1959b50d902SRodney W. GrimesNormally the name cannot be determined since there is no mapping
1969b50d902SRodney W. Grimesfrom an open file back to the directory entry that was used to open
1976a3e8b0aSRuslan Ermilovthat file.
1986a3e8b0aSRuslan ErmilovAlso, since different directory entries may reference
1999b50d902SRodney W. Grimesthe same file (via
200906c1e27SMike Pritchard.Xr ln 1 ) ,
2019b50d902SRodney W. Grimesthe name printed may not be the actual
2029b50d902SRodney W. Grimesname that the process originally used to open that file.
2039b50d902SRodney W. Grimes.El
2049b50d902SRodney W. Grimes.Sh SOCKETS
205f6ac2391SJoel DahlThe formatting of open sockets depends on the protocol domain.
2069b50d902SRodney W. GrimesIn all cases the first field is the domain name, the second field
207*78ef7913SMateusz Piotrowskiis the socket type (stream, dgram, etc.), and the third is the socket
2089b50d902SRodney W. Grimesflags field (in hex).
2099b50d902SRodney W. GrimesThe remaining fields are protocol dependent.
210*78ef7913SMateusz PiotrowskiFor TCP, it is the address of the tcpcb, and for UDP, the inpcb (socket pcb).
211*78ef7913SMateusz PiotrowskiFor UNIX-domain sockets, its the address of the socket pcb and the address
2129b50d902SRodney W. Grimesof the connected pcb (if connected).
2139b50d902SRodney W. GrimesOtherwise the protocol number and address of the socket itself are printed.
2149b50d902SRodney W. Grimes.Pp
2159b50d902SRodney W. GrimesFor example, the addresses mentioned above are the addresses which the
216*78ef7913SMateusz Piotrowski.Ql netstat -A
217*78ef7913SMateusz Piotrowskicommand would print for TCP, UDP, and UNIX-domain.
2189b50d902SRodney W. GrimesNote that since pipes are implemented using sockets, a pipe appears as a
219*78ef7913SMateusz Piotrowskiconnected UNIX-domain stream socket.
220*78ef7913SMateusz PiotrowskiA unidirectional UNIX-domain socket indicates the direction of flow with
221*78ef7913SMateusz Piotrowskian arrow
222*78ef7913SMateusz Piotrowski.Po Ql <-
223*78ef7913SMateusz Piotrowskior
224*78ef7913SMateusz Piotrowski.Ql ->
225*78ef7913SMateusz Piotrowski.Pc ,
226*78ef7913SMateusz Piotrowskiand a full duplex socket shows a double arrow
227*78ef7913SMateusz Piotrowski.Pq Ql <-> .
22891ad311bSJeremie Le Hen.Pp
22991ad311bSJeremie Le HenWhen the
23091ad311bSJeremie Le Hen.Fl s
23191ad311bSJeremie Le Henflag is used, socket endpoint information is shown after the address of the
23291ad311bSJeremie Le Hensocket.
2336f42902dSJeremie Le HenFor internet sockets the local and remote addresses are shown, separated with
234*78ef7913SMateusz Piotrowskia double arrow
235*78ef7913SMateusz Piotrowski.Pq Ql <-> .
236*78ef7913SMateusz PiotrowskiFor UNIX/local sockets either the local or remote address is shown, depending
23791ad311bSJeremie Le Henon which one is available.
2389b50d902SRodney W. Grimes.Sh SEE ALSO
239*78ef7913SMateusz Piotrowski.Xr fuser 1 ,
2409b50d902SRodney W. Grimes.Xr netstat 1 ,
2419b50d902SRodney W. Grimes.Xr nfsstat 1 ,
242e5002279SEdward Tomasz Napierala.Xr procstat 1 ,
2439b50d902SRodney W. Grimes.Xr ps 1 ,
2445ff829fdSSheldon Hearn.Xr sockstat 1 ,
2459b50d902SRodney W. Grimes.Xr systat 1 ,
2465ff829fdSSheldon Hearn.Xr tcp 4 ,
2475ff829fdSSheldon Hearn.Xr unix 4 ,
2489b50d902SRodney W. Grimes.Xr iostat 8 ,
249270d3d75SMike Pritchard.Xr pstat 8 ,
250270d3d75SMike Pritchard.Xr vmstat 8
2519b50d902SRodney W. Grimes.Sh HISTORY
2529b50d902SRodney W. GrimesThe
2539b50d902SRodney W. Grimes.Nm
2549b50d902SRodney W. Grimescommand appeared in
2559b50d902SRodney W. Grimes.Bx 4.3 tahoe .
2566c7216dfSRuslan Ermilov.Sh BUGS
2576c7216dfSRuslan ErmilovSince
2586c7216dfSRuslan Ermilov.Nm
2596c7216dfSRuslan Ermilovtakes a snapshot of the system, it is only correct for a very short period
2606c7216dfSRuslan Ermilovof time.
261