Home | History | Annotate | Line # | Download | only in nfs_prot
nfs_prot_irix6.h revision 1.1
      1 /*	$NetBSD: nfs_prot_irix6.h,v 1.1 2008/09/19 20:07:18 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1997-2007 Erez Zadok
      5  * Copyright (c) 1990 Jan-Simon Pendry
      6  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
      7  * Copyright (c) 1990 The Regents of the University of California.
      8  * All rights reserved.
      9  *
     10  * This code is derived from software contributed to Berkeley by
     11  * Jan-Simon Pendry at Imperial College, London.
     12  *
     13  * Redistribution and use in source and binary forms, with or without
     14  * modification, are permitted provided that the following conditions
     15  * are met:
     16  * 1. Redistributions of source code must retain the above copyright
     17  *    notice, this list of conditions and the following disclaimer.
     18  * 2. Redistributions in binary form must reproduce the above copyright
     19  *    notice, this list of conditions and the following disclaimer in the
     20  *    documentation and/or other materials provided with the distribution.
     21  * 3. All advertising materials mentioning features or use of this software
     22  *    must display the following acknowledgment:
     23  *      This product includes software developed by the University of
     24  *      California, Berkeley and its contributors.
     25  * 4. Neither the name of the University nor the names of its contributors
     26  *    may be used to endorse or promote products derived from this software
     27  *    without specific prior written permission.
     28  *
     29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     39  * SUCH DAMAGE.
     40  *
     41  *
     42  * File: am-utils/conf/nfs_prot/nfs_prot_irix6.h
     43  *
     44  */
     45 
     46 #ifndef _AMU_NFS_PROT_H
     47 #define _AMU_NFS_PROT_H
     48 
     49 #ifdef HAVE_NFS_NFSV2_H
     50 # include <nfs/nfsv2.h>
     51 #endif /* HAVE_NFS_NFSV2_H */
     52 #ifdef HAVE_RPC_RPC_H
     53 # include <rpc/rpc.h>
     54 #endif /* HAVE_RPC_RPC_H */
     55 #ifdef HAVE_NFS_RPCV2_H
     56 # include <nfs/rpcv2.h>
     57 #endif /* HAVE_NFS_RPCV2_H */
     58 #ifdef HAVE_NFS_NFS_H
     59 # include <nfs/nfs.h>
     60 #endif /* HAVE_NFS_NFS_H */
     61 #ifdef HAVE_SYS_FS_NFS_H
     62 # include <sys/fs/nfs.h>
     63 #endif /* HAVE_SYS_FS_NFS_H */
     64 
     65 #ifdef HAVE_RPCSVC_MOUNT_H_off
     66 # include <rpcsvc/mount.h>
     67 #endif /* HAVE_RPCSVC_MOUNT_H */
     68 
     69 /* evil: don't include */
     70 #undef HAVE_RPCSVC_MOUNT_H
     71 
     72 /*
     73  * MACROS
     74  */
     75 
     76 #define NFS_PORT 2049
     77 #define NFS_MAXDATA 8192
     78 #define NFS_MAXPATHLEN 1024
     79 #define NFS_MAXNAMLEN 255
     80 #define NFS_FHSIZE 32
     81 #define NFS_COOKIESIZE 4
     82 #define	MNTPATHLEN 1024
     83 #define	MNTNAMLEN 255
     84 #define FHSIZE 32
     85 
     86 #define MOUNTPROG 100005
     87 #define MOUNTPROC_MNT 1
     88 #define MOUNTPROC_DUMP 2
     89 #define MOUNTPROC_UMNT 3
     90 #define MOUNTPROC_UMNTALL 4
     91 #define MOUNTPROC_EXPORT 5
     92 #define MOUNTPROC_EXPORTALL 6
     93 #define MOUNTVERS_ORIG 1
     94 #define MOUNTVERS 1
     95 #define MOUNTVERS3      3
     96 
     97 #define NFSMODE_FMT 0170000
     98 #define NFSMODE_DIR 0040000
     99 #define NFSMODE_CHR 0020000
    100 #define NFSMODE_BLK 0060000
    101 #define NFSMODE_REG 0100000
    102 #define NFSMODE_LNK 0120000
    103 #define NFSMODE_SOCK 0140000
    104 #define NFSMODE_FIFO 0010000
    105 
    106 #ifndef NFS_PROGRAM
    107 # define NFS_PROGRAM ((u_long)100003)
    108 #endif /* not NFS_PROGRAM */
    109 #ifndef NFS_VERSION
    110 # define NFS_VERSION ((u_long)2)
    111 #endif /* not NFS_VERSION */
    112 
    113 #define NFSPROC_NULL ((u_long)0)
    114 #define NFSPROC_GETATTR ((u_long)1)
    115 #define NFSPROC_SETATTR ((u_long)2)
    116 #define NFSPROC_ROOT ((u_long)3)
    117 #define NFSPROC_LOOKUP ((u_long)4)
    118 #define NFSPROC_READLINK ((u_long)5)
    119 #define NFSPROC_READ ((u_long)6)
    120 #define NFSPROC_WRITECACHE ((u_long)7)
    121 #define NFSPROC_WRITE ((u_long)8)
    122 #define NFSPROC_CREATE ((u_long)9)
    123 #define NFSPROC_REMOVE ((u_long)10)
    124 #define NFSPROC_RENAME ((u_long)11)
    125 #define NFSPROC_LINK ((u_long)12)
    126 #define NFSPROC_SYMLINK ((u_long)13)
    127 #define NFSPROC_MKDIR ((u_long)14)
    128 #define NFSPROC_RMDIR ((u_long)15)
    129 #define NFSPROC_READDIR ((u_long)16)
    130 #define NFSPROC_STATFS ((u_long)17)
    131 
    132 /* map field names */
    133 #define ml_hostname ml_name
    134 #define ml_directory ml_path
    135 #define ml_next ml_nxt
    136 #define gr_next g_next
    137 #define gr_name g_name
    138 #define ex_dir ex_name
    139 
    140 /*
    141  * Irix 6.2 does not define the proto/dev options, although they
    142  * do support them for NFS V3.
    143  */
    144 #ifdef MNTTYPE_NFS3
    145 # ifndef MNTOPT_PROTO
    146 #  define MNTOPT_PROTO "proto"
    147 # endif /* not MNTOPT_PROTO */
    148 # ifndef MNTOPT_VERS
    149 #  define MNTOPT_VERS "vers"
    150 # endif /* not MNTOPT_VERS */
    151 #endif /* MNTTYPE_NFS3 */
    152 
    153 #define AUTOFS_CONFTYPE "udp"
    154 
    155 /*
    156  * TYPEDEFS:
    157  */
    158 typedef char *dirpath;
    159 typedef char *filename;
    160 typedef char *name;
    161 typedef char *nfspath;
    162 typedef char nfscookie[NFS_COOKIESIZE];
    163 typedef enum nfsftype nfsftype;
    164 typedef enum nfsstat nfsstat;
    165 typedef struct attrstat nfsattrstat;
    166 typedef struct createargs nfscreateargs;
    167 typedef struct dirlist nfsdirlist;
    168 typedef struct diropargs nfsdiropargs;
    169 typedef struct diropokres nfsdiropokres;
    170 typedef struct diropres nfsdiropres;
    171 typedef struct entry nfsentry;
    172 typedef struct exports *exports;
    173 typedef struct exports exportnode;
    174 typedef struct fattr nfsfattr;
    175 typedef struct fhstatus fhstatus;
    176 typedef struct groups *groups;
    177 typedef struct groups groupnode;
    178 typedef struct linkargs nfslinkargs;
    179 typedef struct mountlist *mountlist;
    180 typedef struct mountlist mountbody;
    181 typedef struct nfs_fh nfs_fh;
    182 typedef struct nfstime nfstime;
    183 typedef struct readargs nfsreadargs;
    184 typedef struct readdirargs nfsreaddirargs;
    185 typedef struct readdirres nfsreaddirres;
    186 typedef struct readlinkres nfsreadlinkres;
    187 typedef struct readokres nfsreadokres;
    188 typedef struct readres nfsreadres;
    189 typedef struct renameargs nfsrenameargs;
    190 typedef struct sattr nfssattr;
    191 typedef struct sattrargs nfssattrargs;
    192 typedef struct statfsokres nfsstatfsokres;
    193 typedef struct statfsres nfsstatfsres;
    194 typedef struct symlinkargs nfssymlinkargs;
    195 typedef struct writeargs nfswriteargs;
    196 
    197 
    198 /*
    199  * EXTERNALS:
    200  */
    201 
    202 extern void *nfsproc_null_2_svc(void *, struct svc_req *);
    203 extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
    204 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
    205 extern void *nfsproc_root_2_svc(void *, struct svc_req *);
    206 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
    207 extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
    208 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
    209 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
    210 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
    211 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
    212 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
    213 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
    214 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
    215 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
    216 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
    217 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
    218 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
    219 extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
    220 
    221 extern bool_t xdr_nfsstat(XDR *, nfsstat*);
    222 extern bool_t xdr_ftype(XDR *, nfsftype*);
    223 extern bool_t xdr_nfs_fh(XDR *, nfs_fh*);
    224 extern bool_t xdr_nfstime(XDR *, nfstime*);
    225 extern bool_t xdr_fattr(XDR *, nfsfattr*);
    226 extern bool_t xdr_sattr(XDR *, nfssattr*);
    227 extern bool_t xdr_filename(XDR *, filename*);
    228 extern bool_t xdr_nfspath(XDR *, nfspath*);
    229 extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
    230 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
    231 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
    232 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
    233 extern bool_t xdr_diropres(XDR *, nfsdiropres*);
    234 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
    235 extern bool_t xdr_readargs(XDR *, nfsreadargs*);
    236 extern bool_t xdr_readokres(XDR *, nfsreadokres*);
    237 extern bool_t xdr_readres(XDR *, nfsreadres*);
    238 extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
    239 extern bool_t xdr_createargs(XDR *, nfscreateargs*);
    240 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
    241 extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
    242 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
    243 extern bool_t xdr_nfscookie(XDR *, nfscookie);
    244 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
    245 extern bool_t xdr_entry(XDR *, nfsentry*);
    246 extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
    247 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
    248 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
    249 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
    250 
    251 
    252 /*
    253  * STRUCTURES:
    254  */
    255 
    256 struct nfs_fh {
    257   char fh_data[NFS_FHSIZE];
    258 };
    259 
    260 struct nfstime {
    261   u_int nt_seconds;
    262   u_int nt_useconds;
    263 };
    264 
    265 struct fattr {
    266   nfsftype na_type;
    267   u_int na_mode;
    268   u_int na_nlink;
    269   u_int na_uid;
    270   u_int na_gid;
    271   u_int na_size;
    272   u_int na_blocksize;
    273   u_int na_rdev;
    274   u_int na_blocks;
    275   u_int na_fsid;
    276   u_int na_fileid;
    277   nfstime na_atime;
    278   nfstime na_mtime;
    279   nfstime na_ctime;
    280 };
    281 
    282 struct sattr {
    283   u_int sa_mode;
    284   u_int sa_uid;
    285   u_int sa_gid;
    286   u_int sa_size;
    287   nfstime sa_atime;
    288   nfstime sa_mtime;
    289 };
    290 
    291 struct attrstat {
    292   nfsstat ns_status;
    293   union {
    294     nfsfattr ns_attr_u;
    295   } ns_u;
    296 };
    297 
    298 struct sattrargs {
    299   nfs_fh sag_fhandle;
    300   nfssattr sag_attributes;
    301 };
    302 
    303 struct diropargs {
    304   nfs_fh da_fhandle;		/* was dir */
    305   filename da_name;
    306 };
    307 
    308 struct diropokres {
    309   nfs_fh drok_fhandle;
    310   nfsfattr drok_attributes;
    311 };
    312 
    313 struct diropres {
    314   nfsstat dr_status;		/* was status */
    315   union {
    316     nfsdiropokres dr_drok_u;	/* was diropres */
    317   } dr_u;			/* was diropres_u */
    318 };
    319 
    320 struct readlinkres {
    321   nfsstat rlr_status;
    322   union {
    323     nfspath rlr_data_u;
    324   } rlr_u;
    325 };
    326 
    327 struct readargs {
    328   nfs_fh ra_fhandle;
    329   u_int ra_offset;
    330   u_int ra_count;
    331   u_int ra_totalcount;
    332 };
    333 
    334 struct readokres {
    335   nfsfattr raok_attributes;
    336   struct {
    337     u_int raok_len_u;
    338     char *raok_val_u;
    339   } raok_u;
    340 };
    341 
    342 struct readres {
    343   nfsstat rr_status;
    344   union {
    345     nfsreadokres rr_reply_u;
    346   } rr_u;
    347 };
    348 
    349 struct writeargs {
    350   nfs_fh wra_fhandle;
    351   u_int wra_beginoffset;
    352   u_int wra_offset;
    353   u_int wra_totalcount;
    354   struct {
    355     u_int wra_len_u;
    356     char *wra_val_u;
    357   } wra_u;
    358 };
    359 
    360 struct createargs {
    361   nfsdiropargs ca_where;
    362   nfssattr ca_attributes;
    363 };
    364 
    365 struct renameargs {
    366   nfsdiropargs rna_from;
    367   nfsdiropargs rna_to;
    368 };
    369 
    370 struct linkargs {
    371   nfs_fh la_fhandle;
    372   nfsdiropargs la_to;
    373 };
    374 
    375 struct symlinkargs {
    376   nfsdiropargs sla_from;
    377   nfspath sla_to;
    378   nfssattr sla_attributes;
    379 };
    380 
    381 struct readdirargs {
    382   nfs_fh rda_fhandle;
    383   nfscookie rda_cookie;
    384   u_int rda_count;
    385 };
    386 
    387 struct entry {
    388   u_int ne_fileid;
    389   filename ne_name;
    390   nfscookie ne_cookie;
    391   nfsentry *ne_nextentry;
    392 };
    393 
    394 struct dirlist {
    395   nfsentry *dl_entries;
    396   bool_t dl_eof;
    397 };
    398 
    399 struct readdirres {
    400   nfsstat rdr_status;
    401   union {
    402     nfsdirlist rdr_reply_u;
    403   } rdr_u;
    404 };
    405 
    406 struct statfsokres {
    407   u_int sfrok_tsize;
    408   u_int sfrok_bsize;
    409   u_int sfrok_blocks;
    410   u_int sfrok_bfree;
    411   u_int sfrok_bavail;
    412 };
    413 
    414 struct statfsres {
    415   nfsstat sfr_status;
    416   union {
    417     nfsstatfsokres sfr_reply_u;
    418   } sfr_u;
    419 };
    420 
    421 
    422 /*
    423  * Partial definitions from rpcsvc/mount.h (can't use that header
    424  * because it includes other "bad" stuff wrt xdr_groups.
    425  */
    426 
    427 struct mountlist {
    428   char *ml_name;
    429   char *ml_path;
    430   struct mountlist *ml_nxt;
    431 };
    432 
    433 struct fhstatus {
    434   int fhs_status;
    435   fhandle_t fhs_fh;
    436 };
    437 
    438 typedef char fhandle[FHSIZE];
    439 
    440 typedef struct {
    441   u_int fhandle3_len;
    442   char *fhandle3_val;
    443 } fhandle3;
    444 
    445 enum mountstat3 {
    446   MNT_OK = 0,
    447   MNT3ERR_PERM = 1,
    448   MNT3ERR_NOENT = 2,
    449   MNT3ERR_IO = 5,
    450   MNT3ERR_ACCES = 13,
    451   MNT3ERR_NOTDIR = 20,
    452   MNT3ERR_INVAL = 22,
    453   MNT3ERR_NAMETOOLONG = 63,
    454   MNT3ERR_NOTSUPP = 10004,
    455   MNT3ERR_SERVERFAULT = 10006
    456 };
    457 typedef enum mountstat3 mountstat3;
    458 
    459 struct mountres3_ok {
    460   fhandle3 fhandle;
    461   struct {
    462     u_int auth_flavors_len;
    463     int *auth_flavors_val;
    464   } auth_flavors;
    465 };
    466 typedef struct mountres3_ok mountres3_ok;
    467 
    468 struct mountres3 {
    469   mountstat3 fhs_status;
    470   union {
    471     mountres3_ok mountinfo;
    472   } mountres3_u;
    473 };
    474 typedef struct mountres3 mountres3;
    475 
    476 /*
    477  * List of exported directories
    478  * An export entry with ex_groups
    479  * NULL indicates an entry which is exported to the world.
    480  */
    481 struct exports {
    482   dev_t ex_dev;			/* dev of directory */
    483   char *ex_name;		/* name of directory */
    484   struct groups *ex_groups;	/* groups allowed to mount this entry */
    485   struct exports *ex_next;
    486   short ex_rootmap;		/* id to map root requests to */
    487   short ex_flags;		/* bits to mask off file mode */
    488 };
    489 
    490 struct groups {
    491   char *g_name;
    492   struct groups	*g_next;
    493 };
    494 
    495 extern bool_t xdr_groups(XDR *, groups *);
    496 extern bool_t xdr_exports(XDR *, struct exports **);
    497 extern bool_t xdr_mountres3_ok(XDR *, mountres3_ok *);
    498 extern bool_t xdr_mountres3(XDR *, mountres3 *);
    499 extern bool_t xdr_fhstatus(XDR *, struct fhstatus *);
    500 extern bool_t xdr_mountlist(XDR *, struct mountlist **);
    501 
    502 #endif /* not _AMU_NFS_PROT_H */
    503