home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / nfsd / x / nfs.x < prev    next >
Encoding:
Text File  |  1999-04-13  |  7.8 KB  |  366 lines

  1. %/*
  2. % * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  3. % * unrestricted use provided that this legend is included on all tape
  4. % * media and as a part of the software program in whole or part.  Users
  5. % * may copy or modify Sun RPC without charge, but are not authorized
  6. % * to license or distribute it to anyone else except as part of a product or
  7. % * program developed by the user or with the express written consent of
  8. % * Sun Microsystems, Inc.
  9. % *
  10. % * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  11. % * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  12. % * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  13. % *
  14. % * Sun RPC is provided with no support and without any obligation on the
  15. % * part of Sun Microsystems, Inc. to assist in its use, correction,
  16. % * modification or enhancement.
  17. % *
  18. % * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  19. % * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  20. % * OR ANY PART THEREOF.
  21. % *
  22. % * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  23. % * or profits or other special, indirect and consequential damages, even if
  24. % * Sun has been advised of the possibility of such damages.
  25. % *
  26. % * Sun Microsystems, Inc.
  27. % * 2550 Garcia Avenue
  28. % * Mountain View, California  94043
  29. % */
  30.  
  31. %/*
  32. % * Copyright (c) 1987, 1990 by Sun Microsystems, Inc.
  33. % */
  34. %
  35. %/* from @(#)nfs_prot.x    1.3 91/03/11 TIRPC 1.0 */
  36.  
  37. #ifdef RPC_HDR
  38. %#ifndef _rpcsvc_nfs_prot_h
  39. %#define _rpcsvc_nfs_prot_h
  40. #endif
  41.  
  42. const NFS_PORT          = 2049;
  43. const NFS_MAXDATA       = 8192;
  44. const NFS_MAXPATHLEN    = 1024;
  45. const NFS_MAXNAMLEN    = 255;
  46. const NFS_FHSIZE    = 32;
  47. const NFS_COOKIESIZE    = 4;
  48. const NFS_FIFO_DEV    = -1;    /* size kludge for named pipes */
  49.  
  50. /*
  51.  * File types
  52.  */
  53. const NFSMODE_FMT  = 0170000;    /* type of file */
  54. const NFSMODE_DIR  = 0040000;    /* directory */
  55. const NFSMODE_CHR  = 0020000;    /* character special */
  56. const NFSMODE_BLK  = 0060000;    /* block special */
  57. const NFSMODE_REG  = 0100000;    /* regular */
  58. const NFSMODE_LNK  = 0120000;    /* symbolic link */
  59. const NFSMODE_SOCK = 0140000;    /* socket */
  60. const NFSMODE_FIFO = 0010000;    /* fifo */
  61.  
  62. /*
  63.  * Error status
  64.  */
  65. enum nfsstat {
  66.     NFS_OK= 0,        /* no error */
  67.     NFSERR_PERM=1,        /* Not owner */
  68.     NFSERR_NOENT=2,        /* No such file or directory */
  69.     NFSERR_IO=5,        /* I/O error */
  70.     NFSERR_NXIO=6,        /* No such device or address */
  71.     NFSERR_ACCES=13,    /* Permission denied */
  72.     NFSERR_EXIST=17,    /* File exists */
  73.     NFSERR_NODEV=19,    /* No such device */
  74.     NFSERR_NOTDIR=20,    /* Not a directory*/
  75.     NFSERR_ISDIR=21,    /* Is a directory */
  76.     NFSERR_INVAL=22,    /* invalid argument */
  77.     NFSERR_FBIG=27,        /* File too large */
  78.     NFSERR_NOSPC=28,    /* No space left on device */
  79.     NFSERR_ROFS=30,        /* Read-only file system */
  80.     NFSERR_NAMETOOLONG=63,    /* File name too long */
  81.     NFSERR_NOTEMPTY=66,    /* Directory not empty */
  82.     NFSERR_DQUOT=69,    /* Disc quota exceeded */
  83.     NFSERR_STALE=70,    /* Stale NFS file handle */
  84.     NFSERR_WFLUSH=99    /* write cache flushed */
  85. };
  86.  
  87. /*
  88.  * File types
  89.  */
  90. enum ftype {
  91.     NFNON = 0,    /* non-file */
  92.     NFREG = 1,    /* regular file */
  93.     NFDIR = 2,    /* directory */
  94.     NFBLK = 3,    /* block special */
  95.     NFCHR = 4,    /* character special */
  96.     NFLNK = 5,    /* symbolic link */
  97.     NFSOCK = 6,    /* unix domain sockets */
  98.     NFBAD = 7,    /* unused */
  99.     NFFIFO = 8     /* named pipe */
  100. };
  101.  
  102. /*
  103.  * File access handle
  104.  */
  105. struct nfs_fh {
  106.     opaque data[NFS_FHSIZE];
  107. };
  108.  
  109. /* 
  110.  * Timeval
  111.  */
  112. struct nfstime {
  113.     unsigned seconds;
  114.     unsigned useconds;
  115. };
  116.  
  117.  
  118. /*
  119.  * File attributes
  120.  */
  121. struct fattr {
  122.     ftype type;        /* file type */
  123.     unsigned mode;        /* protection mode bits */
  124.     unsigned nlink;        /* # hard links */
  125.     unsigned uid;        /* owner user id */
  126.     unsigned gid;        /* owner group id */
  127.     unsigned size;        /* file size in bytes */
  128.     unsigned blocksize;    /* prefered block size */
  129.     unsigned rdev;        /* special device # */
  130.     unsigned blocks;    /* Kb of disk used by file */
  131.     unsigned fsid;        /* device # */
  132.     unsigned fileid;    /* inode # */
  133.     nfstime    atime;        /* time of last access */
  134.     nfstime    mtime;        /* time of last modification */
  135.     nfstime    ctime;        /* time of last change */
  136. };
  137.  
  138. /*
  139.  * File attributes which can be set
  140.  */
  141. struct sattr {
  142.     unsigned mode;    /* protection mode bits */
  143.     unsigned uid;    /* owner user id */
  144.     unsigned gid;    /* owner group id */
  145.     unsigned size;    /* file size in bytes */
  146.     nfstime    atime;    /* time of last access */
  147.     nfstime    mtime;    /* time of last modification */
  148. };
  149.  
  150.  
  151. typedef string filename<NFS_MAXNAMLEN>; 
  152. typedef string nfspath<NFS_MAXPATHLEN>;
  153.  
  154. /*
  155.  * Reply status with file attributes
  156.  */
  157. union attrstat switch (nfsstat status) {
  158. case NFS_OK:
  159.     fattr attributes;
  160. default:
  161.     void;
  162. };
  163.  
  164. struct sattrargs {
  165.     nfs_fh file;
  166.     sattr attributes;
  167. };
  168.  
  169. /*
  170.  * Arguments for directory operations
  171.  */
  172. struct diropargs {
  173.     nfs_fh    dir;    /* directory file handle */
  174.     filename name;        /* name (up to NFS_MAXNAMLEN bytes) */
  175. };
  176.  
  177. struct diropokres {
  178.     nfs_fh file;
  179.     fattr attributes;
  180. };
  181.  
  182. /*
  183.  * Results from directory operation
  184.  */
  185. union diropres switch (nfsstat status) {
  186. case NFS_OK:
  187.     diropokres diropres;
  188. default:
  189.     void;
  190. };
  191.  
  192. union readlinkres switch (nfsstat status) {
  193. case NFS_OK:
  194.     nfspath data;
  195. default:
  196.     void;
  197. };
  198.  
  199. /*
  200.  * Arguments to remote read
  201.  */
  202. struct readargs {
  203.     nfs_fh file;        /* handle for file */
  204.     unsigned offset;    /* byte offset in file */
  205.     unsigned count;        /* immediate read count */
  206.     unsigned totalcount;    /* total read count (from this offset)*/
  207. };
  208.  
  209. /*
  210.  * Status OK portion of remote read reply
  211.  */
  212. struct readokres {
  213.     fattr    attributes;    /* attributes, need for pagin*/
  214.     opaque data<NFS_MAXDATA>;
  215. };
  216.  
  217. union readres switch (nfsstat status) {
  218. case NFS_OK:
  219.     readokres reply;
  220. default:
  221.     void;
  222. };
  223.  
  224. /*
  225.  * Arguments to remote write 
  226.  */
  227. struct writeargs {
  228.     nfs_fh    file;        /* handle for file */
  229.     unsigned beginoffset;    /* beginning byte offset in file */
  230.     unsigned offset;    /* current byte offset in file */
  231.     unsigned totalcount;    /* total write count (to this offset)*/
  232.     opaque data<NFS_MAXDATA>;
  233. };
  234.  
  235. struct createargs {
  236.     diropargs where;
  237.     sattr attributes;
  238. };
  239.  
  240. struct renameargs {
  241.     diropargs from;
  242.     diropargs to;
  243. };
  244.  
  245. struct linkargs {
  246.     nfs_fh from;
  247.     diropargs to;
  248. };
  249.  
  250. struct symlinkargs {
  251.     diropargs from;
  252.     nfspath to;
  253.     sattr attributes;
  254. };
  255.  
  256.  
  257. typedef opaque nfscookie[NFS_COOKIESIZE];
  258.  
  259. /*
  260.  * Arguments to readdir
  261.  */
  262. struct readdirargs {
  263.     nfs_fh dir;        /* directory handle */
  264.     nfscookie cookie;
  265.     unsigned count;        /* number of directory bytes to read */
  266. };
  267.  
  268. struct entry {
  269.     unsigned fileid;
  270.     filename name;
  271.     nfscookie cookie;
  272.     entry *nextentry;
  273. };
  274.  
  275. struct dirlist {
  276.     entry *entries;
  277.     bool eof;
  278. };
  279.  
  280. union readdirres switch (nfsstat status) {
  281. case NFS_OK:
  282.     dirlist reply;
  283. default:
  284.     void;
  285. };
  286.  
  287. struct statfsokres {
  288.     unsigned tsize;    /* preferred transfer size in bytes */
  289.     unsigned bsize;    /* fundamental file system block size */
  290.     unsigned blocks;    /* total blocks in file system */
  291.     unsigned bfree;    /* free blocks in fs */
  292.     unsigned bavail;    /* free blocks avail to non-superuser */
  293. };
  294.  
  295. union statfsres switch (nfsstat status) {
  296. case NFS_OK:
  297.     statfsokres reply;
  298. default:
  299.     void;
  300. };
  301.  
  302. /*
  303.  * Remote file service routines
  304.  */
  305. program NFS_PROGRAM {
  306.     version NFS_VERSION {
  307.         void 
  308.         NFSPROC_NULL(void) = 0;
  309.  
  310.         attrstat 
  311.         NFSPROC_GETATTR(nfs_fh) =    1;
  312.  
  313.         attrstat 
  314.         NFSPROC_SETATTR(sattrargs) = 2;
  315.  
  316.         void 
  317.         NFSPROC_ROOT(void) = 3;
  318.  
  319.         diropres 
  320.         NFSPROC_LOOKUP(diropargs) = 4;
  321.  
  322.         readlinkres 
  323.         NFSPROC_READLINK(nfs_fh) = 5;
  324.  
  325.         readres 
  326.         NFSPROC_READ(readargs) = 6;
  327.  
  328.         void 
  329.         NFSPROC_WRITECACHE(void) = 7;
  330.  
  331.         attrstat
  332.         NFSPROC_WRITE(writeargs) = 8;
  333.  
  334.         diropres
  335.         NFSPROC_CREATE(createargs) = 9;
  336.  
  337.         nfsstat
  338.         NFSPROC_REMOVE(diropargs) = 10;
  339.  
  340.         nfsstat
  341.         NFSPROC_RENAME(renameargs) = 11;
  342.  
  343.         nfsstat
  344.         NFSPROC_LINK(linkargs) = 12;
  345.  
  346.         nfsstat
  347.         NFSPROC_SYMLINK(symlinkargs) = 13;
  348.  
  349.         diropres
  350.         NFSPROC_MKDIR(createargs) = 14;
  351.  
  352.         nfsstat
  353.         NFSPROC_RMDIR(diropargs) = 15;
  354.  
  355.         readdirres
  356.         NFSPROC_READDIR(readdirargs) = 16;
  357.  
  358.         statfsres
  359.         NFSPROC_STATFS(nfs_fh) = 17;
  360.     } = 2;
  361. } = 100003;
  362.  
  363. #ifdef RPC_HDR
  364. %#endif /*!_rpcsvc_nfs_prot_h*/
  365. #endif
  366.