FreeBSD: Fix the build on FreeBSD 12
[zfs.git] / include / os / freebsd / spl / sys / vnode.h
blob75c32f221ffd677aadef43e5c6beba1160455905
1 /*
2 * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
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.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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 AUTHORS 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.
26 * $FreeBSD$
29 #ifndef _OPENSOLARIS_SYS_VNODE_H_
30 #define _OPENSOLARIS_SYS_VNODE_H_
32 struct vnode;
33 struct vattr;
34 struct xucred;
36 typedef struct flock flock64_t;
37 typedef struct vnode vnode_t;
38 typedef struct vattr vattr_t;
39 #if __FreeBSD_version < 1400093
40 typedef enum vtype vtype_t;
41 #else
42 #define vtype_t __enum_uint8(vtype)
43 #endif
45 #include <sys/types.h>
46 #include <sys/queue.h>
47 #include_next <sys/sdt.h>
48 #include <sys/namei.h>
49 enum symfollow { NO_FOLLOW = NOFOLLOW };
51 #define NOCRED ((struct ucred *)0) /* no credential available */
52 #define F_FREESP 11 /* Free file space */
54 #include <sys/proc.h>
55 #include <sys/vnode_impl.h>
56 #ifndef IN_BASE
57 #include_next <sys/vnode.h>
58 #endif
59 #include <sys/ccompat.h>
60 #include <sys/mount.h>
61 #include <sys/cred.h>
62 #include <sys/fcntl.h>
63 #include <sys/refcount.h>
64 #include <sys/file.h>
65 #include <sys/filedesc.h>
66 #include <sys/syscallsubr.h>
67 #include <sys/vm.h>
68 #include <vm/vm_object.h>
70 typedef struct vop_vector vnodeops_t;
71 #define VOP_FID VOP_VPTOFH
72 #define vop_fid vop_vptofh
73 #define vop_fid_args vop_vptofh_args
74 #define a_fid a_fhp
76 #define rootvfs (rootvnode == NULL ? NULL : rootvnode->v_mount)
78 #ifndef IN_BASE
79 static __inline int
80 vn_is_readonly(vnode_t *vp)
82 return (vp->v_mount->mnt_flag & MNT_RDONLY);
84 #endif
85 #define vn_vfswlock(vp) (0)
86 #define vn_vfsunlock(vp) do { } while (0)
87 #define vn_ismntpt(vp) \
88 ((vp)->v_type == VDIR && (vp)->v_mountedhere != NULL)
89 #define vn_mountedvfs(vp) ((vp)->v_mountedhere)
90 #define vn_has_cached_data(vp) \
91 ((vp)->v_object != NULL && \
92 (vp)->v_object->resident_page_count > 0)
94 #ifndef IN_BASE
95 static __inline void
96 vn_flush_cached_data(vnode_t *vp, boolean_t sync)
98 #if __FreeBSD_version > 1300054
99 if (vm_object_mightbedirty(vp->v_object)) {
100 #else
101 if (vp->v_object->flags & OBJ_MIGHTBEDIRTY) {
102 #endif
103 int flags = sync ? OBJPC_SYNC : 0;
104 vn_lock(vp, LK_SHARED | LK_RETRY);
105 zfs_vmobject_wlock(vp->v_object);
106 vm_object_page_clean(vp->v_object, 0, 0, flags);
107 zfs_vmobject_wunlock(vp->v_object);
108 VOP_UNLOCK1(vp);
111 #endif
113 #define vn_exists(vp) do { } while (0)
114 #define vn_invalid(vp) do { } while (0)
115 #define vn_free(vp) do { } while (0)
116 #define vn_matchops(vp, vops) ((vp)->v_op == &(vops))
118 #define VN_HOLD(v) vref(v)
119 #define VN_RELE(v) vrele(v)
120 #define VN_URELE(v) vput(v)
122 #define vnevent_create(vp, ct) do { } while (0)
123 #define vnevent_link(vp, ct) do { } while (0)
124 #define vnevent_remove(vp, dvp, name, ct) do { } while (0)
125 #define vnevent_rmdir(vp, dvp, name, ct) do { } while (0)
126 #define vnevent_rename_src(vp, dvp, name, ct) do { } while (0)
127 #define vnevent_rename_dest(vp, dvp, name, ct) do { } while (0)
128 #define vnevent_rename_dest_dir(vp, ct) do { } while (0)
130 #define specvp(vp, rdev, type, cr) (VN_HOLD(vp), (vp))
131 #define MANDLOCK(vp, mode) (0)
134 * We will use va_spare is place of Solaris' va_mask.
135 * This field is initialized in zfs_setattr().
137 #define va_mask va_spare
138 /* TODO: va_fileid is shorter than va_nodeid !!! */
139 #define va_nodeid va_fileid
140 /* TODO: This field needs conversion! */
141 #define va_nblocks va_bytes
142 #define va_blksize va_blocksize
144 #define MAXOFFSET_T OFF_MAX
146 #define FIGNORECASE 0x00
149 * Attributes of interest to the caller of setattr or getattr.
152 #undef AT_UID
153 #undef AT_GID
155 #define AT_MODE 0x00002
156 #define AT_UID 0x00004
157 #define AT_GID 0x00008
158 #define AT_FSID 0x00010
159 #define AT_NODEID 0x00020
160 #define AT_NLINK 0x00040
161 #define AT_SIZE 0x00080
162 #define AT_ATIME 0x00100
163 #define AT_MTIME 0x00200
164 #define AT_CTIME 0x00400
165 #define AT_RDEV 0x00800
166 #define AT_BLKSIZE 0x01000
167 #define AT_NBLOCKS 0x02000
168 /* 0x04000 */ /* unused */
169 #define AT_SEQ 0x08000
171 * If AT_XVATTR is set then there are additional bits to process in
172 * the xvattr_t's attribute bitmap. If this is not set then the bitmap
173 * MUST be ignored. Note that this bit must be set/cleared explicitly.
174 * That is, setting AT_ALL will NOT set AT_XVATTR.
176 #define AT_XVATTR 0x10000
178 #define AT_ALL (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
179 AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
180 AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
182 #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
183 AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV)
185 #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME)
187 #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|\
188 AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
190 #ifndef IN_BASE
191 static __inline void
192 vattr_init_mask(vattr_t *vap)
195 vap->va_mask = 0;
197 if (vap->va_uid != (uid_t)VNOVAL)
198 vap->va_mask |= AT_UID;
199 if (vap->va_gid != (gid_t)VNOVAL)
200 vap->va_mask |= AT_GID;
201 if (vap->va_size != (u_quad_t)VNOVAL)
202 vap->va_mask |= AT_SIZE;
203 if (vap->va_atime.tv_sec != VNOVAL)
204 vap->va_mask |= AT_ATIME;
205 if (vap->va_mtime.tv_sec != VNOVAL)
206 vap->va_mask |= AT_MTIME;
207 if (vap->va_mode != (uint16_t)VNOVAL)
208 vap->va_mask |= AT_MODE;
209 if (vap->va_flags != VNOVAL)
210 vap->va_mask |= AT_XVATTR;
212 #endif
214 #define RLIM64_INFINITY 0
216 #include <sys/vfs.h>
218 #endif /* _OPENSOLARIS_SYS_VNODE_H_ */