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