summaryrefslogtreecommitdiffstats
path: root/sys/fs/nfs/nfsdport.h
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2009-05-04 15:23:58 +0000
committerrmacklem <rmacklem@FreeBSD.org>2009-05-04 15:23:58 +0000
commite3d34903b6fb9cb09f7e616bde59d97341958fa2 (patch)
tree0246ff14527b554e60f1c9212be00ee8c1128197 /sys/fs/nfs/nfsdport.h
parentfb2908c8ff440e0985013b83071bd8dfecb11371 (diff)
downloadFreeBSD-src-e3d34903b6fb9cb09f7e616bde59d97341958fa2.zip
FreeBSD-src-e3d34903b6fb9cb09f7e616bde59d97341958fa2.tar.gz
Add the experimental nfs subtree to the kernel, that includes
support for NFSv4 as well as NFSv2 and 3. It lives in 3 subdirs under sys/fs: nfs - functions that are common to the client and server nfsclient - a mutation of sys/nfsclient that call generic functions to do RPCs and handle state. As such, it retains the buffer cache handling characteristics and vnode semantics that are found in sys/nfsclient, for the most part. nfsserver - the server. It includes a DRC designed specifically for NFSv4, that is used instead of the generic DRC in sys/rpc. The build glue will be checked in later, so at this point, it consists of 3 new subdirs that should not affect kernel building. Approved by: kib (mentor)
Diffstat (limited to 'sys/fs/nfs/nfsdport.h')
-rw-r--r--sys/fs/nfs/nfsdport.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/sys/fs/nfs/nfsdport.h b/sys/fs/nfs/nfsdport.h
new file mode 100644
index 0000000..f8ee445
--- /dev/null
+++ b/sys/fs/nfs/nfsdport.h
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2009 Rick Macklem, University of Guelph
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * These macros handle nfsvattr fields. They look a bit silly here, but
+ * are quite different for the Darwin port.
+ */
+#define NFSVNO_ATTRINIT(n) (VATTR_NULL(&((n)->na_vattr)))
+#define NFSVNO_SETATTRVAL(n, f, v) ((n)->na_##f = (v))
+#define NFSVNO_SETACTIVE(n, f)
+#define NFSVNO_UNSET(n, f) ((n)->na_##f = VNOVAL)
+#define NFSVNO_NOTSETMODE(n) ((n)->na_mode == ((mode_t)VNOVAL))
+#define NFSVNO_ISSETMODE(n) ((n)->na_mode != ((mode_t)VNOVAL))
+#define NFSVNO_NOTSETUID(n) ((n)->na_uid == ((uid_t)VNOVAL))
+#define NFSVNO_ISSETUID(n) ((n)->na_uid != ((uid_t)VNOVAL))
+#define NFSVNO_NOTSETGID(n) ((n)->na_gid == ((gid_t)VNOVAL))
+#define NFSVNO_ISSETGID(n) ((n)->na_gid != ((gid_t)VNOVAL))
+#define NFSVNO_NOTSETSIZE(n) ((n)->na_size == VNOVAL)
+#define NFSVNO_ISSETSIZE(n) ((n)->na_size != VNOVAL)
+#define NFSVNO_NOTSETATIME(n) ((n)->na_atime.tv_sec == VNOVAL)
+#define NFSVNO_ISSETATIME(n) ((n)->na_atime.tv_sec != VNOVAL)
+#define NFSVNO_NOTSETMTIME(n) ((n)->na_mtime.tv_sec == VNOVAL)
+#define NFSVNO_ISSETMTIME(n) ((n)->na_mtime.tv_sec != VNOVAL)
+
+/*
+ * This structure acts as a "catch-all" for information that
+ * needs to be returned by nfsd_fhtovp().
+ */
+struct nfsexstuff {
+ int nes_vfslocked; /* required for all ports */
+ int nes_exflag;
+};
+
+#define NFSVNO_EXINIT(e) ((e)->nes_exflag = 0)
+#define NFSVNO_EXPORTED(e) ((e)->nes_exflag & MNT_EXPORTED)
+#define NFSVNO_EXRDONLY(e) ((e)->nes_exflag & MNT_EXRDONLY)
+#define NFSVNO_EXPORTANON(e) ((e)->nes_exflag & MNT_EXPORTANON)
+#define NFSVNO_EXSTRICTACCESS(e) ((e)->nes_exflag & MNT_EXSTRICTACCESS)
+#define NFSVNO_EXGSSONLY(e) ((e)->nes_exflag & MNT_EXGSSONLY)
+#define NFSVNO_EXV4ONLY(e) ((e)->nes_exflag & MNT_EXV4ONLY)
+
+#define NFSVNO_SETEXRDONLY(e) ((e)->nes_exflag = (MNT_EXPORTED|MNT_EXRDONLY))
+#define NFSVNO_SETEXGSSONLY(e) ((e)->nes_exflag |= MNT_EXGSSONLY)
+
+#define NFSVNO_CMPFH(f1, f2) \
+ ((f1)->fh_fsid.val[0] == (f2)->fh_fsid.val[0] && \
+ (f1)->fh_fsid.val[1] == (f2)->fh_fsid.val[1] && \
+ !bcmp((f1)->fh_fid.fid_data, (f2)->fh_fid.fid_data, \
+ (f1)->fh_fid.fid_len))
+
+#define NFSLOCKHASH(f) \
+ (&nfslockhash[(*((u_int32_t *)((f)->fh_fid.fid_data))) % NFSLOCKHASHSIZE])
+
+#define NFSFPVNODE(f) ((struct vnode *)((f)->f_data))
+#define NFSFPCRED(f) ((f)->f_cred)
+#define NFSFPFLAG(f) ((f)->f_flag)
+
+int fp_getfvp(NFSPROC_T *, int, struct file **, struct vnode **);
+
+#define NFSNAMEICNDSET(n, c, o, f) do { \
+ (n)->cn_cred = (c); \
+ (n)->cn_nameiop = (o); \
+ (n)->cn_flags = (f); \
+ } while (0)
+
+/*
+ * A little bit of Darwin vfs kpi.
+ */
+#define vnode_mount(v) ((v)->v_mount)
+#define vfs_statfs(m) (&((m)->mnt_stat))
+
+#define NFSPATHLEN_T size_t
+
+/*
+ * These are set to the minimum and maximum size of a server file
+ * handle.
+ */
+#define NFSRV_MINFH (sizeof (fhandle_t))
+#define NFSRV_MAXFH (sizeof (fhandle_t))
+
OpenPOWER on IntegriCloud