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