]>
Commit | Line | Data |
---|---|---|
0b3cf046 | 1 | #ifndef _SPL_VNODE_H |
2 | #define _SPL_VNODE_H | |
3 | ||
5d86345d | 4 | #ifdef __cplusplus |
5 | extern "C" { | |
6 | #endif | |
7 | ||
4b171585 | 8 | #include <linux/module.h> |
6adf99e7 | 9 | #include <linux/syscalls.h> |
4b171585 | 10 | #include <linux/fcntl.h> |
11 | #include <linux/uaccess.h> | |
12 | #include <linux/buffer_head.h> | |
13 | #include <linux/dcache.h> | |
14 | #include <linux/namei.h> | |
e4f1d29f | 15 | #include <linux/file.h> |
4b171585 | 16 | #include <linux/fs.h> |
af828292 | 17 | #include <sys/kmem.h> |
18 | #include <sys/mutex.h> | |
4b171585 | 19 | #include <sys/types.h> |
20 | #include <sys/time.h> | |
21 | #include <sys/uio.h> | |
6adf99e7 | 22 | |
0b3cf046 | 23 | #define XVA_MAPSIZE 3 |
24 | #define XVA_MAGIC 0x78766174 | |
25 | ||
36e6f861 | 26 | #define O_DSYNC 040000000 |
27 | ||
4b171585 | 28 | #define FREAD 1 |
29 | #define FWRITE 2 | |
30 | #define FCREAT O_CREAT | |
31 | #define FTRUNC O_TRUNC | |
32 | #define FOFFMAX O_LARGEFILE | |
33 | #define FSYNC O_SYNC | |
34 | #define FDSYNC O_DSYNC | |
35 | #define FRSYNC O_RSYNC | |
36 | #define FEXCL O_EXCL | |
37 | #define FDIRECT O_DIRECT | |
5d86345d | 38 | #define FAPPEND O_APPEND |
4b171585 | 39 | |
40 | #define FNODSYNC 0x10000 /* fsync pseudo flag */ | |
41 | #define FNOFOLLOW 0x20000 /* don't follow symlinks */ | |
42 | ||
43 | #define AT_TYPE 0x00001 | |
44 | #define AT_MODE 0x00002 | |
45 | #undef AT_UID /* Conflicts with linux/auxvec.h */ | |
46 | #define AT_UID 0x00004 | |
47 | #undef AT_GID /* Conflicts with linux/auxvec.h */ | |
48 | #define AT_GID 0x00008 | |
49 | #define AT_FSID 0x00010 | |
50 | #define AT_NODEID 0x00020 | |
51 | #define AT_NLINK 0x00040 | |
52 | #define AT_SIZE 0x00080 | |
53 | #define AT_ATIME 0x00100 | |
54 | #define AT_MTIME 0x00200 | |
55 | #define AT_CTIME 0x00400 | |
56 | #define AT_RDEV 0x00800 | |
57 | #define AT_BLKSIZE 0x01000 | |
58 | #define AT_NBLOCKS 0x02000 | |
59 | #define AT_SEQ 0x08000 | |
60 | #define AT_XVATTR 0x10000 | |
61 | ||
2f5d55aa | 62 | #define CRCREAT 0x01 |
63 | #define RMFILE 0x02 | |
4b171585 | 64 | |
36e6f861 | 65 | #define B_INVAL 0x01 |
66 | #define B_TRUNC 0x02 | |
67 | ||
6adf99e7 | 68 | typedef enum vtype { |
4b171585 | 69 | VNON = 0, |
70 | VREG = 1, | |
71 | VDIR = 2, | |
72 | VBLK = 3, | |
73 | VCHR = 4, | |
74 | VLNK = 5, | |
75 | VFIFO = 6, | |
76 | VDOOR = 7, | |
77 | VPROC = 8, | |
78 | VSOCK = 9, | |
79 | VPORT = 10, | |
80 | VBAD = 11 | |
6adf99e7 | 81 | } vtype_t; |
82 | ||
4b171585 | 83 | typedef struct vattr { |
84 | enum vtype va_type; /* vnode type */ | |
36e6f861 | 85 | u_int va_mask; /* attribute bit-mask */ |
4b171585 | 86 | u_short va_mode; /* acc mode */ |
87 | short va_uid; /* owner uid */ | |
88 | short va_gid; /* owner gid */ | |
89 | long va_fsid; /* fs id */ | |
90 | long va_nodeid; /* node # */ | |
91 | short va_nlink; /* # links */ | |
92 | u_long va_size; /* file size */ | |
93 | long va_blocksize; /* block size */ | |
94 | struct timeval va_atime; /* last acc */ | |
95 | struct timeval va_mtime; /* last mod */ | |
96 | struct timeval va_ctime; /* last chg */ | |
97 | dev_t va_rdev; /* dev */ | |
98 | long va_blocks; /* space used */ | |
99 | } vattr_t; | |
0b3cf046 | 100 | |
101 | typedef struct xoptattr { | |
102 | timestruc_t xoa_createtime; /* Create time of file */ | |
103 | uint8_t xoa_archive; | |
104 | uint8_t xoa_system; | |
105 | uint8_t xoa_readonly; | |
106 | uint8_t xoa_hidden; | |
107 | uint8_t xoa_nounlink; | |
108 | uint8_t xoa_immutable; | |
109 | uint8_t xoa_appendonly; | |
110 | uint8_t xoa_nodump; | |
111 | uint8_t xoa_settable; | |
112 | uint8_t xoa_opaque; | |
113 | uint8_t xoa_av_quarantined; | |
114 | uint8_t xoa_av_modified; | |
115 | } xoptattr_t; | |
116 | ||
0b3cf046 | 117 | typedef struct xvattr { |
118 | vattr_t xva_vattr; /* Embedded vattr structure */ | |
119 | uint32_t xva_magic; /* Magic Number */ | |
120 | uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */ | |
121 | uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */ | |
122 | uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */ | |
123 | uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */ | |
124 | xoptattr_t xva_xoptattrs; /* Optional attributes */ | |
125 | } xvattr_t; | |
126 | ||
127 | typedef struct vsecattr { | |
128 | uint_t vsa_mask; /* See below */ | |
129 | int vsa_aclcnt; /* ACL entry count */ | |
130 | void *vsa_aclentp; /* pointer to ACL entries */ | |
131 | int vsa_dfaclcnt; /* default ACL entry count */ | |
132 | void *vsa_dfaclentp; /* pointer to default ACL entries */ | |
133 | size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */ | |
134 | } vsecattr_t; | |
4b171585 | 135 | |
af828292 | 136 | typedef struct vnode { |
e4f1d29f | 137 | struct file *v_file; |
af828292 | 138 | kmutex_t v_lock; /* protects vnode fields */ |
139 | uint_t v_flag; /* vnode flags (see below) */ | |
140 | uint_t v_count; /* reference count */ | |
141 | void *v_data; /* private data for fs */ | |
142 | struct vfs *v_vfsp; /* ptr to containing VFS */ | |
143 | struct stdata *v_stream; /* associated stream */ | |
144 | enum vtype v_type; /* vnode type */ | |
145 | dev_t v_rdev; /* device (VCHR, VBLK) */ | |
146 | } vnode_t; | |
147 | ||
e4f1d29f | 148 | typedef struct vn_file { |
149 | int f_fd; /* linux fd for lookup */ | |
150 | struct file *f_file; /* linux file struct */ | |
151 | atomic_t f_ref; /* ref count */ | |
152 | kmutex_t f_lock; /* struct lock */ | |
153 | loff_t f_offset; /* offset */ | |
154 | vnode_t *f_vnode; /* vnode */ | |
155 | struct list_head f_list; /* list of referenced file_t's */ | |
156 | } file_t; | |
157 | ||
af828292 | 158 | extern vnode_t *vn_alloc(int flag); |
159 | void vn_free(vnode_t *vp); | |
73e540a0 | 160 | extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 161 | vnode_t **vpp, int x1, void *x2); |
73e540a0 | 162 | extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode, |
4b171585 | 163 | vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd); |
164 | extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, | |
73e540a0 | 165 | offset_t off, uio_seg_t seg, int x1, rlim64_t x2, |
4b171585 | 166 | void *x3, ssize_t *residp); |
2f5d55aa | 167 | extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4); |
73e540a0 | 168 | extern int vn_remove(const char *path, uio_seg_t seg, int flags); |
4b171585 | 169 | extern int vn_rename(const char *path1, const char *path2, int x1); |
36e6f861 | 170 | extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4); |
2f5d55aa | 171 | extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4); |
e4f1d29f | 172 | extern file_t *vn_getf(int fd); |
173 | extern void vn_releasef(int fd); | |
4b171585 | 174 | |
af828292 | 175 | int vn_init(void); |
176 | void vn_fini(void); | |
177 | ||
36e6f861 | 178 | static __inline__ int |
179 | vn_rele(vnode_t *vp) | |
180 | { | |
181 | return 0; | |
182 | } /* vn_rele() */ | |
183 | ||
184 | static __inline__ int | |
185 | vn_putpage(vnode_t *vp, offset_t off, ssize_t size, | |
186 | int flags, void *x1, void *x2) { | |
187 | return 0; | |
188 | } /* vn_putpage() */ | |
189 | ||
4b171585 | 190 | #define VOP_CLOSE vn_close |
36e6f861 | 191 | #define VN_RELE vn_rele |
4b171585 | 192 | #define VOP_GETATTR vn_getattr |
193 | #define VOP_FSYNC vn_fsync | |
36e6f861 | 194 | #define VOP_PUTPAGE vn_putpage |
4b171585 | 195 | #define vn_is_readonly(vp) 0 |
e4f1d29f | 196 | #define getf vn_getf |
197 | #define releasef vn_releasef | |
4b171585 | 198 | |
199 | extern void *rootdir; | |
0b3cf046 | 200 | |
5d86345d | 201 | #ifdef __cplusplus |
202 | } | |
203 | #endif | |
204 | ||
0b3cf046 | 205 | #endif /* SPL_VNODE_H */ |