1*e81f0ea2Spgoyette /* $NetBSD: nfsdport.h,v 1.1.1.2 2016/11/18 07:49:12 pgoyette Exp $ */ 26ca35587Sdholland /*- 36ca35587Sdholland * Copyright (c) 2009 Rick Macklem, University of Guelph 46ca35587Sdholland * All rights reserved. 56ca35587Sdholland * 66ca35587Sdholland * Redistribution and use in source and binary forms, with or without 76ca35587Sdholland * modification, are permitted provided that the following conditions 86ca35587Sdholland * are met: 96ca35587Sdholland * 1. Redistributions of source code must retain the above copyright 106ca35587Sdholland * notice, this list of conditions and the following disclaimer. 116ca35587Sdholland * 2. Redistributions in binary form must reproduce the above copyright 126ca35587Sdholland * notice, this list of conditions and the following disclaimer in the 136ca35587Sdholland * documentation and/or other materials provided with the distribution. 146ca35587Sdholland * 156ca35587Sdholland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 166ca35587Sdholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 176ca35587Sdholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 186ca35587Sdholland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 196ca35587Sdholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 206ca35587Sdholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 216ca35587Sdholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 226ca35587Sdholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 236ca35587Sdholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 246ca35587Sdholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 256ca35587Sdholland * SUCH DAMAGE. 266ca35587Sdholland * 27*e81f0ea2Spgoyette * FreeBSD: head/sys/fs/nfs/nfsdport.h 283635 2015-05-27 22:00:05Z rmacklem 28*e81f0ea2Spgoyette * $NetBSD: nfsdport.h,v 1.1.1.2 2016/11/18 07:49:12 pgoyette Exp $ 296ca35587Sdholland */ 306ca35587Sdholland 316ca35587Sdholland /* 326ca35587Sdholland * These macros handle nfsvattr fields. They look a bit silly here, but 336ca35587Sdholland * are quite different for the Darwin port. 346ca35587Sdholland */ 356ca35587Sdholland #define NFSVNO_ATTRINIT(n) (VATTR_NULL(&((n)->na_vattr))) 366ca35587Sdholland #define NFSVNO_SETATTRVAL(n, f, v) ((n)->na_##f = (v)) 376ca35587Sdholland #define NFSVNO_SETACTIVE(n, f) 386ca35587Sdholland #define NFSVNO_UNSET(n, f) ((n)->na_##f = VNOVAL) 396ca35587Sdholland #define NFSVNO_NOTSETMODE(n) ((n)->na_mode == ((mode_t)VNOVAL)) 406ca35587Sdholland #define NFSVNO_ISSETMODE(n) ((n)->na_mode != ((mode_t)VNOVAL)) 416ca35587Sdholland #define NFSVNO_NOTSETUID(n) ((n)->na_uid == ((uid_t)VNOVAL)) 426ca35587Sdholland #define NFSVNO_ISSETUID(n) ((n)->na_uid != ((uid_t)VNOVAL)) 436ca35587Sdholland #define NFSVNO_NOTSETGID(n) ((n)->na_gid == ((gid_t)VNOVAL)) 446ca35587Sdholland #define NFSVNO_ISSETGID(n) ((n)->na_gid != ((gid_t)VNOVAL)) 456ca35587Sdholland #define NFSVNO_NOTSETSIZE(n) ((n)->na_size == VNOVAL) 466ca35587Sdholland #define NFSVNO_ISSETSIZE(n) ((n)->na_size != VNOVAL) 476ca35587Sdholland #define NFSVNO_NOTSETATIME(n) ((n)->na_atime.tv_sec == VNOVAL) 486ca35587Sdholland #define NFSVNO_ISSETATIME(n) ((n)->na_atime.tv_sec != VNOVAL) 496ca35587Sdholland #define NFSVNO_NOTSETMTIME(n) ((n)->na_mtime.tv_sec == VNOVAL) 506ca35587Sdholland #define NFSVNO_ISSETMTIME(n) ((n)->na_mtime.tv_sec != VNOVAL) 516ca35587Sdholland 526ca35587Sdholland /* 536ca35587Sdholland * This structure acts as a "catch-all" for information that 546ca35587Sdholland * needs to be returned by nfsd_fhtovp(). 556ca35587Sdholland */ 566ca35587Sdholland struct nfsexstuff { 576ca35587Sdholland int nes_exflag; /* export flags */ 586ca35587Sdholland int nes_numsecflavor; /* # of security flavors */ 596ca35587Sdholland int nes_secflavors[MAXSECFLAVORS]; /* and the flavors */ 606ca35587Sdholland }; 616ca35587Sdholland 626ca35587Sdholland /* 636ca35587Sdholland * These are NO-OPS for BSD until Isilon upstreams EXITCODE support. 646ca35587Sdholland * EXITCODE is an in-memory ring buffer that holds the routines failing status. 656ca35587Sdholland * This is a valuable tool to use when debugging and analyzing issues. 666ca35587Sdholland * In addition to recording a routine's failing status, it offers 676ca35587Sdholland * logging of routines for call stack tracing. 686ca35587Sdholland * EXITCODE should be used only in routines that return a true errno value, as 696ca35587Sdholland * that value will be formatted to a displayable errno string. Routines that 706ca35587Sdholland * return regular int status that are not true errno should not set EXITCODE. 716ca35587Sdholland * If you want to log routine tracing, you can add EXITCODE(0) to any routine. 726ca35587Sdholland * NFS extended the EXITCODE with EXITCODE2 to record either the routine's 736ca35587Sdholland * exit errno status or the nd_repstat. 746ca35587Sdholland */ 756ca35587Sdholland #define NFSEXITCODE(error) 766ca35587Sdholland #define NFSEXITCODE2(error, nd) 776ca35587Sdholland 786ca35587Sdholland #define NFSVNO_EXINIT(e) ((e)->nes_exflag = 0) 796ca35587Sdholland #define NFSVNO_EXPORTED(e) ((e)->nes_exflag & MNT_EXPORTED) 806ca35587Sdholland #define NFSVNO_EXRDONLY(e) ((e)->nes_exflag & MNT_EXRDONLY) 816ca35587Sdholland #define NFSVNO_EXPORTANON(e) ((e)->nes_exflag & MNT_EXPORTANON) 826ca35587Sdholland #define NFSVNO_EXSTRICTACCESS(e) ((e)->nes_exflag & MNT_EXSTRICTACCESS) 836ca35587Sdholland #define NFSVNO_EXV4ONLY(e) ((e)->nes_exflag & MNT_EXV4ONLY) 846ca35587Sdholland 856ca35587Sdholland #define NFSVNO_SETEXRDONLY(e) ((e)->nes_exflag = (MNT_EXPORTED|MNT_EXRDONLY)) 866ca35587Sdholland 876ca35587Sdholland #define NFSVNO_CMPFH(f1, f2) \ 886ca35587Sdholland ((f1)->fh_fsid.val[0] == (f2)->fh_fsid.val[0] && \ 896ca35587Sdholland (f1)->fh_fsid.val[1] == (f2)->fh_fsid.val[1] && \ 906ca35587Sdholland bcmp(&(f1)->fh_fid, &(f2)->fh_fid, sizeof(struct fid)) == 0) 916ca35587Sdholland 926ca35587Sdholland #define NFSLOCKHASH(f) \ 93*e81f0ea2Spgoyette (&nfslockhash[nfsrv_hashfh(f) % nfsrv_lockhashsize]) 946ca35587Sdholland 956ca35587Sdholland #define NFSFPVNODE(f) ((struct vnode *)((f)->f_data)) 966ca35587Sdholland #define NFSFPCRED(f) ((f)->f_cred) 976ca35587Sdholland #define NFSFPFLAG(f) ((f)->f_flag) 986ca35587Sdholland 996ca35587Sdholland #define NFSNAMEICNDSET(n, c, o, f) do { \ 1006ca35587Sdholland (n)->cn_cred = (c); \ 1016ca35587Sdholland (n)->cn_nameiop = (o); \ 1026ca35587Sdholland (n)->cn_flags = (f); \ 1036ca35587Sdholland } while (0) 1046ca35587Sdholland 1056ca35587Sdholland /* 1066ca35587Sdholland * A little bit of Darwin vfs kpi. 1076ca35587Sdholland */ 1086ca35587Sdholland #define vnode_mount(v) ((v)->v_mount) 1096ca35587Sdholland #define vfs_statfs(m) (&((m)->mnt_stat)) 1106ca35587Sdholland 1116ca35587Sdholland #define NFSPATHLEN_T size_t 1126ca35587Sdholland 1136ca35587Sdholland /* 1146ca35587Sdholland * These are set to the minimum and maximum size of a server file 1156ca35587Sdholland * handle. 1166ca35587Sdholland */ 1176ca35587Sdholland #define NFSRV_MINFH (sizeof (fhandle_t)) 1186ca35587Sdholland #define NFSRV_MAXFH (sizeof (fhandle_t)) 1196ca35587Sdholland 120*e81f0ea2Spgoyette /* Use this macro for debug printfs. */ 121*e81f0ea2Spgoyette #define NFSD_DEBUG(level, ...) do { \ 122*e81f0ea2Spgoyette if (nfsd_debuglevel >= (level)) \ 123*e81f0ea2Spgoyette printf(__VA_ARGS__); \ 124*e81f0ea2Spgoyette } while (0) 125*e81f0ea2Spgoyette 126