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