1 /*
2 * Copyright (c) 2010 Kip Macy All rights reserved.
3 * Copyright (C) 2017-2021 THL A29 Limited, a Tencent company.
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 are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice, this
10 * list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 */
27
28 #ifndef _FSTACK_SYS_VNODE_H_
29 #define _FSTACK_SYS_VNODE_H_
30
31 #include <sys/uio.h>
32 #include <sys/namei.h>
33
34 /*
35 * Vnode types. VNON means no type.
36 */
37 enum vtype {
38 VNON, VREG, VDIR, VBLK, VCHR,
39 VLNK, VSOCK, VFIFO, VBAD, VMARKER
40 };
41
42 struct nameidata;
43 struct stat;
44 struct nstat;
45 struct vnode {
46 enum vtype v_type;
47 struct mount *v_mount; /* u ptr to vfs we are in */
48 u_long v_vflag; /* v vnode flags */
49 int v_fd; /* file descriptor */
50 };
51
52 #define VOP_ADVLOCK(a, b, c, d, e) (0)
53 #define VOP_UNLOCK(a)
54 static __inline int
vn_lock(struct vnode * vp,int flags)55 vn_lock(struct vnode *vp, int flags)
56 {
57 return (0);
58 }
59
60 static __inline int
vrefcnt(struct vnode * vp)61 vrefcnt(struct vnode *vp)
62 {
63 return (0);
64 }
65
66 #define VREF(vp) vref(vp)
67 static __inline void
vref(struct vnode * vp)68 vref(struct vnode *vp)
69 {
70
71 }
72
73 static __inline void
vrele(struct vnode * vp)74 vrele(struct vnode *vp)
75 {
76
77 }
78
79 extern struct vnode *rootvnode;
80 /* 0 or POSIX version of AIO i'face */
81 extern int async_io_version;
82
83 static __inline int
vn_fullpath(struct thread * td,struct vnode * vp,char ** retbuf,char ** freebuf)84 vn_fullpath(struct thread *td, struct vnode *vp,
85 char **retbuf, char **freebuf)
86 {
87 return (0);
88 }
89
90 static __inline void
cvtnstat(struct stat * sb,struct nstat * nsb)91 cvtnstat(struct stat *sb, struct nstat *nsb)
92 {
93
94 }
95
96 struct vattr {
97 enum vtype va_type;/* vnode type (for create) */
98 u_short va_mode; /* files access mode and type */
99 dev_t va_fsid; /* filesystem id */
100 struct timespec va_mtime;
101 dev_t va_rdev; /* device the special file represents */
102 u_quad_t va_size; /* file size in bytes */
103 long va_fileid; /* file id */
104 };
105
106 /* underlying node already locked */
107 #define IO_NODELOCKED 0x0008
108
109 #define VNOVAL (-1)
110
111 /*
112 * Convert between vnode types and inode formats (since POSIX.1
113 * defines mode word of stat structure in terms of inode formats).
114 */
115 extern enum vtype iftovt_tab[];
116 extern int vttoif_tab[];
117 #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
118 #define VTTOIF(indx) (vttoif_tab[(int)(indx)])
119 #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
120
121 #define VV_PROCDEP 0x0100 /* vnode is process dependent */
122
123 static __inline int
VOP_PATHCONF(struct vnode * vp,int name,register_t * retval)124 VOP_PATHCONF(struct vnode *vp, int name, register_t *retval)
125 {
126 return (0);
127 }
128
129 static __inline int
VOP_GETATTR(struct vnode * vp,struct vattr * vap,struct ucred * cred)130 VOP_GETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred)
131 {
132 bzero(vap, sizeof(struct vattr));
133 return (0);
134 }
135
136 int vn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp);
137 int vn_close(struct vnode *vp, int flags, struct ucred *file_cred,
138 struct thread *td);
139
140 int vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base,
141 int len, off_t offset, enum uio_seg segflg, int ioflg,
142 struct ucred *active_cred, struct ucred *file_cred, ssize_t *aresid,
143 struct thread *td);
144
145 #define VFS_SMR_DECLARE \
146 extern smr_t vfs_smr
147
148 #define VFS_SMR() vfs_smr
149 #define vfs_smr_enter() smr_enter(VFS_SMR())
150 #define vfs_smr_exit() smr_exit(VFS_SMR())
151 #define vfs_smr_entered_load(ptr) smr_entered_load((ptr), VFS_SMR())
152 #define VFS_SMR_ASSERT_ENTERED() SMR_ASSERT_ENTERED(VFS_SMR())
153
154 static __inline void
vrefact(struct vnode * vp)155 vrefact(struct vnode *vp)
156 {
157
158 }
159
160 #define IO_SEQMAX 0x7F /* seq heuristic max value */
161
162 extern u_int vn_lock_pair_pause_max;
163
164 #endif /* _FSTACK_SYS_VNODE_H_ */
165