1 /* $NetBSD: nfs_prot_irix5.h,v 1.1.1.2 2009/03/20 20:26:51 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1997-2009 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_irix5.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_UIO_H 62 # define _KMEMUSER 63 # include <sys/uio.h> 64 # undef _KMEMUSER 65 #endif /* HAVE_SYS_UIO_H */ 66 #ifdef HAVE_SYS_VNODE_H 67 # include <sys/vnode.h> 68 #endif /* HAVE_SYS_VNODE_H */ 69 #ifdef HAVE_SYS_FS_NFS_H 70 # include <sys/fs/nfs.h> 71 #endif /* HAVE_SYS_FS_NFS_H */ 72 73 #ifdef HAVE_RPCSVC_MOUNT_H 74 # include <rpcsvc/mount.h> 75 #endif /* HAVE_RPCSVC_MOUNT_H */ 76 #ifdef HAVE_SYS_FSTYP_H 77 # include <sys/fstyp.h> 78 #endif /* HAVE_SYS_FSTYP_H */ 79 80 /* XFS isn't really supported in 5.3, but the header files are confusing */ 81 #undef MNTTYPE_XFS 82 #undef MNTTAB_TYPE_XFS 83 84 /****************************************************************************/ 85 /* 86 * NFS V3 SUPPORT: 87 * 88 * IRIX5.3 requires the fh_len field to be added to the struct nfs_args 89 * defined in <sys/fs/nfs_clnt.h> for NFS3 mounts (it doesn't hurt for 90 * NFS2 mounts). The mount syscall however always expects the argument 91 * structure size to be sizeof(struct nfs_args). 92 * So we need to use an extended struct nfs_args in amd/ops_nfs.c, 93 * while using the original struct nfs_arg in libamu/mountutil.c. 94 * -- stolcke 7/4/97 95 */ 96 97 /* 98 * NFS arguments to the mount system call. 99 */ 100 struct irix5_nfs_args { 101 struct sockaddr_in *addr; /* file server address */ 102 fhandle_t *fh; /* File handle to be mounted */ 103 int flags; /* flags */ 104 u_int wsize; /* write size in bytes */ 105 u_int rsize; /* read size in bytes */ 106 u_int timeo; /* initial timeout in .1 secs */ 107 u_int retrans; /* times to retry send */ 108 char *hostname; /* server's name */ 109 u_int acregmin; /* attr cache file min secs */ 110 u_int acregmax; /* attr cache file max secs */ 111 u_int acdirmin; /* attr cache dir min secs */ 112 u_int acdirmax; /* attr cache dir max secs */ 113 u_int symttl; /* symlink cache time-to-live */ 114 char base[FSTYPSZ]; /* base type for statvfs */ 115 u_int namemax; /* name length for statvfs */ 116 u_int fh_len; /* length for a v3 filehandle */ 117 }; 118 119 #ifndef MNTOPT_PROTO 120 # define MNTOPT_PROTO "proto" 121 #endif /* not MNTOPT_PROTO */ 122 #ifndef MNTOPT_VERS 123 # define MNTOPT_VERS "vers" 124 #endif /* not MNTOPT_VERS */ 125 126 /****************************************************************************/ 127 128 129 /* 130 * MACROS 131 */ 132 133 #define NFS_PORT 2049 134 #define NFS_MAXDATA 8192 135 #define NFS_MAXPATHLEN 1024 136 #define NFS_MAXNAMLEN 255 137 #define NFS_FHSIZE 32 138 #ifndef FHSIZE 139 /* Irix 5.2 is missing the definition for FHSIZE */ 140 # define FHSIZE NFS_FHSIZE 141 #endif /* not FHSIZE */ 142 #define NFS_COOKIESIZE 4 143 #define MNTPATHLEN 1024 144 #define MNTNAMLEN 255 145 146 #define NFSMODE_FMT 0170000 147 #define NFSMODE_DIR 0040000 148 #define NFSMODE_CHR 0020000 149 #define NFSMODE_BLK 0060000 150 #define NFSMODE_REG 0100000 151 #define NFSMODE_LNK 0120000 152 #define NFSMODE_SOCK 0140000 153 #define NFSMODE_FIFO 0010000 154 155 #ifndef NFS_PROGRAM 156 # define NFS_PROGRAM ((u_long)100003) 157 #endif /* not NFS_PROGRAM */ 158 #ifndef NFS_VERSION 159 # define NFS_VERSION ((u_long)2) 160 #endif /* not NFS_VERSION */ 161 162 #define NFSPROC_NULL ((u_long)0) 163 #define NFSPROC_GETATTR ((u_long)1) 164 #define NFSPROC_SETATTR ((u_long)2) 165 #define NFSPROC_ROOT ((u_long)3) 166 #define NFSPROC_LOOKUP ((u_long)4) 167 #define NFSPROC_READLINK ((u_long)5) 168 #define NFSPROC_READ ((u_long)6) 169 #define NFSPROC_WRITECACHE ((u_long)7) 170 #define NFSPROC_WRITE ((u_long)8) 171 #define NFSPROC_CREATE ((u_long)9) 172 #define NFSPROC_REMOVE ((u_long)10) 173 #define NFSPROC_RENAME ((u_long)11) 174 #define NFSPROC_LINK ((u_long)12) 175 #define NFSPROC_SYMLINK ((u_long)13) 176 #define NFSPROC_MKDIR ((u_long)14) 177 #define NFSPROC_RMDIR ((u_long)15) 178 #define NFSPROC_READDIR ((u_long)16) 179 #define NFSPROC_STATFS ((u_long)17) 180 181 /* map field names */ 182 #define ml_hostname ml_name 183 #define ml_directory ml_path 184 #define ml_next ml_nxt 185 #define gr_next g_next 186 #define gr_name g_name 187 #define ex_dir ex_name 188 189 190 /* 191 * TYPEDEFS: 192 */ 193 typedef char *dirpath; 194 typedef char *filename; 195 typedef char *name; 196 typedef char *nfspath; 197 typedef char nfscookie[NFS_COOKIESIZE]; 198 typedef enum nfsftype nfsftype; 199 typedef enum nfsstat nfsstat; 200 typedef struct attrstat nfsattrstat; 201 typedef struct createargs nfscreateargs; 202 typedef struct dirlist nfsdirlist; 203 typedef struct diropargs nfsdiropargs; 204 typedef struct diropokres nfsdiropokres; 205 typedef struct diropres nfsdiropres; 206 typedef struct entry nfsentry; 207 typedef struct exports *exports; 208 typedef struct exports exportnode; 209 typedef struct fattr nfsfattr; 210 typedef struct fhstatus fhstatus; 211 typedef struct groups *groups; 212 typedef struct groups groupnode; 213 typedef struct linkargs nfslinkargs; 214 typedef struct mountlist *mountlist; 215 typedef struct mountlist mountbody; 216 typedef struct nfs_fh nfs_fh; 217 typedef struct nfstime nfstime; 218 typedef struct readargs nfsreadargs; 219 typedef struct readdirargs nfsreaddirargs; 220 typedef struct readdirres nfsreaddirres; 221 typedef struct readlinkres nfsreadlinkres; 222 typedef struct readokres nfsreadokres; 223 typedef struct readres nfsreadres; 224 typedef struct renameargs nfsrenameargs; 225 typedef struct sattr nfssattr; 226 typedef struct sattrargs nfssattrargs; 227 typedef struct statfsokres nfsstatfsokres; 228 typedef struct statfsres nfsstatfsres; 229 typedef struct symlinkargs nfssymlinkargs; 230 typedef struct writeargs nfswriteargs; 231 232 233 /* 234 * EXTERNALS: 235 */ 236 237 extern void *nfsproc_null_2_svc(void *, struct svc_req *); 238 extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); 239 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); 240 extern void *nfsproc_root_2_svc(void *, struct svc_req *); 241 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); 242 extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); 243 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); 244 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); 245 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); 246 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); 247 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); 248 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); 249 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); 250 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); 251 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); 252 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); 253 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); 254 extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); 255 256 extern bool_t xdr_nfsstat(XDR *, nfsstat*); 257 extern bool_t xdr_ftype(XDR *, nfsftype*); 258 extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); 259 extern bool_t xdr_nfstime(XDR *, nfstime*); 260 extern bool_t xdr_fattr(XDR *, nfsfattr*); 261 extern bool_t xdr_sattr(XDR *, nfssattr*); 262 extern bool_t xdr_filename(XDR *, filename*); 263 extern bool_t xdr_nfspath(XDR *, nfspath*); 264 extern bool_t xdr_attrstat(XDR *, nfsattrstat*); 265 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); 266 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); 267 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); 268 extern bool_t xdr_diropres(XDR *, nfsdiropres*); 269 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); 270 extern bool_t xdr_readargs(XDR *, nfsreadargs*); 271 extern bool_t xdr_readokres(XDR *, nfsreadokres*); 272 extern bool_t xdr_readres(XDR *, nfsreadres*); 273 extern bool_t xdr_writeargs(XDR *, nfswriteargs*); 274 extern bool_t xdr_createargs(XDR *, nfscreateargs*); 275 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); 276 extern bool_t xdr_linkargs(XDR *, nfslinkargs*); 277 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); 278 extern bool_t xdr_nfscookie(XDR *, nfscookie); 279 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); 280 extern bool_t xdr_entry(XDR *, nfsentry*); 281 extern bool_t xdr_dirlist(XDR *, nfsdirlist*); 282 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); 283 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); 284 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); 285 286 287 /* 288 * STRUCTURES: 289 */ 290 291 struct nfs_fh { 292 char fh_data[NFS_FHSIZE]; 293 }; 294 295 struct nfstime { 296 u_int nt_seconds; 297 u_int nt_useconds; 298 }; 299 300 struct fattr { 301 nfsftype na_type; 302 u_int na_mode; 303 u_int na_nlink; 304 u_int na_uid; 305 u_int na_gid; 306 u_int na_size; 307 u_int na_blocksize; 308 u_int na_rdev; 309 u_int na_blocks; 310 u_int na_fsid; 311 u_int na_fileid; 312 nfstime na_atime; 313 nfstime na_mtime; 314 nfstime na_ctime; 315 }; 316 317 struct sattr { 318 u_int sa_mode; 319 u_int sa_uid; 320 u_int sa_gid; 321 u_int sa_size; 322 nfstime sa_atime; 323 nfstime sa_mtime; 324 }; 325 326 struct attrstat { 327 nfsstat ns_status; 328 union { 329 nfsfattr ns_attr_u; 330 } ns_u; 331 }; 332 333 struct sattrargs { 334 nfs_fh sag_fhandle; 335 nfssattr sag_attributes; 336 }; 337 338 struct diropargs { 339 nfs_fh da_fhandle; /* was dir */ 340 filename da_name; 341 }; 342 343 struct diropokres { 344 nfs_fh drok_fhandle; 345 nfsfattr drok_attributes; 346 }; 347 348 struct diropres { 349 nfsstat dr_status; /* was status */ 350 union { 351 nfsdiropokres dr_drok_u; /* was diropres */ 352 } dr_u; /* was diropres_u */ 353 }; 354 355 struct readlinkres { 356 nfsstat rlr_status; 357 union { 358 nfspath rlr_data_u; 359 } rlr_u; 360 }; 361 362 struct readargs { 363 nfs_fh ra_fhandle; 364 u_int ra_offset; 365 u_int ra_count; 366 u_int ra_totalcount; 367 }; 368 369 struct readokres { 370 nfsfattr raok_attributes; 371 struct { 372 u_int raok_len_u; 373 char *raok_val_u; 374 } raok_u; 375 }; 376 377 struct readres { 378 nfsstat rr_status; 379 union { 380 nfsreadokres rr_reply_u; 381 } rr_u; 382 }; 383 384 struct writeargs { 385 nfs_fh wra_fhandle; 386 u_int wra_beginoffset; 387 u_int wra_offset; 388 u_int wra_totalcount; 389 struct { 390 u_int wra_len_u; 391 char *wra_val_u; 392 } wra_u; 393 }; 394 395 struct createargs { 396 nfsdiropargs ca_where; 397 nfssattr ca_attributes; 398 }; 399 400 struct renameargs { 401 nfsdiropargs rna_from; 402 nfsdiropargs rna_to; 403 }; 404 405 struct linkargs { 406 nfs_fh la_fhandle; 407 nfsdiropargs la_to; 408 }; 409 410 struct symlinkargs { 411 nfsdiropargs sla_from; 412 nfspath sla_to; 413 nfssattr sla_attributes; 414 }; 415 416 struct readdirargs { 417 nfs_fh rda_fhandle; 418 nfscookie rda_cookie; 419 u_int rda_count; 420 }; 421 422 struct entry { 423 u_int ne_fileid; 424 filename ne_name; 425 nfscookie ne_cookie; 426 nfsentry *ne_nextentry; 427 }; 428 429 struct dirlist { 430 nfsentry *dl_entries; 431 bool_t dl_eof; 432 }; 433 434 struct readdirres { 435 nfsstat rdr_status; 436 union { 437 nfsdirlist rdr_reply_u; 438 } rdr_u; 439 }; 440 441 struct statfsokres { 442 u_int sfrok_tsize; 443 u_int sfrok_bsize; 444 u_int sfrok_blocks; 445 u_int sfrok_bfree; 446 u_int sfrok_bavail; 447 }; 448 449 struct statfsres { 450 nfsstat sfr_status; 451 union { 452 nfsstatfsokres sfr_reply_u; 453 } sfr_u; 454 }; 455 456 #endif /* not _AMU_NFS_PROT_H */ 457