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