]> git.proxmox.com Git - mirror_spl-debian.git/blob - include/sys/vnode.h
9568a1392632819d4268f59d625e9b300124e95a
[mirror_spl-debian.git] / include / sys / vnode.h
1 /*
2 * This file is part of the SPL: Solaris Porting Layer.
3 *
4 * Copyright (c) 2008 Lawrence Livermore National Security, LLC.
5 * Produced at Lawrence Livermore National Laboratory
6 * Written by:
7 * Brian Behlendorf <behlendorf1@llnl.gov>,
8 * Herb Wartens <wartens2@llnl.gov>,
9 * Jim Garlick <garlick@llnl.gov>
10 * UCRL-CODE-235197
11 *
12 * This is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 */
26
27 #ifndef _SPL_VNODE_H
28 #define _SPL_VNODE_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #include <linux/module.h>
35 #include <linux/syscalls.h>
36 #include <linux/fcntl.h>
37 #include <linux/buffer_head.h>
38 #include <linux/dcache.h>
39 #include <linux/namei.h>
40 #include <linux/file.h>
41 #include <linux/fs.h>
42 #include <linux/fs_struct.h>
43 #include <linux/mount.h>
44 #include <sys/kmem.h>
45 #include <sys/mutex.h>
46 #include <sys/types.h>
47 #include <sys/time.h>
48 #include <sys/uio.h>
49 #include <sys/sunldi.h>
50
51 #define XVA_MAPSIZE 3
52 #define XVA_MAGIC 0x78766174
53
54 #define O_DSYNC 040000000
55
56 #define FREAD 1
57 #define FWRITE 2
58 #define FCREAT O_CREAT
59 #define FTRUNC O_TRUNC
60 #define FOFFMAX O_LARGEFILE
61 #define FSYNC O_SYNC
62 #define FDSYNC O_DSYNC
63 #define FRSYNC O_RSYNC
64 #define FEXCL O_EXCL
65 #define FDIRECT O_DIRECT
66 #define FAPPEND O_APPEND
67
68 #define FNODSYNC 0x10000 /* fsync pseudo flag */
69 #define FNOFOLLOW 0x20000 /* don't follow symlinks */
70
71 #define AT_TYPE 0x00001
72 #define AT_MODE 0x00002
73 #undef AT_UID /* Conflicts with linux/auxvec.h */
74 #define AT_UID 0x00004
75 #undef AT_GID /* Conflicts with linux/auxvec.h */
76 #define AT_GID 0x00008
77 #define AT_FSID 0x00010
78 #define AT_NODEID 0x00020
79 #define AT_NLINK 0x00040
80 #define AT_SIZE 0x00080
81 #define AT_ATIME 0x00100
82 #define AT_MTIME 0x00200
83 #define AT_CTIME 0x00400
84 #define AT_RDEV 0x00800
85 #define AT_BLKSIZE 0x01000
86 #define AT_NBLOCKS 0x02000
87 #define AT_SEQ 0x08000
88 #define AT_XVATTR 0x10000
89
90 #define CRCREAT 0x01
91 #define RMFILE 0x02
92
93 #define B_INVAL 0x01
94 #define B_TRUNC 0x02
95
96 #ifdef HAVE_PATH_IN_NAMEIDATA
97 # define nd_dentry path.dentry
98 # define nd_mnt path.mnt
99 #else
100 # define nd_dentry dentry
101 # define nd_mnt mnt
102 #endif
103
104 typedef enum vtype {
105 VNON = 0,
106 VREG = 1,
107 VDIR = 2,
108 VBLK = 3,
109 VCHR = 4,
110 VLNK = 5,
111 VFIFO = 6,
112 VDOOR = 7,
113 VPROC = 8,
114 VSOCK = 9,
115 VPORT = 10,
116 VBAD = 11
117 } vtype_t;
118
119 typedef struct vattr {
120 enum vtype va_type; /* vnode type */
121 u_int va_mask; /* attribute bit-mask */
122 u_short va_mode; /* acc mode */
123 short va_uid; /* owner uid */
124 short va_gid; /* owner gid */
125 long va_fsid; /* fs id */
126 long va_nodeid; /* node # */
127 short va_nlink; /* # links */
128 u_long va_size; /* file size */
129 long va_blocksize; /* block size */
130 struct timeval va_atime; /* last acc */
131 struct timeval va_mtime; /* last mod */
132 struct timeval va_ctime; /* last chg */
133 dev_t va_rdev; /* dev */
134 long va_blocks; /* space used */
135 } vattr_t;
136
137 typedef struct xoptattr {
138 timestruc_t xoa_createtime; /* Create time of file */
139 uint8_t xoa_archive;
140 uint8_t xoa_system;
141 uint8_t xoa_readonly;
142 uint8_t xoa_hidden;
143 uint8_t xoa_nounlink;
144 uint8_t xoa_immutable;
145 uint8_t xoa_appendonly;
146 uint8_t xoa_nodump;
147 uint8_t xoa_settable;
148 uint8_t xoa_opaque;
149 uint8_t xoa_av_quarantined;
150 uint8_t xoa_av_modified;
151 } xoptattr_t;
152
153 typedef struct xvattr {
154 vattr_t xva_vattr; /* Embedded vattr structure */
155 uint32_t xva_magic; /* Magic Number */
156 uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */
157 uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */
158 uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */
159 uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */
160 xoptattr_t xva_xoptattrs; /* Optional attributes */
161 } xvattr_t;
162
163 typedef struct vsecattr {
164 uint_t vsa_mask; /* See below */
165 int vsa_aclcnt; /* ACL entry count */
166 void *vsa_aclentp; /* pointer to ACL entries */
167 int vsa_dfaclcnt; /* default ACL entry count */
168 void *vsa_dfaclentp; /* pointer to default ACL entries */
169 size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */
170 } vsecattr_t;
171
172 typedef struct vnode {
173 struct file *v_file;
174 kmutex_t v_lock; /* protects vnode fields */
175 uint_t v_flag; /* vnode flags (see below) */
176 uint_t v_count; /* reference count */
177 void *v_data; /* private data for fs */
178 struct vfs *v_vfsp; /* ptr to containing VFS */
179 struct stdata *v_stream; /* associated stream */
180 enum vtype v_type; /* vnode type */
181 dev_t v_rdev; /* device (VCHR, VBLK) */
182 } vnode_t;
183
184 typedef struct vn_file {
185 int f_fd; /* linux fd for lookup */
186 struct file *f_file; /* linux file struct */
187 atomic_t f_ref; /* ref count */
188 kmutex_t f_lock; /* struct lock */
189 loff_t f_offset; /* offset */
190 vnode_t *f_vnode; /* vnode */
191 struct list_head f_list; /* list referenced file_t's */
192 } file_t;
193
194 typedef struct caller_context {
195 pid_t cc_pid; /* Process ID of the caller */
196 int cc_sysid; /* System ID, used for remote calls */
197 u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */
198 ulong_t cc_flags;
199 } caller_context_t;
200
201 extern vnode_t *vn_alloc(int flag);
202 void vn_free(vnode_t *vp);
203 extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode,
204 vnode_t **vpp, int x1, void *x2);
205 extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
206 vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd);
207 extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len,
208 offset_t off, uio_seg_t seg, int x1, rlim64_t x2,
209 void *x3, ssize_t *residp);
210 extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4);
211 extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, caller_context_t *ct);
212
213 extern int vn_remove(const char *path, uio_seg_t seg, int flags);
214 extern int vn_rename(const char *path1, const char *path2, int x1);
215 extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4);
216 extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4);
217 extern file_t *vn_getf(int fd);
218 extern void vn_releasef(int fd);
219 extern int vn_set_pwd(const char *filename);
220
221 int vn_init(void);
222 void vn_fini(void);
223
224 static __inline__ int
225 vn_rele(vnode_t *vp)
226 {
227 return 0;
228 } /* vn_rele() */
229
230 static __inline__ int
231 vn_putpage(vnode_t *vp, offset_t off, ssize_t size,
232 int flags, void *x1, void *x2) {
233 return 0;
234 } /* vn_putpage() */
235
236 #define VOP_CLOSE vn_close
237 #define VOP_SEEK vn_seek
238 #define VN_RELE vn_rele
239 #define VOP_GETATTR vn_getattr
240 #define VOP_FSYNC vn_fsync
241 #define VOP_PUTPAGE vn_putpage
242 #define vn_is_readonly(vp) 0
243 #define getf vn_getf
244 #define releasef vn_releasef
245
246 extern vnode_t *rootdir;
247
248 #ifdef __cplusplus
249 }
250 #endif
251
252 #endif /* SPL_VNODE_H */