nfs_prot.x 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */
  2. /*
  3. * nfs_prot.x 1.2 87/10/12
  4. * Copyright (c) 2010, Oracle America, Inc.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are
  8. * met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * * Redistributions in binary form must reproduce the above
  13. * copyright notice, this list of conditions and the following
  14. * disclaimer in the documentation and/or other materials
  15. * provided with the distribution.
  16. * * Neither the name of the "Oracle America, Inc." nor the names of its
  17. * contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  25. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  27. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. const NFS_PORT = 2049;
  34. const NFS_MAXDATA = 8192;
  35. const NFS_MAXPATHLEN = 1024;
  36. const NFS_MAXNAMLEN = 255;
  37. const NFS_FHSIZE = 32;
  38. const NFS_COOKIESIZE = 4;
  39. const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
  40. /*
  41. * File types
  42. */
  43. const NFSMODE_FMT = 0170000; /* type of file */
  44. const NFSMODE_DIR = 0040000; /* directory */
  45. const NFSMODE_CHR = 0020000; /* character special */
  46. const NFSMODE_BLK = 0060000; /* block special */
  47. const NFSMODE_REG = 0100000; /* regular */
  48. const NFSMODE_LNK = 0120000; /* symbolic link */
  49. const NFSMODE_SOCK = 0140000; /* socket */
  50. const NFSMODE_FIFO = 0010000; /* fifo */
  51. /*
  52. * Error status
  53. */
  54. enum nfsstat {
  55. NFS_OK= 0, /* no error */
  56. NFSERR_PERM=1, /* Not owner */
  57. NFSERR_NOENT=2, /* No such file or directory */
  58. NFSERR_IO=5, /* I/O error */
  59. NFSERR_NXIO=6, /* No such device or address */
  60. NFSERR_ACCES=13, /* Permission denied */
  61. NFSERR_EXIST=17, /* File exists */
  62. NFSERR_NODEV=19, /* No such device */
  63. NFSERR_NOTDIR=20, /* Not a directory*/
  64. NFSERR_ISDIR=21, /* Is a directory */
  65. NFSERR_FBIG=27, /* File too large */
  66. NFSERR_NOSPC=28, /* No space left on device */
  67. NFSERR_ROFS=30, /* Read-only file system */
  68. NFSERR_NAMETOOLONG=63, /* File name too long */
  69. NFSERR_NOTEMPTY=66, /* Directory not empty */
  70. NFSERR_DQUOT=69, /* Disc quota exceeded */
  71. NFSERR_STALE=70, /* Stale NFS file handle */
  72. NFSERR_WFLUSH=99 /* write cache flushed */
  73. };
  74. /*
  75. * File types
  76. */
  77. enum ftype {
  78. NFNON = 0, /* non-file */
  79. NFREG = 1, /* regular file */
  80. NFDIR = 2, /* directory */
  81. NFBLK = 3, /* block special */
  82. NFCHR = 4, /* character special */
  83. NFLNK = 5, /* symbolic link */
  84. NFSOCK = 6, /* unix domain sockets */
  85. NFBAD = 7, /* unused */
  86. NFFIFO = 8 /* named pipe */
  87. };
  88. /*
  89. * File access handle
  90. */
  91. struct nfs_fh {
  92. opaque data[NFS_FHSIZE];
  93. };
  94. /*
  95. * Timeval
  96. */
  97. struct nfstime {
  98. unsigned seconds;
  99. unsigned useconds;
  100. };
  101. /*
  102. * File attributes
  103. */
  104. struct fattr {
  105. ftype type; /* file type */
  106. unsigned mode; /* protection mode bits */
  107. unsigned nlink; /* # hard links */
  108. unsigned uid; /* owner user id */
  109. unsigned gid; /* owner group id */
  110. unsigned size; /* file size in bytes */
  111. unsigned blocksize; /* preferred block size */
  112. unsigned rdev; /* special device # */
  113. unsigned blocks; /* Kb of disk used by file */
  114. unsigned fsid; /* device # */
  115. unsigned fileid; /* inode # */
  116. nfstime atime; /* time of last access */
  117. nfstime mtime; /* time of last modification */
  118. nfstime ctime; /* time of last change */
  119. };
  120. /*
  121. * File attributes which can be set
  122. */
  123. struct sattr {
  124. unsigned mode; /* protection mode bits */
  125. unsigned uid; /* owner user id */
  126. unsigned gid; /* owner group id */
  127. unsigned size; /* file size in bytes */
  128. nfstime atime; /* time of last access */
  129. nfstime mtime; /* time of last modification */
  130. };
  131. typedef string filename<NFS_MAXNAMLEN>;
  132. typedef string nfspath<NFS_MAXPATHLEN>;
  133. /*
  134. * Reply status with file attributes
  135. */
  136. union attrstat switch (nfsstat status) {
  137. case NFS_OK:
  138. fattr attributes;
  139. default:
  140. void;
  141. };
  142. struct sattrargs {
  143. nfs_fh file;
  144. sattr attributes;
  145. };
  146. /*
  147. * Arguments for directory operations
  148. */
  149. struct diropargs {
  150. nfs_fh dir; /* directory file handle */
  151. filename name; /* name (up to NFS_MAXNAMLEN bytes) */
  152. };
  153. struct diropokres {
  154. nfs_fh file;
  155. fattr attributes;
  156. };
  157. /*
  158. * Results from directory operation
  159. */
  160. union diropres switch (nfsstat status) {
  161. case NFS_OK:
  162. diropokres diropres;
  163. default:
  164. void;
  165. };
  166. union readlinkres switch (nfsstat status) {
  167. case NFS_OK:
  168. nfspath data;
  169. default:
  170. void;
  171. };
  172. /*
  173. * Arguments to remote read
  174. */
  175. struct readargs {
  176. nfs_fh file; /* handle for file */
  177. unsigned offset; /* byte offset in file */
  178. unsigned count; /* immediate read count */
  179. unsigned totalcount; /* total read count (from this offset)*/
  180. };
  181. /*
  182. * Status OK portion of remote read reply
  183. */
  184. struct readokres {
  185. fattr attributes; /* attributes, need for pagin*/
  186. opaque data<NFS_MAXDATA>;
  187. };
  188. union readres switch (nfsstat status) {
  189. case NFS_OK:
  190. readokres reply;
  191. default:
  192. void;
  193. };
  194. /*
  195. * Arguments to remote write
  196. */
  197. struct writeargs {
  198. nfs_fh file; /* handle for file */
  199. unsigned beginoffset; /* beginning byte offset in file */
  200. unsigned offset; /* current byte offset in file */
  201. unsigned totalcount; /* total write count (to this offset)*/
  202. opaque data<NFS_MAXDATA>;
  203. };
  204. struct createargs {
  205. diropargs where;
  206. sattr attributes;
  207. };
  208. struct renameargs {
  209. diropargs from;
  210. diropargs to;
  211. };
  212. struct linkargs {
  213. nfs_fh from;
  214. diropargs to;
  215. };
  216. struct symlinkargs {
  217. diropargs from;
  218. nfspath to;
  219. sattr attributes;
  220. };
  221. typedef opaque nfscookie[NFS_COOKIESIZE];
  222. /*
  223. * Arguments to readdir
  224. */
  225. struct readdirargs {
  226. nfs_fh dir; /* directory handle */
  227. nfscookie cookie;
  228. unsigned count; /* number of directory bytes to read */
  229. };
  230. struct entry {
  231. unsigned fileid;
  232. filename name;
  233. nfscookie cookie;
  234. entry *nextentry;
  235. };
  236. struct dirlist {
  237. entry *entries;
  238. bool eof;
  239. };
  240. union readdirres switch (nfsstat status) {
  241. case NFS_OK:
  242. dirlist reply;
  243. default:
  244. void;
  245. };
  246. struct statfsokres {
  247. unsigned tsize; /* preferred transfer size in bytes */
  248. unsigned bsize; /* fundamental file system block size */
  249. unsigned blocks; /* total blocks in file system */
  250. unsigned bfree; /* free blocks in fs */
  251. unsigned bavail; /* free blocks avail to non-superuser */
  252. };
  253. union statfsres switch (nfsstat status) {
  254. case NFS_OK:
  255. statfsokres reply;
  256. default:
  257. void;
  258. };
  259. /*
  260. * Remote file service routines
  261. */
  262. program NFS_PROGRAM {
  263. version NFS_VERSION {
  264. void
  265. NFSPROC_NULL(void) = 0;
  266. attrstat
  267. NFSPROC_GETATTR(nfs_fh) = 1;
  268. attrstat
  269. NFSPROC_SETATTR(sattrargs) = 2;
  270. void
  271. NFSPROC_ROOT(void) = 3;
  272. diropres
  273. NFSPROC_LOOKUP(diropargs) = 4;
  274. readlinkres
  275. NFSPROC_READLINK(nfs_fh) = 5;
  276. readres
  277. NFSPROC_READ(readargs) = 6;
  278. void
  279. NFSPROC_WRITECACHE(void) = 7;
  280. attrstat
  281. NFSPROC_WRITE(writeargs) = 8;
  282. diropres
  283. NFSPROC_CREATE(createargs) = 9;
  284. nfsstat
  285. NFSPROC_REMOVE(diropargs) = 10;
  286. nfsstat
  287. NFSPROC_RENAME(renameargs) = 11;
  288. nfsstat
  289. NFSPROC_LINK(linkargs) = 12;
  290. nfsstat
  291. NFSPROC_SYMLINK(symlinkargs) = 13;
  292. diropres
  293. NFSPROC_MKDIR(createargs) = 14;
  294. nfsstat
  295. NFSPROC_RMDIR(diropargs) = 15;
  296. readdirres
  297. NFSPROC_READDIR(readdirargs) = 16;
  298. statfsres
  299. NFSPROC_STATFS(nfs_fh) = 17;
  300. } = 2;
  301. } = 100003;