2 * This file is part of the SPL: Solaris Porting Layer.
4 * Copyright (c) 2008 Lawrence Livermore National Security, LLC.
5 * Produced at Lawrence Livermore National Laboratory
7 * Brian Behlendorf <behlendorf1@llnl.gov>,
8 * Herb Wartens <wartens2@llnl.gov>,
9 * Jim Garlick <garlick@llnl.gov>
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.
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
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.
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>
42 #include <linux/fs_struct.h>
43 #include <linux/mount.h>
45 #include <sys/mutex.h>
46 #include <sys/types.h>
49 #include <sys/sunldi.h>
52 #define XVA_MAGIC 0x78766174
54 #define O_DSYNC 040000000
58 #define FCREAT O_CREAT
59 #define FTRUNC O_TRUNC
60 #define FOFFMAX O_LARGEFILE
62 #define FDSYNC O_DSYNC
63 #define FRSYNC O_RSYNC
65 #define FDIRECT O_DIRECT
66 #define FAPPEND O_APPEND
68 #define FNODSYNC 0x10000 /* fsync pseudo flag */
69 #define FNOFOLLOW 0x20000 /* don't follow symlinks */
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
96 #ifdef HAVE_PATH_IN_NAMEIDATA
97 # define nd_dentry path.dentry
98 # define nd_mnt path.mnt
100 # define nd_dentry dentry
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 */
137 typedef struct xoptattr
{
138 timestruc_t xoa_createtime
; /* Create time of file */
141 uint8_t xoa_readonly
;
143 uint8_t xoa_nounlink
;
144 uint8_t xoa_immutable
;
145 uint8_t xoa_appendonly
;
147 uint8_t xoa_settable
;
149 uint8_t xoa_av_quarantined
;
150 uint8_t xoa_av_modified
;
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 */
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 */
172 typedef struct vnode
{
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) */
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 */
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) */
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
);
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
);
224 static __inline__
int
230 static __inline__
int
231 vn_putpage(vnode_t
*vp
, offset_t off
, ssize_t size
,
232 int flags
, void *x1
, void *x2
) {
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
244 #define releasef vn_releasef
246 extern vnode_t
*rootdir
;
252 #endif /* SPL_VNODE_H */