1 /* $NetBSD: nfs_prot_bsdi2.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_bsdi2.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_NFS_RPCV2_H 49 # include <nfs/rpcv2.h> 50 #endif /* HAVE_NFS_RPCV2_H */ 51 #ifdef HAVE_NFS_NFS_H 52 # include <nfs/nfs.h> 53 #endif /* HAVE_NFS_NFS_H */ 54 #ifdef HAVE_SYS_FS_NFS_H 55 # include <sys/fs/nfs.h> 56 #endif /* HAVE_SYS_FS_NFS_H */ 57 #ifdef HAVE_RPCSVC_MOUNT_H 58 # include <rpcsvc/mount.h> 59 #endif /* HAVE_RPCSVC_MOUNT_H */ 60 61 #ifdef HAVE_UFS_UFS_UFSMOUNT_H 62 # ifndef MAXQUOTAS 63 # define MAXQUOTAS 2 64 # endif /* not MAXQUOTAS */ 65 /* fake structure: too difficult to include other headers here */ 66 struct netexport { int this_is_SO_wrong; }; 67 # include <ufs/ufs/ufsmount.h> 68 #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ 69 70 /* 71 * <msdosfs/msdosfsmount.h> is for kernel only on bsdi2, so do not 72 * include it. 73 */ 74 #ifndef ____MSDOSFS_MSDOSFSMOUNT_H__ 75 # define ____MSDOSFS_MSDOSFSMOUNT_H__ 76 #endif /* ____MSDOSFS_MSDOSFSMOUNT_H__ */ 77 78 /* 79 * getifaddrs() on bsdi2 is broken. Don't use it. 80 */ 81 #ifdef HAVE_GETIFADDRS 82 # undef HAVE_GETIFADDRS 83 #endif /* HAVE_GETIFADDRS */ 84 85 86 /* 87 * MACROS 88 */ 89 90 #define NFS_PORT 2049 91 #ifndef NFS_MAXDATA 92 # define NFS_MAXDATA 8192 93 #endif /* NFS_MAXDATA */ 94 #define NFS_MAXPATHLEN 1024 95 #define NFS_MAXNAMLEN 255 96 #define NFS_FHSIZE 32 97 #define NFS_COOKIESIZE 4 98 #define MNTPATHLEN 1024 99 #define MNTNAMLEN 255 100 101 #define NFSMODE_FMT 0170000 102 #define NFSMODE_DIR 0040000 103 #define NFSMODE_CHR 0020000 104 #define NFSMODE_BLK 0060000 105 #define NFSMODE_REG 0100000 106 #define NFSMODE_LNK 0120000 107 #define NFSMODE_SOCK 0140000 108 #define NFSMODE_FIFO 0010000 109 110 #ifndef NFS_PROGRAM 111 # define NFS_PROGRAM ((u_long)100003) 112 #endif /* not NFS_PROGRAM */ 113 #ifndef NFS_VERSION 114 # define NFS_VERSION ((u_long)2) 115 #endif /* not NFS_VERSION */ 116 117 /* 118 * BSD/OS 2.1 deprecated NFSPROC_ROOT and NFSPROC_WRITECACHE and set them 119 * to NFSPROC_NOOP. 120 * Since amd is its own NFS server, reinstate them. 121 */ 122 #if (NFSPROC_ROOT == NFSPROC_NOOP) 123 # undef NFSPROC_ROOT 124 # define NFSPROC_ROOT 3 125 #endif /* (NFSPROC_ROOT == NFSPROC_NOOP) */ 126 #if (NFSPROC_WRITECACHE == NFSPROC_NOOP) 127 # undef NFSPROC_WRITECACHE 128 # define NFSPROC_WRITECACHE 7 129 #endif /* (NFSPROC_WRITECACHE == NFSPROC_NOOP) */ 130 131 /* map field names */ 132 #define ex_dir ex_name 133 #define gr_name g_name 134 #define gr_next g_next 135 #define ml_directory ml_path 136 #define ml_hostname ml_name 137 #define ml_next ml_nxt 138 #define fh_data fh_bytes 139 140 /* 141 * TYPEDEFS: 142 */ 143 typedef char *dirpath; 144 typedef char *filename; 145 typedef char *name; 146 typedef char *nfspath; 147 typedef char nfscookie[NFS_COOKIESIZE]; 148 typedef nfstype nfsftype; 149 typedef enum nfsstat nfsstat; 150 typedef struct attrstat nfsattrstat; 151 typedef struct createargs nfscreateargs; 152 typedef struct dirlist nfsdirlist; 153 typedef struct diropargs nfsdiropargs; 154 typedef struct diropokres nfsdiropokres; 155 typedef struct diropres nfsdiropres; 156 typedef struct entry nfsentry; 157 typedef struct exports *exports; 158 typedef struct exports exportnode; 159 typedef struct fattr nfsfattr; 160 typedef struct fhstatus fhstatus; 161 typedef struct groups *groups; 162 typedef struct groups groupnode; 163 typedef struct linkargs nfslinkargs; 164 typedef struct mountlist *mountlist; 165 typedef struct mountlist mountbody; 166 typedef struct nfstime nfstime; 167 typedef struct readargs nfsreadargs; 168 typedef struct readdirargs nfsreaddirargs; 169 typedef struct readdirres nfsreaddirres; 170 typedef struct readlinkres nfsreadlinkres; 171 typedef struct readokres nfsreadokres; 172 typedef struct readres nfsreadres; 173 typedef struct renameargs nfsrenameargs; 174 typedef struct sattr nfssattr; 175 typedef struct sattrargs nfssattrargs; 176 typedef struct statfsokres nfsstatfsokres; 177 typedef struct statfsres nfsstatfsres; 178 typedef struct symlinkargs nfssymlinkargs; 179 typedef struct writeargs nfswriteargs; 180 181 182 /* 183 * EXTERNALS: 184 */ 185 186 extern nfsattrstat *nfsproc_getattr_2_svc(nfsv2fh_t *, struct svc_req *); 187 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); 188 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); 189 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); 190 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); 191 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); 192 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); 193 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); 194 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); 195 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); 196 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); 197 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); 198 extern nfsreadlinkres *nfsproc_readlink_2_svc(nfsv2fh_t *, struct svc_req *); 199 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); 200 extern nfsstatfsres *nfsproc_statfs_2_svc(nfsv2fh_t *, struct svc_req *); 201 extern void *nfsproc_null_2_svc(void *, struct svc_req *); 202 extern void *nfsproc_root_2_svc(void *, struct svc_req *); 203 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); 204 205 extern bool_t xdr_attrstat(XDR *, nfsattrstat*); 206 extern bool_t xdr_createargs(XDR *, nfscreateargs*); 207 extern bool_t xdr_dirlist(XDR *, nfsdirlist*); 208 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); 209 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); 210 extern bool_t xdr_diropres(XDR *, nfsdiropres*); 211 extern bool_t xdr_entry(XDR *, nfsentry*); 212 extern bool_t xdr_fattr(XDR *, nfsfattr*); 213 extern bool_t xdr_filename(XDR *, filename*); 214 extern bool_t xdr_ftype(XDR *, nfsftype*); 215 extern bool_t xdr_linkargs(XDR *, nfslinkargs*); 216 extern bool_t xdr_mountlist(XDR *xdrs, mountlist *objp); 217 extern bool_t xdr_nfs_fh(XDR *, nfsv2fh_t*); 218 extern bool_t xdr_nfscookie(XDR *, nfscookie); 219 extern bool_t xdr_nfspath(XDR *, nfspath*); 220 extern bool_t xdr_nfsstat(XDR *, nfsstat*); 221 extern bool_t xdr_nfstime(XDR *, nfstime*); 222 extern bool_t xdr_readargs(XDR *, nfsreadargs*); 223 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); 224 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); 225 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); 226 extern bool_t xdr_readokres(XDR *, nfsreadokres*); 227 extern bool_t xdr_readres(XDR *, nfsreadres*); 228 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); 229 extern bool_t xdr_sattr(XDR *, nfssattr*); 230 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); 231 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); 232 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); 233 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); 234 extern bool_t xdr_writeargs(XDR *, nfswriteargs*); 235 236 237 /* 238 * ENUMS: 239 */ 240 241 /* 242 * Use AMU_ prefixes so as to not conflict with #define's in <nfs/nfsv2.h>. 243 * It is vital! that the AMU_* match one-to-one with the NFS_OK and NFSERR_* 244 * codes listed in <nfs/nfsv2.h>. 245 */ 246 enum nfsstat { 247 AMU_NFS_OK = 0, 248 AMU_NFSERR_PERM = 1, 249 AMU_NFSERR_NOENT = 2, 250 AMU_NFSERR_IO = 5, 251 AMU_NFSERR_NXIO = 6, 252 AMU_NFSERR_ACCES = 13, 253 AMU_NFSERR_EXIST = 17, 254 AMU_NFSERR_NODEV = 19, 255 AMU_NFSERR_NOTDIR = 20, 256 AMU_NFSERR_ISDIR = 21, 257 AMU_NFSERR_FBIG = 27, 258 AMU_NFSERR_NOSPC = 28, 259 AMU_NFSERR_ROFS = 30, 260 AMU_NFSERR_NAMETOOLONG = 63, 261 AMU_NFSERR_NOTEMPTY = 66, 262 AMU_NFSERR_DQUOT = 69, 263 AMU_NFSERR_STALE = 70, 264 AMU_NFSERR_WFLUSH = 99 265 }; 266 267 268 /* 269 * STRUCTURES: 270 */ 271 272 struct nfstime { 273 u_int nt_seconds; 274 u_int nt_useconds; 275 }; 276 277 struct fattr { 278 nfsftype na_type; 279 u_int na_mode; 280 u_int na_nlink; 281 u_int na_uid; 282 u_int na_gid; 283 u_int na_size; 284 u_int na_blocksize; 285 u_int na_rdev; 286 u_int na_blocks; 287 u_int na_fsid; 288 u_int na_fileid; 289 nfstime na_atime; 290 nfstime na_mtime; 291 nfstime na_ctime; 292 }; 293 294 struct sattr { 295 u_int sa_mode; 296 u_int sa_uid; 297 u_int sa_gid; 298 u_int sa_size; 299 nfstime sa_atime; 300 nfstime sa_mtime; 301 }; 302 303 struct attrstat { 304 nfsstat ns_status; 305 union { 306 nfsfattr ns_attr_u; 307 } ns_u; 308 }; 309 310 struct sattrargs { 311 nfsv2fh_t sag_fhandle; 312 nfssattr sag_attributes; 313 }; 314 315 struct diropargs { 316 nfsv2fh_t da_fhandle; /* was dir */ 317 filename da_name; 318 }; 319 320 struct diropokres { 321 nfsv2fh_t drok_fhandle; 322 nfsfattr drok_attributes; 323 }; 324 325 struct diropres { 326 nfsstat dr_status; /* was status */ 327 union { 328 nfsdiropokres dr_drok_u; /* was diropres */ 329 } dr_u; /* was diropres_u */ 330 }; 331 332 struct readlinkres { 333 nfsstat rlr_status; 334 union { 335 nfspath rlr_data_u; 336 } rlr_u; 337 }; 338 339 struct readargs { 340 nfsv2fh_t ra_fhandle; 341 u_int ra_offset; 342 u_int ra_count; 343 u_int ra_totalcount; 344 }; 345 346 struct readokres { 347 nfsfattr raok_attributes; 348 struct { 349 u_int raok_len_u; 350 char *raok_val_u; 351 } raok_u; 352 }; 353 354 struct readres { 355 nfsstat rr_status; 356 union { 357 nfsreadokres rr_reply_u; 358 } rr_u; 359 }; 360 361 struct writeargs { 362 nfsv2fh_t wra_fhandle; 363 u_int wra_beginoffset; 364 u_int wra_offset; 365 u_int wra_totalcount; 366 struct { 367 u_int wra_len_u; 368 char *wra_val_u; 369 } wra_u; 370 }; 371 372 struct createargs { 373 nfsdiropargs ca_where; 374 nfssattr ca_attributes; 375 }; 376 377 struct renameargs { 378 nfsdiropargs rna_from; 379 nfsdiropargs rna_to; 380 }; 381 382 struct linkargs { 383 nfsv2fh_t la_fhandle; 384 nfsdiropargs la_to; 385 }; 386 387 struct symlinkargs { 388 nfsdiropargs sla_from; 389 nfspath sla_to; 390 nfssattr sla_attributes; 391 }; 392 393 struct readdirargs { 394 nfsv2fh_t rda_fhandle; 395 nfscookie rda_cookie; 396 u_int rda_count; 397 }; 398 399 struct entry { 400 u_int ne_fileid; 401 filename ne_name; 402 nfscookie ne_cookie; 403 nfsentry *ne_nextentry; 404 }; 405 406 struct dirlist { 407 nfsentry *dl_entries; 408 bool_t dl_eof; 409 }; 410 411 struct readdirres { 412 nfsstat rdr_status; 413 union { 414 nfsdirlist rdr_reply_u; 415 } rdr_u; 416 }; 417 418 struct statfsokres { 419 u_int sfrok_tsize; 420 u_int sfrok_bsize; 421 u_int sfrok_blocks; 422 u_int sfrok_bfree; 423 u_int sfrok_bavail; 424 }; 425 426 struct statfsres { 427 nfsstat sfr_status; 428 union { 429 nfsstatfsokres sfr_reply_u; 430 } sfr_u; 431 }; 432 433 434 /****************************************************************************/ 435 /*** XDR ADDITIONS ***/ 436 /****************************************************************************/ 437 438 struct exports { 439 dirpath ex_dir; 440 groups ex_groups; 441 exports ex_next; 442 }; 443 444 typedef char fhandle[NFS_FHSIZE]; 445 446 struct fhstatus { 447 u_int fhs_status; 448 union { 449 fhandle fhs_fhandle; 450 } fhstatus_u; 451 }; 452 453 struct groups { 454 name gr_name; 455 groups gr_next; 456 }; 457 458 struct mountlist { 459 name ml_hostname; 460 dirpath ml_directory; 461 mountlist ml_next; 462 }; 463 464 465 /****************************************************************************/ 466 /*** NFS ADDITIONS ***/ 467 /****************************************************************************/ 468 469 #ifndef MOUNTPROG 470 # define MOUNTPROG RPCPROG_MNT 471 #endif /* not MOUNTPROG */ 472 473 #ifndef MOUNTVERS 474 # define MOUNTVERS RPCMNT_VER1 475 #endif /* not MOUNTVERS */ 476 477 #ifndef MOUNTPROC_MNT 478 # define MOUNTPROC_MNT RPCMNT_MOUNT 479 #endif /* not MOUNTPROC_MNT */ 480 481 #ifndef MOUNTPROC_DUMP 482 # define MOUNTPROC_DUMP RPCMNT_DUMP 483 #endif /* not MOUNTPROC_DUMP */ 484 485 #ifndef MOUNTPROC_UMNT 486 # define MOUNTPROC_UMNT RPCMNT_UMOUNT 487 #endif /* not MOUNTPROC_UMNT */ 488 489 #ifndef MOUNTPROC_UMNTALL 490 # define MOUNTPROC_UMNTALL RPCMNT_UMNTALL 491 #endif /* not MOUNTPROC_UMNTALL */ 492 493 #ifndef MOUNTPROC_EXPORT 494 # define MOUNTPROC_EXPORT RPCMNT_EXPORT 495 #endif /* not MOUNTPROC_EXPORT */ 496 497 498 #endif /* not _AMU_NFS_PROT_H */ 499