1 1.1 dholland /* $NetBSD: nfsdport.h,v 1.1.1.2 2016/11/18 07:49:12 pgoyette Exp $ */ 2 1.1 dholland /*- 3 1.1 dholland * Copyright (c) 2009 Rick Macklem, University of Guelph 4 1.1 dholland * All rights reserved. 5 1.1 dholland * 6 1.1 dholland * Redistribution and use in source and binary forms, with or without 7 1.1 dholland * modification, are permitted provided that the following conditions 8 1.1 dholland * are met: 9 1.1 dholland * 1. Redistributions of source code must retain the above copyright 10 1.1 dholland * notice, this list of conditions and the following disclaimer. 11 1.1 dholland * 2. Redistributions in binary form must reproduce the above copyright 12 1.1 dholland * notice, this list of conditions and the following disclaimer in the 13 1.1 dholland * documentation and/or other materials provided with the distribution. 14 1.1 dholland * 15 1.1 dholland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 1.1 dholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 1.1 dholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 1.1 dholland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 1.1 dholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 1.1 dholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 1.1 dholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 1.1 dholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 1.1 dholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 1.1 dholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 1.1 dholland * SUCH DAMAGE. 26 1.1 dholland * 27 1.1.1.2 pgoyette * FreeBSD: head/sys/fs/nfs/nfsdport.h 283635 2015-05-27 22:00:05Z rmacklem 28 1.1 dholland * $NetBSD: nfsdport.h,v 1.1.1.2 2016/11/18 07:49:12 pgoyette Exp $ 29 1.1 dholland */ 30 1.1 dholland 31 1.1 dholland /* 32 1.1 dholland * These macros handle nfsvattr fields. They look a bit silly here, but 33 1.1 dholland * are quite different for the Darwin port. 34 1.1 dholland */ 35 1.1 dholland #define NFSVNO_ATTRINIT(n) (VATTR_NULL(&((n)->na_vattr))) 36 1.1 dholland #define NFSVNO_SETATTRVAL(n, f, v) ((n)->na_##f = (v)) 37 1.1 dholland #define NFSVNO_SETACTIVE(n, f) 38 1.1 dholland #define NFSVNO_UNSET(n, f) ((n)->na_##f = VNOVAL) 39 1.1 dholland #define NFSVNO_NOTSETMODE(n) ((n)->na_mode == ((mode_t)VNOVAL)) 40 1.1 dholland #define NFSVNO_ISSETMODE(n) ((n)->na_mode != ((mode_t)VNOVAL)) 41 1.1 dholland #define NFSVNO_NOTSETUID(n) ((n)->na_uid == ((uid_t)VNOVAL)) 42 1.1 dholland #define NFSVNO_ISSETUID(n) ((n)->na_uid != ((uid_t)VNOVAL)) 43 1.1 dholland #define NFSVNO_NOTSETGID(n) ((n)->na_gid == ((gid_t)VNOVAL)) 44 1.1 dholland #define NFSVNO_ISSETGID(n) ((n)->na_gid != ((gid_t)VNOVAL)) 45 1.1 dholland #define NFSVNO_NOTSETSIZE(n) ((n)->na_size == VNOVAL) 46 1.1 dholland #define NFSVNO_ISSETSIZE(n) ((n)->na_size != VNOVAL) 47 1.1 dholland #define NFSVNO_NOTSETATIME(n) ((n)->na_atime.tv_sec == VNOVAL) 48 1.1 dholland #define NFSVNO_ISSETATIME(n) ((n)->na_atime.tv_sec != VNOVAL) 49 1.1 dholland #define NFSVNO_NOTSETMTIME(n) ((n)->na_mtime.tv_sec == VNOVAL) 50 1.1 dholland #define NFSVNO_ISSETMTIME(n) ((n)->na_mtime.tv_sec != VNOVAL) 51 1.1 dholland 52 1.1 dholland /* 53 1.1 dholland * This structure acts as a "catch-all" for information that 54 1.1 dholland * needs to be returned by nfsd_fhtovp(). 55 1.1 dholland */ 56 1.1 dholland struct nfsexstuff { 57 1.1 dholland int nes_exflag; /* export flags */ 58 1.1 dholland int nes_numsecflavor; /* # of security flavors */ 59 1.1 dholland int nes_secflavors[MAXSECFLAVORS]; /* and the flavors */ 60 1.1 dholland }; 61 1.1 dholland 62 1.1 dholland /* 63 1.1 dholland * These are NO-OPS for BSD until Isilon upstreams EXITCODE support. 64 1.1 dholland * EXITCODE is an in-memory ring buffer that holds the routines failing status. 65 1.1 dholland * This is a valuable tool to use when debugging and analyzing issues. 66 1.1 dholland * In addition to recording a routine's failing status, it offers 67 1.1 dholland * logging of routines for call stack tracing. 68 1.1 dholland * EXITCODE should be used only in routines that return a true errno value, as 69 1.1 dholland * that value will be formatted to a displayable errno string. Routines that 70 1.1 dholland * return regular int status that are not true errno should not set EXITCODE. 71 1.1 dholland * If you want to log routine tracing, you can add EXITCODE(0) to any routine. 72 1.1 dholland * NFS extended the EXITCODE with EXITCODE2 to record either the routine's 73 1.1 dholland * exit errno status or the nd_repstat. 74 1.1 dholland */ 75 1.1 dholland #define NFSEXITCODE(error) 76 1.1 dholland #define NFSEXITCODE2(error, nd) 77 1.1 dholland 78 1.1 dholland #define NFSVNO_EXINIT(e) ((e)->nes_exflag = 0) 79 1.1 dholland #define NFSVNO_EXPORTED(e) ((e)->nes_exflag & MNT_EXPORTED) 80 1.1 dholland #define NFSVNO_EXRDONLY(e) ((e)->nes_exflag & MNT_EXRDONLY) 81 1.1 dholland #define NFSVNO_EXPORTANON(e) ((e)->nes_exflag & MNT_EXPORTANON) 82 1.1 dholland #define NFSVNO_EXSTRICTACCESS(e) ((e)->nes_exflag & MNT_EXSTRICTACCESS) 83 1.1 dholland #define NFSVNO_EXV4ONLY(e) ((e)->nes_exflag & MNT_EXV4ONLY) 84 1.1 dholland 85 1.1 dholland #define NFSVNO_SETEXRDONLY(e) ((e)->nes_exflag = (MNT_EXPORTED|MNT_EXRDONLY)) 86 1.1 dholland 87 1.1 dholland #define NFSVNO_CMPFH(f1, f2) \ 88 1.1 dholland ((f1)->fh_fsid.val[0] == (f2)->fh_fsid.val[0] && \ 89 1.1 dholland (f1)->fh_fsid.val[1] == (f2)->fh_fsid.val[1] && \ 90 1.1 dholland bcmp(&(f1)->fh_fid, &(f2)->fh_fid, sizeof(struct fid)) == 0) 91 1.1 dholland 92 1.1 dholland #define NFSLOCKHASH(f) \ 93 1.1.1.2 pgoyette (&nfslockhash[nfsrv_hashfh(f) % nfsrv_lockhashsize]) 94 1.1 dholland 95 1.1 dholland #define NFSFPVNODE(f) ((struct vnode *)((f)->f_data)) 96 1.1 dholland #define NFSFPCRED(f) ((f)->f_cred) 97 1.1 dholland #define NFSFPFLAG(f) ((f)->f_flag) 98 1.1 dholland 99 1.1 dholland #define NFSNAMEICNDSET(n, c, o, f) do { \ 100 1.1 dholland (n)->cn_cred = (c); \ 101 1.1 dholland (n)->cn_nameiop = (o); \ 102 1.1 dholland (n)->cn_flags = (f); \ 103 1.1 dholland } while (0) 104 1.1 dholland 105 1.1 dholland /* 106 1.1 dholland * A little bit of Darwin vfs kpi. 107 1.1 dholland */ 108 1.1 dholland #define vnode_mount(v) ((v)->v_mount) 109 1.1 dholland #define vfs_statfs(m) (&((m)->mnt_stat)) 110 1.1 dholland 111 1.1 dholland #define NFSPATHLEN_T size_t 112 1.1 dholland 113 1.1 dholland /* 114 1.1 dholland * These are set to the minimum and maximum size of a server file 115 1.1 dholland * handle. 116 1.1 dholland */ 117 1.1 dholland #define NFSRV_MINFH (sizeof (fhandle_t)) 118 1.1 dholland #define NFSRV_MAXFH (sizeof (fhandle_t)) 119 1.1 dholland 120 1.1.1.2 pgoyette /* Use this macro for debug printfs. */ 121 1.1.1.2 pgoyette #define NFSD_DEBUG(level, ...) do { \ 122 1.1.1.2 pgoyette if (nfsd_debuglevel >= (level)) \ 123 1.1.1.2 pgoyette printf(__VA_ARGS__); \ 124 1.1.1.2 pgoyette } while (0) 125 1.1.1.2 pgoyette 126