1 // SPDX-License-Identifier: BSD-2-Clause
2 /*
3 * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD$
28 */
29
30 #ifndef _OPENSOLARIS_SYS_VNODE_H_
31 #define _OPENSOLARIS_SYS_VNODE_H_
32
33 struct vnode;
34 struct vattr;
35 struct xucred;
36
37 typedef struct flock flock64_t;
38 typedef struct vnode vnode_t;
39 typedef struct vattr vattr_t;
40 #if __FreeBSD_version < 1400093
41 typedef enum vtype vtype_t;
42 #else
43 #define vtype_t __enum_uint8(vtype)
44 #endif
45
46 #include <sys/types.h>
47 #include <sys/queue.h>
48 #include_next <sys/sdt.h>
49 #include <sys/namei.h>
50 enum symfollow { NO_FOLLOW = NOFOLLOW };
51
52 #define NOCRED ((struct ucred *)0) /* no credential available */
53 #define F_FREESP 11 /* Free file space */
54
55 #include <sys/proc.h>
56 #include <sys/vnode_impl.h>
57 #ifndef IN_BASE
58 #include_next <sys/vnode.h>
59 #endif
60 #include <sys/ccompat.h>
61 #include <sys/mount.h>
62 #include <sys/cred.h>
63 #include <sys/fcntl.h>
64 #include <sys/refcount.h>
65 #include <sys/file.h>
66 #include <sys/filedesc.h>
67 #include <sys/syscallsubr.h>
68 #include <sys/vm.h>
69 #include <vm/vm_object.h>
70
71 typedef struct vop_vector vnodeops_t;
72 #define vop_fid vop_vptofh
73 #define vop_fid_args vop_vptofh_args
74 #define a_fid a_fhp
75
76 #define vn_vfswlock(vp) (0)
77 #define vn_vfsunlock(vp) do { } while (0)
78
79 #ifndef IN_BASE
80 #define vn_has_cached_data(vp) \
81 ((vp)->v_object != NULL && \
82 (vp)->v_object->resident_page_count > 0)
83
84 static __inline void
vn_flush_cached_data(vnode_t * vp,boolean_t sync)85 vn_flush_cached_data(vnode_t *vp, boolean_t sync)
86 {
87 if (vm_object_mightbedirty(vp->v_object)) {
88 int flags = sync ? OBJPC_SYNC : 0;
89 zfs_vmobject_wlock(vp->v_object);
90 vm_object_page_clean(vp->v_object, 0, 0, flags);
91 zfs_vmobject_wunlock(vp->v_object);
92 }
93 }
94 #endif
95
96 #define vn_matchops(vp, vops) ((vp)->v_op == &(vops))
97
98 #define VN_HOLD(v) vref(v)
99 #define VN_RELE(v) vrele(v)
100 #define VN_URELE(v) vput(v)
101
102 #define vnevent_create(vp, ct) do { } while (0)
103 #define vnevent_link(vp, ct) do { } while (0)
104 #define vnevent_remove(vp, dvp, name, ct) do { } while (0)
105 #define vnevent_rmdir(vp, dvp, name, ct) do { } while (0)
106 #define vnevent_rename_src(vp, dvp, name, ct) do { } while (0)
107 #define vnevent_rename_dest(vp, dvp, name, ct) do { } while (0)
108 #define vnevent_rename_dest_dir(vp, ct) do { } while (0)
109
110 /*
111 * We will use va_spare is place of Solaris' va_mask.
112 * This field is initialized in zfs_setattr().
113 */
114 #define va_mask va_spare
115 /* TODO: va_fileid is shorter than va_nodeid !!! */
116 #define va_nodeid va_fileid
117 /* TODO: This field needs conversion! */
118 #define va_nblocks va_bytes
119 #define va_blksize va_blocksize
120
121 #define MAXOFFSET_T OFF_MAX
122
123 #define FIGNORECASE 0x00
124
125 /*
126 * Attributes of interest to the caller of setattr or getattr.
127 */
128
129 #undef AT_UID
130 #undef AT_GID
131
132 #define AT_MODE 0x00002
133 #define AT_UID 0x00004
134 #define AT_GID 0x00008
135 #define AT_FSID 0x00010
136 #define AT_NODEID 0x00020
137 #define AT_NLINK 0x00040
138 #define AT_SIZE 0x00080
139 #define AT_ATIME 0x00100
140 #define AT_MTIME 0x00200
141 #define AT_CTIME 0x00400
142 #define AT_RDEV 0x00800
143 #define AT_BLKSIZE 0x01000
144 #define AT_NBLOCKS 0x02000
145 /* 0x04000 */ /* unused */
146 #define AT_SEQ 0x08000
147 /*
148 * If AT_XVATTR is set then there are additional bits to process in
149 * the xvattr_t's attribute bitmap. If this is not set then the bitmap
150 * MUST be ignored. Note that this bit must be set/cleared explicitly.
151 * That is, setting AT_ALL will NOT set AT_XVATTR.
152 */
153 #define AT_XVATTR 0x10000
154
155 #define AT_ALL (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
156 AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
157 AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
158
159 #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
160 AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV)
161
162 #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME)
163
164 #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|\
165 AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
166
167 #ifndef IN_BASE
168 static __inline void
vattr_init_mask(vattr_t * vap)169 vattr_init_mask(vattr_t *vap)
170 {
171
172 vap->va_mask = 0;
173
174 if (vap->va_uid != (uid_t)VNOVAL)
175 vap->va_mask |= AT_UID;
176 if (vap->va_gid != (gid_t)VNOVAL)
177 vap->va_mask |= AT_GID;
178 if (vap->va_size != (u_quad_t)VNOVAL)
179 vap->va_mask |= AT_SIZE;
180 if (vap->va_atime.tv_sec != VNOVAL)
181 vap->va_mask |= AT_ATIME;
182 if (vap->va_mtime.tv_sec != VNOVAL)
183 vap->va_mask |= AT_MTIME;
184 if (vap->va_mode != (uint16_t)VNOVAL)
185 vap->va_mask |= AT_MODE;
186 if (vap->va_flags != VNOVAL)
187 vap->va_mask |= AT_XVATTR;
188 }
189 #endif
190
191 #define RLIM64_INFINITY 0
192
193 #include <sys/vfs.h>
194
195 #endif /* _OPENSOLARIS_SYS_VNODE_H_ */
196