xref: /original-bsd/usr.bin/fstat/fstat.1 (revision 9756c099)
1.\" Copyright (c) 1987, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"     @(#)fstat.1	8.2 (Berkeley) 02/16/94
7.\"
8.Dd
9.Dt FSTAT 1
10.Os BSD 4
11.Sh NAME
12.Nm fstat
13.Nd file status
14.Sh SYNOPSIS
15.Nm fstat
16.Op Fl fnv
17.Op Fl M Ar core
18.Op Fl N Ar system
19.Op Fl p Ar pid
20.Op Fl u Ar user
21.Op Ar filename...
22.Sh DESCRIPTION
23.Nm Fstat
24identifies open files.
25A file is considered open by a process if it was explicitly opened,
26is the working directory, root directory, active pure text, or kernel
27trace file for that process.
28If no options are specified,
29.Nm fstat
30reports on all open files in the system.
31.Pp
32Options:
33.Bl -tag -width Ds
34.It Fl f
35If additional filename arguments are present, restrict examination to files
36open in the same filesystem as the named file arguments.
37For example, to find all files open in the filesystem where the
38directory
39.Pa /usr/src
40resides, type
41.Dq Li fstat -f /usr/src .
42.It Fl M
43Extract values associated with the name list from the specified core
44instead of the default
45.Pa /dev/kmem .
46.It Fl N
47Extract the name list from the specified system instead of the default
48.Pa /vmunix .
49.It Fl n
50Numerical format.  Print the device number (maj,min) of the filesystem
51the file resides in rather than the mount point name; for special
52files, print the
53device number that the special device refers to rather than the filename
54in
55.Pa /dev ;
56and print the mode of the file in octal instead of symbolic form.
57.It Fl p
58Report all files open by the specified process.
59.It Fl u
60Report all files open by the specified user.
61.It Fl v
62Verbose mode.  Print error messages upon failures to locate particular
63system data structures rather than silently ignoring them.  Most of
64these data structures are dynamically created or deleted and it is
65possible for them to disappear while
66.Nm fstat
67is running.  This
68is normal and  unavoidable since the rest of the system is running while
69.Nm fstat
70itself is running.
71.It Ar filename ...
72Restrict reports to the specified files.
73.El
74.Pp
75The following fields are printed:
76.Bl -tag -width MOUNT
77.It Li USER
78The username of the owner of the process (effective uid).
79.It Li CMD
80The command name of the process.
81.It Li PID
82The process id.
83.It Li FD
84The file number in the per-process open file table or one of the following
85special names:
86.Pp
87.Bd -ragged -offset indent -compact
88text	- pure text inode
89wd 	- current working directory
90root	- root inode
91tr	- kernel trace file
92.Ed
93.Pp
94If the file number is followed by an asterisk (``*''), the file is
95not an inode, but rather a socket,
96.Tn FIFO ,
97or there is an error.
98In this case the remainder of the line doesn't
99correspond to the remaining headers -- the format of the line
100is described later under
101.Sx Sockets .
102.It Li MOUNT
103If the
104.Fl n
105flag wasn't specified, this header is present and is the
106pathname that the filesystem the file resides in is mounted on.
107.It Li DEV
108If the
109.Fl n
110flag is specified, this header is present and is the
111major/minor number of the device that this file resides in.
112.It Li INUM
113The inode number of the file.
114.It Li MODE
115The mode of the file.  If the
116.Fl n
117flag isn't specified, the mode is printed
118using a symbolic format (see
119.Xr strmode 3 ) ;
120otherwise, the mode is printed
121as an octal number.
122.It Li SZ\&|DV
123If the file is not a character or block special, prints the size of
124the file in bytes.  Otherwise, if the
125.Fl n
126flag is not specified, prints
127the name of the special file as located in
128.Pa /dev .
129If that cannot be
130located, or the
131.Fl n
132flag is specified, prints the major/minor device
133number that the special device refers to.
134.It Li R/W
135This column describes the access mode that the file allows.
136The letter ``r'' indicates open for reading;
137the letter ``w'' indicates open for writing.
138This field is useful when trying to find the processes that are
139preventing a filesystem from being down graded to read-only.
140.It Li NAME
141If filename arguments are specified and the
142.Fl f
143flag is not, then
144this field is present and is the name associated with the given file.
145Normally the name cannot be determined since there is no mapping
146from an open file back to the directory entry that was used to open
147that file.  Also, since different directory entries may reference
148the same file (via
149.Xr ln 2 ) ,
150the name printed may not be the actual
151name that the process originally used to open that file.
152.El
153.Sh SOCKETS
154The formating of open sockets depends on the protocol domain.
155In all cases the first field is the domain name, the second field
156is the socket type (stream, dgram, etc), and the third is the socket
157flags field (in hex).
158The remaining fields are protocol dependent.
159For tcp, it is the address of the tcpcb, and for udp, the inpcb (socket pcb).
160For unix domain sockets, its the address of the socket pcb and the address
161of the connected pcb (if connected).
162Otherwise the protocol number and address of the socket itself are printed.
163The attempt is to make enough information available to
164permit further analysis without duplicating
165.Xr netstat 1 .
166.Pp
167For example, the addresses mentioned above are the addresses which the
168.Dq Li netstat -A
169command would print for tcp, udp, and unixdomain.
170Note that since pipes are implemented using sockets, a pipe appears as a
171connected unix domain stream socket.
172A unidirectional unix domain socket indicates the direction of flow with
173an arrow (``<-'' or ``->''), and a full duplex socket shows a double arrow
174(``<->'').
175.Sh BUGS
176Since
177.Nm fstat
178takes a snapshot of the system, it is only correct for a very short period
179of time.
180.Sh SEE ALSO
181.Xr netstat 1 ,
182.Xr nfsstat 1 ,
183.Xr ps 1 ,
184.Xr systat 1 ,
185.Xr vmstat 1 ,
186.Xr iostat 8 ,
187.Xr pstat 8
188.Sh HISTORY
189The
190.Nm
191command appeared in
192.Bx 4.3 tahoe .
193