]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/fs/nfs/nfsdport.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / fs / nfs / nfsdport.h
1 /*-
2  * Copyright (c) 2009 Rick Macklem, University of Guelph
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 /*
30  * These macros handle nfsvattr fields. They look a bit silly here, but
31  * are quite different for the Darwin port.
32  */
33 #define NFSVNO_ATTRINIT(n)              (VATTR_NULL(&((n)->na_vattr)))
34 #define NFSVNO_SETATTRVAL(n, f, v)      ((n)->na_##f = (v))
35 #define NFSVNO_SETACTIVE(n, f)
36 #define NFSVNO_UNSET(n, f)              ((n)->na_##f = VNOVAL)
37 #define NFSVNO_NOTSETMODE(n)            ((n)->na_mode == ((mode_t)VNOVAL))
38 #define NFSVNO_ISSETMODE(n)             ((n)->na_mode != ((mode_t)VNOVAL))
39 #define NFSVNO_NOTSETUID(n)             ((n)->na_uid == ((uid_t)VNOVAL))
40 #define NFSVNO_ISSETUID(n)              ((n)->na_uid != ((uid_t)VNOVAL))
41 #define NFSVNO_NOTSETGID(n)             ((n)->na_gid == ((gid_t)VNOVAL))
42 #define NFSVNO_ISSETGID(n)              ((n)->na_gid != ((gid_t)VNOVAL))
43 #define NFSVNO_NOTSETSIZE(n)            ((n)->na_size == VNOVAL)
44 #define NFSVNO_ISSETSIZE(n)             ((n)->na_size != VNOVAL)
45 #define NFSVNO_NOTSETATIME(n)           ((n)->na_atime.tv_sec == VNOVAL)
46 #define NFSVNO_ISSETATIME(n)            ((n)->na_atime.tv_sec != VNOVAL)
47 #define NFSVNO_NOTSETMTIME(n)           ((n)->na_mtime.tv_sec == VNOVAL)
48 #define NFSVNO_ISSETMTIME(n)            ((n)->na_mtime.tv_sec != VNOVAL)
49
50 /*
51  * This structure acts as a "catch-all" for information that
52  * needs to be returned by nfsd_fhtovp().
53  */
54 struct nfsexstuff {
55         int     nes_vfslocked;                  /* required for all ports */
56         int     nes_exflag;                     /* export flags */
57         int     nes_numsecflavor;               /* # of security flavors */
58         int     nes_secflavors[MAXSECFLAVORS];  /* and the flavors */
59 };
60
61 #define NFSVNO_EXINIT(e)                ((e)->nes_exflag = 0)
62 #define NFSVNO_EXPORTED(e)              ((e)->nes_exflag & MNT_EXPORTED)
63 #define NFSVNO_EXRDONLY(e)              ((e)->nes_exflag & MNT_EXRDONLY)
64 #define NFSVNO_EXPORTANON(e)            ((e)->nes_exflag & MNT_EXPORTANON)
65 #define NFSVNO_EXSTRICTACCESS(e)        ((e)->nes_exflag & MNT_EXSTRICTACCESS)
66 #define NFSVNO_EXV4ONLY(e)              ((e)->nes_exflag & MNT_EXV4ONLY)
67
68 #define NFSVNO_SETEXRDONLY(e)   ((e)->nes_exflag = (MNT_EXPORTED|MNT_EXRDONLY))
69
70 #define NFSVNO_CMPFH(f1, f2)                                            \
71     ((f1)->fh_fsid.val[0] == (f2)->fh_fsid.val[0] &&                    \
72      (f1)->fh_fsid.val[1] == (f2)->fh_fsid.val[1] &&                    \
73      !bcmp((f1)->fh_fid.fid_data, (f2)->fh_fid.fid_data,                \
74             (f1)->fh_fid.fid_len))
75
76 #define NFSLOCKHASH(f)                                                  \
77         (&nfslockhash[(*((u_int32_t *)((f)->fh_fid.fid_data))) % NFSLOCKHASHSIZE])
78
79 #define NFSFPVNODE(f)   ((struct vnode *)((f)->f_data))
80 #define NFSFPCRED(f)    ((f)->f_cred)
81 #define NFSFPFLAG(f)    ((f)->f_flag)
82
83 int fp_getfvp(NFSPROC_T *, int, struct file **, struct vnode **);
84
85 #define NFSNAMEICNDSET(n, c, o, f)      do {                            \
86         (n)->cn_cred = (c);                                             \
87         (n)->cn_nameiop = (o);                                          \
88         (n)->cn_flags = (f);                                            \
89     } while (0)
90
91 /*
92  * A little bit of Darwin vfs kpi.
93  */
94 #define vnode_mount(v)  ((v)->v_mount)
95 #define vfs_statfs(m)   (&((m)->mnt_stat))
96
97 #define NFSPATHLEN_T    size_t
98
99 /*
100  * These are set to the minimum and maximum size of a server file
101  * handle.
102  */
103 #define NFSRV_MINFH     (sizeof (fhandle_t))
104 #define NFSRV_MAXFH     (sizeof (fhandle_t))
105