Warning, /network/kio-extras/nfs/rpc_nfs2_prot.x is written in an unsupported language. File is not indexed.

0001 %/*
0002 % * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
0003 % * unrestricted use provided that this legend is included on all tape
0004 % * media and as a part of the software program in whole or part.  Users
0005 % * may copy or modify Sun RPC without charge, but are not authorized
0006 % * to license or distribute it to anyone else except as part of a product or
0007 % * program developed by the user or with the express written consent of
0008 % * Sun Microsystems, Inc.
0009 % *
0010 % * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
0011 % * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
0012 % * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
0013 % *
0014 % * Sun RPC is provided with no support and without any obligation on the
0015 % * part of Sun Microsystems, Inc. to assist in its use, correction,
0016 % * modification or enhancement.
0017 % *
0018 % * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
0019 % * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
0020 % * OR ANY PART THEREOF.
0021 % *
0022 % * In no event will Sun Microsystems, Inc. be liable for any lost revenue
0023 % * or profits or other special, indirect and consequential damages, even if
0024 % * Sun has been advised of the possibility of such damages.
0025 % *
0026 % * Sun Microsystems, Inc.
0027 % * 2550 Garcia Avenue
0028 % * Mountain View, California  94043
0029 % */
0030 
0031 %/*
0032 % * Copyright (c) 1987, 1990 by Sun Microsystems, Inc.
0033 % */
0034 %
0035 %/* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */
0036 
0037 #ifdef RPC_HDR
0038 %#ifndef _rpcsvc_nfs_prot_h
0039 %#define _rpcsvc_nfs_prot_h
0040 #endif
0041 
0042 const NFS_PORT          = 2049;
0043 const NFS_MAXDATA       = 8192;
0044 const NFS_MAXPATHLEN    = 1024;
0045 const NFS_MAXNAMLEN     = 255;
0046 const NFS_FHSIZE        = 32;
0047 const NFS_COOKIESIZE    = 4;
0048 const NFS_FIFO_DEV      = -1;   /* size kludge for named pipes */
0049 
0050 /*
0051  * File types
0052  */
0053 const NFSMODE_FMT  = 0170000;   /* type of file */
0054 const NFSMODE_DIR  = 0040000;   /* directory */
0055 const NFSMODE_CHR  = 0020000;   /* character special */
0056 const NFSMODE_BLK  = 0060000;   /* block special */
0057 const NFSMODE_REG  = 0100000;   /* regular */
0058 const NFSMODE_LNK  = 0120000;   /* symbolic link */
0059 const NFSMODE_SOCK = 0140000;   /* socket */
0060 const NFSMODE_FIFO = 0010000;   /* fifo */
0061 
0062 /*
0063  * Error status
0064  */
0065 enum nfsstat {
0066         NFS_OK= 0,              /* no error */
0067         NFSERR_PERM=1,          /* Not owner */
0068         NFSERR_NOENT=2,         /* No such file or directory */
0069         NFSERR_IO=5,            /* I/O error */
0070         NFSERR_NXIO=6,          /* No such device or address */
0071         NFSERR_ACCES=13,        /* Permission denied */
0072         NFSERR_EXIST=17,        /* File exists */
0073         NFSERR_NODEV=19,        /* No such device */
0074         NFSERR_NOTDIR=20,       /* Not a directory*/
0075         NFSERR_ISDIR=21,        /* Is a directory */
0076         NFSERR_INVAL=22,        /* invalid argument */
0077         NFSERR_FBIG=27,         /* File too large */
0078         NFSERR_NOSPC=28,        /* No space left on device */
0079         NFSERR_ROFS=30,         /* Read-only file system */
0080         NFSERR_NAMETOOLONG=63,  /* File name too long */
0081         NFSERR_NOTEMPTY=66,     /* Directory not empty */
0082         NFSERR_DQUOT=69,        /* Disc quota exceeded */
0083         NFSERR_STALE=70,        /* Stale NFS file handle */
0084         NFSERR_WFLUSH=99        /* write cache flushed */
0085 };
0086 
0087 /*
0088  * File types
0089  */
0090 enum ftype {
0091         NFNON = 0,      /* non-file */
0092         NFREG = 1,      /* regular file */
0093         NFDIR = 2,      /* directory */
0094         NFBLK = 3,      /* block special */
0095         NFCHR = 4,      /* character special */
0096         NFLNK = 5,      /* symbolic link */
0097         NFSOCK = 6,     /* unix domain sockets */
0098         NFBAD = 7,      /* unused */
0099         NFFIFO = 8      /* named pipe */
0100 };
0101 
0102 /*
0103  * File access handle
0104  */
0105 struct nfs_fh {
0106         opaque data[NFS_FHSIZE];
0107 };
0108 
0109 /*
0110  * Timeval
0111  */
0112 struct nfstime {
0113         unsigned seconds;
0114         unsigned useconds;
0115 };
0116 
0117 
0118 /*
0119  * File attributes
0120  */
0121 struct fattr {
0122         ftype type;             /* file type */
0123         unsigned mode;          /* protection mode bits */
0124         unsigned nlink;         /* # hard links */
0125         unsigned uid;           /* owner user id */
0126         unsigned gid;           /* owner group id */
0127         unsigned size;          /* file size in bytes */
0128         unsigned blocksize;     /* prefered block size */
0129         unsigned rdev;          /* special device # */
0130         unsigned blocks;        /* Kb of disk used by file */
0131         unsigned fsid;          /* device # */
0132         unsigned fileid;        /* inode # */
0133         nfstime atime;          /* time of last access */
0134         nfstime mtime;          /* time of last modification */
0135         nfstime ctime;          /* time of last change */
0136 };
0137 
0138 /*
0139  * File attributes which can be set
0140  */
0141 struct sattr {
0142         unsigned mode;  /* protection mode bits */
0143         unsigned uid;   /* owner user id */
0144         unsigned gid;   /* owner group id */
0145         unsigned size;  /* file size in bytes */
0146         nfstime atime;  /* time of last access */
0147         nfstime mtime;  /* time of last modification */
0148 };
0149 
0150 
0151 typedef string filename<NFS_MAXNAMLEN>;
0152 typedef string nfspath<NFS_MAXPATHLEN>;
0153 
0154 /*
0155  * Reply status with file attributes
0156  */
0157 union attrstat switch (nfsstat status) {
0158 case NFS_OK:
0159         fattr attributes;
0160 default:
0161         void;
0162 };
0163 
0164 struct sattrargs {
0165         nfs_fh file;
0166         sattr attributes;
0167 };
0168 
0169 /*
0170  * Arguments for directory operations
0171  */
0172 struct diropargs {
0173         nfs_fh  dir;    /* directory file handle */
0174         filename name;          /* name (up to NFS_MAXNAMLEN bytes) */
0175 };
0176 
0177 struct diropokres {
0178         nfs_fh file;
0179         fattr attributes;
0180 };
0181 
0182 /*
0183  * Results from directory operation
0184  */
0185 union diropres switch (nfsstat status) {
0186 case NFS_OK:
0187         diropokres diropres;
0188 default:
0189         void;
0190 };
0191 
0192 union readlinkres switch (nfsstat status) {
0193 case NFS_OK:
0194         nfspath data;
0195 default:
0196         void;
0197 };
0198 
0199 /*
0200  * Arguments to remote read
0201  */
0202 struct readargs {
0203         nfs_fh file;            /* handle for file */
0204         unsigned offset;        /* byte offset in file */
0205         unsigned count;         /* immediate read count */
0206         unsigned totalcount;    /* total read count (from this offset)*/
0207 };
0208 
0209 /*
0210  * Status OK portion of remote read reply
0211  */
0212 struct readokres {
0213         fattr   attributes;     /* attributes, need for pagin*/
0214         opaque data<NFS_MAXDATA>;
0215 };
0216 
0217 union readres switch (nfsstat status) {
0218 case NFS_OK:
0219         readokres reply;
0220 default:
0221         void;
0222 };
0223 
0224 /*
0225  * Arguments to remote write
0226  */
0227 struct writeargs {
0228         nfs_fh  file;           /* handle for file */
0229         unsigned beginoffset;   /* beginning byte offset in file */
0230         unsigned offset;        /* current byte offset in file */
0231         unsigned totalcount;    /* total write count (to this offset)*/
0232         opaque data<NFS_MAXDATA>;
0233 };
0234 
0235 struct createargs {
0236         diropargs where;
0237         sattr attributes;
0238 };
0239 
0240 struct renameargs {
0241         diropargs from;
0242         diropargs to;
0243 };
0244 
0245 struct linkargs {
0246         nfs_fh from;
0247         diropargs to;
0248 };
0249 
0250 struct symlinkargs {
0251         diropargs from;
0252         nfspath to;
0253         sattr attributes;
0254 };
0255 
0256 
0257 typedef opaque nfscookie[NFS_COOKIESIZE];
0258 
0259 /*
0260  * Arguments to readdir
0261  */
0262 struct readdirargs {
0263         nfs_fh dir;             /* directory handle */
0264         nfscookie cookie;
0265         unsigned count;         /* number of directory bytes to read */
0266 };
0267 
0268 struct entry {
0269         unsigned fileid;
0270         filename name;
0271         nfscookie cookie;
0272         entry *nextentry;
0273 };
0274 
0275 struct dirlist {
0276         entry *entries;
0277         bool eof;
0278 };
0279 
0280 union readdirres switch (nfsstat status) {
0281 case NFS_OK:
0282         dirlist reply;
0283 default:
0284         void;
0285 };
0286 
0287 struct statfsokres {
0288         unsigned tsize; /* preferred transfer size in bytes */
0289         unsigned bsize; /* fundamental file system block size */
0290         unsigned blocks;        /* total blocks in file system */
0291         unsigned bfree; /* free blocks in fs */
0292         unsigned bavail;        /* free blocks avail to non-superuser */
0293 };
0294 
0295 union statfsres switch (nfsstat status) {
0296 case NFS_OK:
0297         statfsokres reply;
0298 default:
0299         void;
0300 };
0301 
0302 /*
0303  * Remote file service routines
0304  */
0305 program NFS_PROGRAM {
0306         version NFS_VERSION {
0307                 void
0308                 NFSPROC_NULL(void) = 0;
0309 
0310                 attrstat
0311                 NFSPROC_GETATTR(nfs_fh) =       1;
0312 
0313                 attrstat
0314                 NFSPROC_SETATTR(sattrargs) = 2;
0315 
0316                 void
0317                 NFSPROC_ROOT(void) = 3;
0318 
0319                 diropres
0320                 NFSPROC_LOOKUP(diropargs) = 4;
0321 
0322                 readlinkres
0323                 NFSPROC_READLINK(nfs_fh) = 5;
0324 
0325                 readres
0326                 NFSPROC_READ(readargs) = 6;
0327 
0328                 void
0329                 NFSPROC_WRITECACHE(void) = 7;
0330 
0331                 attrstat
0332                 NFSPROC_WRITE(writeargs) = 8;
0333 
0334                 diropres
0335                 NFSPROC_CREATE(createargs) = 9;
0336 
0337                 nfsstat
0338                 NFSPROC_REMOVE(diropargs) = 10;
0339 
0340                 nfsstat
0341                 NFSPROC_RENAME(renameargs) = 11;
0342 
0343                 nfsstat
0344                 NFSPROC_LINK(linkargs) = 12;
0345 
0346                 nfsstat
0347                 NFSPROC_SYMLINK(symlinkargs) = 13;
0348 
0349                 diropres
0350                 NFSPROC_MKDIR(createargs) = 14;
0351 
0352                 nfsstat
0353                 NFSPROC_RMDIR(diropargs) = 15;
0354 
0355                 readdirres
0356                 NFSPROC_READDIR(readdirargs) = 16;
0357 
0358                 statfsres
0359                 NFSPROC_STATFS(nfs_fh) = 17;
0360         } = 2;
0361 } = 100003;
0362 
0363 /* Mount v2 */
0364 
0365 const MNTPATHLEN = 1024;        /* maximum bytes in a pathname argument */
0366 const MNTNAMLEN = 255;          /* maximum bytes in a name argument */
0367 const FHSIZE = 32;              /* size in bytes of a file handle */
0368 
0369 /*
0370  * The fhandle is the file handle that the server passes to the client.
0371  * All file operations are done using the file handles to refer to a file
0372  * or a directory. The file handle can contain whatever information the
0373  * server needs to distinguish an individual file.
0374  */
0375 typedef opaque fhandle[FHSIZE];
0376 
0377 /*
0378  * If a status of zero is returned, the call completed successfully, and
0379  * a file handle for the directory follows. A non-zero status indicates
0380  * some sort of error. The status corresponds with UNIX error numbers.
0381  */
0382 union fhstatus switch (unsigned fhs_status) {
0383 case 0:
0384         fhandle fhs_fhandle;
0385 default:
0386         void;
0387 };
0388 
0389 /*
0390  * The type dirpath is the pathname of a directory
0391  */
0392 typedef string dirpath<MNTPATHLEN>;
0393 
0394 /*
0395  * The type name is used for arbitrary names (hostnames, groupnames)
0396  */
0397 typedef string name<MNTNAMLEN>;
0398 
0399 /*
0400  * A list of who has what mounted
0401  */
0402 typedef struct mountbody *mountlist;
0403 struct mountbody {
0404         name ml_hostname;
0405         dirpath ml_directory;
0406         mountlist ml_next;
0407 };
0408 
0409 /*
0410  * A list of netgroups
0411  */
0412 typedef struct groupnode *groups;
0413 struct groupnode {
0414         name gr_name;
0415         groups gr_next;
0416 };
0417 
0418 /*
0419  * A list of what is exported and to whom
0420  */
0421 typedef struct exportnode *exports;
0422 struct exportnode {
0423         dirpath ex_dir;
0424         groups ex_groups;
0425         exports ex_next;
0426 };
0427 
0428 /*
0429  * POSIX pathconf information
0430  */
0431 struct ppathcnf {
0432         int     pc_link_max;    /* max links allowed */
0433         short   pc_max_canon;   /* max line len for a tty */
0434         short   pc_max_input;   /* input a tty can eat all at once */
0435         short   pc_name_max;    /* max file name length (dir entry) */
0436         short   pc_path_max;    /* max path name length (/x/y/x/.. ) */
0437         short   pc_pipe_buf;    /* size of a pipe (bytes) */
0438         u_char  pc_vdisable;    /* safe char to turn off c_cc[i] */
0439         char    pc_xxx;         /* alignment padding; cc_t == char */
0440         short   pc_mask[2];     /* validity and boolean bits */
0441 };
0442 
0443 program MOUNTPROG {
0444         /*
0445          * Version one of the mount protocol communicates with version two
0446          * of the NFS protocol. The only connecting point is the fhandle
0447          * structure, which is the same for both protocols.
0448          */
0449         version MOUNTVERS {
0450                 /*
0451                  * Does no work. It is made available in all RPC services
0452                  * to allow server reponse testing and timing
0453                  */
0454                 void
0455                 MOUNTPROC_NULL(void) = 0;
0456 
0457                 /*
0458                  * If fhs_status is 0, then fhs_fhandle contains the
0459                  * file handle for the directory. This file handle may
0460                  * be used in the NFS protocol. This procedure also adds
0461                  * a new entry to the mount list for this client mounting
0462                  * the directory.
0463                  * Unix authentication required.
0464                  */
0465                 fhstatus
0466                 MOUNTPROC_MNT(dirpath) = 1;
0467 
0468                 /*
0469                  * Returns the list of remotely mounted filesystems. The
0470                  * mountlist contains one entry for each hostname and
0471                  * directory pair.
0472                  */
0473                 mountlist
0474                 MOUNTPROC_DUMP(void) = 2;
0475 
0476                 /*
0477                  * Removes the mount list entry for the directory
0478                  * Unix authentication required.
0479                  */
0480                 void
0481                 MOUNTPROC_UMNT(dirpath) = 3;
0482 
0483                 /*
0484                  * Removes all of the mount list entries for this client
0485                  * Unix authentication required.
0486                  */
0487                 void
0488                 MOUNTPROC_UMNTALL(void) = 4;
0489 
0490                 /*
0491                  * Returns a list of all the exported filesystems, and which
0492                  * machines are allowed to import it.
0493                  */
0494                 exports
0495                 MOUNTPROC_EXPORT(void)  = 5;
0496 
0497                 /*
0498                  * Identical to MOUNTPROC_EXPORT above
0499                  */
0500                 exports
0501                 MOUNTPROC_EXPORTALL(void) = 6;
0502         } = 1;
0503 
0504         /*
0505          * Version two of the mount protocol communicates with version two
0506          * of the NFS protocol.
0507          * The only difference from version one is the addition of a POSIX
0508          * pathconf call.
0509          */
0510         version MOUNTVERS_POSIX {
0511                 /*
0512                  * Does no work. It is made available in all RPC services
0513                  * to allow server reponse testing and timing
0514                  */
0515                 void
0516                 MOUNTPROC_NULL(void) = 0;
0517 
0518                 /*
0519                  * If fhs_status is 0, then fhs_fhandle contains the
0520                  * file handle for the directory. This file handle may
0521                  * be used in the NFS protocol. This procedure also adds
0522                  * a new entry to the mount list for this client mounting
0523                  * the directory.
0524                  * Unix authentication required.
0525                  */
0526                 fhstatus
0527                 MOUNTPROC_MNT(dirpath) = 1;
0528 
0529                 /*
0530                  * Returns the list of remotely mounted filesystems. The
0531                  * mountlist contains one entry for each hostname and
0532                  * directory pair.
0533                  */
0534                 mountlist
0535                 MOUNTPROC_DUMP(void) = 2;
0536 
0537                 /*
0538                  * Removes the mount list entry for the directory
0539                  * Unix authentication required.
0540                  */
0541                 void
0542                 MOUNTPROC_UMNT(dirpath) = 3;
0543 
0544                 /*
0545                  * Removes all of the mount list entries for this client
0546                  * Unix authentication required.
0547                  */
0548                 void
0549                 MOUNTPROC_UMNTALL(void) = 4;
0550 
0551                 /*
0552                  * Returns a list of all the exported filesystems, and which
0553                  * machines are allowed to import it.
0554                  */
0555                 exports
0556                 MOUNTPROC_EXPORT(void)  = 5;
0557 
0558                 /*
0559                  * Identical to MOUNTPROC_EXPORT above
0560                  */
0561                 exports
0562                 MOUNTPROC_EXPORTALL(void) = 6;
0563 
0564                 /*
0565                  * POSIX pathconf info (Sun hack)
0566                  */
0567                 ppathcnf
0568                 MOUNTPROC_PATHCONF(dirpath) = 7;
0569         } = 2;
0570 } = 100005;
0571 
0572 #ifdef RPC_HDR
0573 %#endif /*!_rpcsvc_nfs_prot_h*/
0574 #endif