stat 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. .TH STAT 5
  2. .SH NAME
  3. stat, wstat \- inquire or change file attributes
  4. .SH SYNOPSIS
  5. .ta \w'\fLTwstat 'u
  6. .IR size [4]
  7. .B Tstat
  8. .IR tag [2]
  9. .IR fid [4]
  10. .br
  11. .IR size [4]
  12. .B Rstat
  13. .IR tag [2]
  14. .IR stat [ n ]
  15. .PP
  16. .IR size [4]
  17. .B Twstat
  18. .IR tag [2]
  19. .IR fid [4]
  20. .IR stat [ n ]
  21. .br
  22. .IR size [4]
  23. .B Rwstat
  24. .IR tag [2]
  25. .SH DESCRIPTION
  26. The
  27. .B stat
  28. transaction inquires about the file
  29. identified by
  30. .IR fid .
  31. The reply will contain a
  32. machine-independent
  33. .I directory
  34. .IR entry ,
  35. .IR stat ,
  36. laid out as follows:
  37. .TP
  38. .I size\f1[2]\fP
  39. total byte count of the following data
  40. .TP
  41. .I type\f1[2]\fP
  42. for kernel use
  43. .TP
  44. .I dev\f1[4]\fP
  45. for kernel use
  46. .TP
  47. .I qid.type\f1[1]\fP
  48. the type of the file (directory, etc.), represented as a bit vector
  49. corresponding to the high 8 bits of the file's mode word.
  50. .TP
  51. .I qid.vers\f1[4]\fP
  52. version number for given path
  53. .TP
  54. .I qid.path\f1[8]\fP
  55. the file server's unique identification for the file
  56. .TP
  57. .I mode\f1[4]\fP
  58. permissions and flags
  59. .TP
  60. .I atime\f1[4]\fP
  61. last access time
  62. .TP
  63. .I mtime\f1[4]\fP
  64. last modification time
  65. .TP
  66. .I length\f1[8]\fP
  67. length of file in bytes
  68. .TP
  69. .I name\f1[ s ]\fP
  70. file name; must be
  71. .B /
  72. if the file is the root directory of the server
  73. .TP
  74. .I uid\f1[ s ]\fP
  75. owner name
  76. .TP
  77. .I gid\f1[ s ]\fP
  78. group name
  79. .TP
  80. .I muid\f1[ s ]\fP
  81. name of the user who last modified the file
  82. .PD
  83. .PP
  84. Integers in this encoding are in little-endian order (least
  85. significant byte first).
  86. The
  87. .I convM2D
  88. and
  89. .I convD2M
  90. routines (see
  91. .IR fcall (2))
  92. convert between directory entries and a C structure called a
  93. .BR Dir .
  94. .PP
  95. The
  96. .I mode
  97. contains permission bits as described in
  98. .IR intro (5)
  99. and the following:
  100. .B 0x80000000
  101. .RB ( DMDIR ,
  102. this file is a directory),
  103. .B 0x40000000
  104. .RB ( DMAPPEND ,
  105. append only),
  106. .B 0x20000000
  107. .RB ( DMEXCL ,
  108. exclusive use),
  109. .B 0x04000000
  110. .RB ( DMTMP ,
  111. temporary);
  112. these are echoed in
  113. .BR Qid.type .
  114. Writes to append-only files always place their data at the
  115. end of the file; the
  116. .I offset
  117. in the
  118. .B write
  119. message is ignored, as is the
  120. .B OTRUNC
  121. bit in an open.
  122. Exclusive use files may be open for I/O by only one fid at a time
  123. across all clients of the server. If a second open is attempted,
  124. it draws an error. Servers may implement a timeout on the lock
  125. on an exclusive use file: if the fid holding the file open has
  126. been unused for an extended period (of order at least minutes),
  127. it is reasonable to break the lock and deny the initial fid
  128. further I/O.
  129. Temporary files are not included in nightly archives
  130. (see
  131. .IR fossil (4)).
  132. .PP
  133. The two time fields are measured in seconds since the epoch
  134. (Jan 1 00:00 1970 GMT).
  135. The
  136. .I mtime
  137. field reflects the time of the last change of content (except when later changed by
  138. .BR wstat ).
  139. For a plain file,
  140. .I mtime
  141. is the time of the most recent
  142. .BR create ,
  143. .B open
  144. with truncation,
  145. or
  146. .BR write ;
  147. for a directory it is the time of the most recent
  148. .BR remove ,
  149. .BR create ,
  150. or
  151. .B wstat
  152. of a file in the directory.
  153. Similarly, the
  154. .I atime
  155. field records the last
  156. .B read
  157. of the contents;
  158. also it is set whenever
  159. .I mtime
  160. is set.
  161. In addition, for a directory, it is set by
  162. an
  163. .BR attach ,
  164. .BR walk ,
  165. or
  166. .BR create ,
  167. all whether successful or not.
  168. .PP
  169. The
  170. .I muid
  171. field names the user whose actions most recently changed the
  172. .I mtime
  173. of the file.
  174. .PP
  175. The
  176. .I length
  177. records the number of bytes in the file.
  178. Directories and most files representing devices have a conventional
  179. length of 0.
  180. .PP
  181. The
  182. .B stat
  183. request requires no special permissions.
  184. .PP
  185. The
  186. .B wstat
  187. request can change some of the file status information.
  188. The
  189. .I name
  190. can be changed by anyone with write permission in the parent directory;
  191. it is an error to change the name to that of an existing file.
  192. The
  193. .I length
  194. can be changed (affecting the actual length of the file) by anyone with
  195. write permission on the file.
  196. It is an error to attempt to set the length of a directory to a non-zero value,
  197. and servers may decide to reject length changes for other reasons.
  198. The
  199. .I mode
  200. and
  201. .I mtime
  202. can be changed by the owner of the file or the group leader of the file's current
  203. group.
  204. The directory bit cannot be changed by a
  205. .BR wstat ;
  206. the other defined permission and mode bits can.
  207. The
  208. .I gid
  209. can be changed: by the owner if also a member of the new group; or
  210. by the group leader of the file's current group
  211. if also leader of the new group
  212. (see
  213. .IR intro (5)
  214. for more information about permissions and
  215. .IR users (6)
  216. for users and groups).
  217. None of the other data can be altered by a
  218. .B wstat
  219. and attempts to change them will trigger an error.
  220. In particular,
  221. it is illegal to attempt to change the owner of a file.
  222. (These conditions may be
  223. relaxed when establishing the initial state of a file server; see
  224. .IR fsconfig (8).)
  225. .PP
  226. Either all the changes in
  227. .B wstat
  228. request happen, or none of them does: if the request succeeds,
  229. all changes were made; if it fails, none were.
  230. .PP
  231. A
  232. .B wstat
  233. request can avoid modifying some properties of the file
  234. by providing explicit ``don't touch'' values in the
  235. .B stat
  236. data that is sent: zero-length strings for text values and
  237. the maximum unsigned value of appropriate size
  238. for integral values.
  239. As a special case, if
  240. .I all
  241. the elements of the directory entry in a
  242. .B Twstat
  243. message are ``don't touch'' values, the server may interpret it
  244. as a request to guarantee that the contents of the associated
  245. file are committed to stable storage before the
  246. .B Rwstat
  247. message is returned.
  248. (Consider the message to mean, ``make the state of the file
  249. exactly what it claims to be.'')
  250. .PP
  251. A
  252. .I read
  253. of a directory yields an integral number of directory entries in
  254. the machine independent encoding given above
  255. (see
  256. .IR read (5)).
  257. .PP
  258. Note that since the
  259. .B stat
  260. information is sent as a 9P variable-length datum, it is limited to a maximum of
  261. 65535 bytes.
  262. .SH ENTRY POINTS
  263. .B Stat
  264. messages are generated by
  265. .I fstat
  266. and
  267. .IR stat .
  268. .PP
  269. .B Wstat
  270. messages are generated by
  271. .I fwstat
  272. and
  273. .IR wstat .
  274. .SH BUGS
  275. To make the contents of a directory, such as returned by
  276. .IR read (5),
  277. easy to parse, each
  278. directory entry begins with a size field.
  279. For consistency, the entries in
  280. .B Twstat
  281. and
  282. .B Rstat
  283. messages also contain
  284. their size, which means the size appears twice.
  285. For example, the
  286. .B Rstat
  287. message is formatted as
  288. .RI ``(4+1+2+2+ n )[4]
  289. .B Rstat
  290. .IR tag [2]
  291. .IR n [2]
  292. .RI ( n -2)[2]
  293. .IR type [2]
  294. .IR dev [4]...,''
  295. where
  296. .I n
  297. is the value returned by
  298. .BR convD2M .