]>
git.proxmox.com Git - mirror_spl-debian.git/blob - include/sys/vnode.h
1 /*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://zfsonlinux.org/>.
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 \*****************************************************************************/
28 #include <linux/module.h>
29 #include <linux/syscalls.h>
30 #include <linux/fcntl.h>
31 #include <linux/buffer_head.h>
32 #include <linux/dcache.h>
33 #include <linux/namei.h>
34 #include <linux/file.h>
36 #include <linux/fs_struct.h>
37 #include <linux/mount.h>
39 #include <sys/mutex.h>
40 #include <sys/types.h>
43 #include <sys/sunldi.h>
46 * Prior to linux-2.6.33 only O_DSYNC semantics were implemented and
47 * they used the O_SYNC flag. As of linux-2.6.33 the this behavior
48 * was properly split in to O_SYNC and O_DSYNC respectively.
51 #define O_DSYNC O_SYNC
56 #define FCREAT O_CREAT
57 #define FTRUNC O_TRUNC
58 #define FOFFMAX O_LARGEFILE
60 #define FDSYNC O_DSYNC
63 #define FDIRECT O_DIRECT
64 #define FAPPEND O_APPEND
66 #define FNODSYNC 0x10000 /* fsync pseudo flag */
67 #define FNOFOLLOW 0x20000 /* don't follow symlinks */
69 #define F_FREESP 11 /* Free file space */
73 * The vnode AT_ flags are mapped to the Linux ATTR_* flags.
74 * This allows them to be used safely with an iattr structure.
75 * The AT_XVATTR flag has been added and mapped to the upper
76 * bit range to avoid conflicting with the standard Linux set.
81 #define AT_MODE ATTR_MODE
82 #define AT_UID ATTR_UID
83 #define AT_GID ATTR_GID
84 #define AT_SIZE ATTR_SIZE
85 #define AT_ATIME ATTR_ATIME
86 #define AT_MTIME ATTR_MTIME
87 #define AT_CTIME ATTR_CTIME
89 #define ATTR_XVATTR (1 << 31)
90 #define AT_XVATTR ATTR_XVATTR
92 #define ATTR_IATTR_MASK (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE | \
93 ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_FILE)
101 #define LOOKUP_DIR 0x01
102 #define LOOKUP_XATTR 0x02
103 #define CREATE_XATTR_DIR 0x04
104 #define ATTR_NOACLCHECK 0x20
106 #ifdef HAVE_PATH_IN_NAMEIDATA
107 # define nd_dentry path.dentry
108 # define nd_mnt path.mnt
110 # define nd_dentry dentry
129 typedef struct vattr
{
130 enum vtype va_type
; /* vnode type */
131 u_int va_mask
; /* attribute bit-mask */
132 u_short va_mode
; /* acc mode */
133 uid_t va_uid
; /* owner uid */
134 gid_t va_gid
; /* owner gid */
135 long va_fsid
; /* fs id */
136 long va_nodeid
; /* node # */
137 uint32_t va_nlink
; /* # links */
138 uint64_t va_size
; /* file size */
139 struct timespec va_atime
; /* last acc */
140 struct timespec va_mtime
; /* last mod */
141 struct timespec va_ctime
; /* last chg */
142 dev_t va_rdev
; /* dev */
143 uint64_t va_nblocks
; /* space used */
144 uint32_t va_blksize
; /* block size */
145 uint32_t va_seq
; /* sequence */
146 struct dentry
*va_dentry
; /* dentry to wire */
149 typedef struct vnode
{
151 kmutex_t v_lock
; /* protects vnode fields */
152 uint_t v_flag
; /* vnode flags (see below) */
153 uint_t v_count
; /* reference count */
154 void *v_data
; /* private data for fs */
155 struct vfs
*v_vfsp
; /* ptr to containing VFS */
156 struct stdata
*v_stream
; /* associated stream */
157 enum vtype v_type
; /* vnode type */
158 dev_t v_rdev
; /* device (VCHR, VBLK) */
159 gfp_t v_gfp_mask
; /* original mapping gfp mask */
162 typedef struct vn_file
{
163 int f_fd
; /* linux fd for lookup */
164 struct task_struct
*f_task
; /* linux task this fd belongs to */
165 struct file
*f_file
; /* linux file struct */
166 atomic_t f_ref
; /* ref count */
167 kmutex_t f_lock
; /* struct lock */
168 loff_t f_offset
; /* offset */
169 vnode_t
*f_vnode
; /* vnode */
170 struct list_head f_list
; /* list referenced file_t's */
173 extern vnode_t
*vn_alloc(int flag
);
174 void vn_free(vnode_t
*vp
);
175 extern vtype_t
vn_mode_to_vtype(mode_t
);
176 extern mode_t
vn_vtype_to_mode(vtype_t
);
177 extern int vn_open(const char *path
, uio_seg_t seg
, int flags
, int mode
,
178 vnode_t
**vpp
, int x1
, void *x2
);
179 extern int vn_openat(const char *path
, uio_seg_t seg
, int flags
, int mode
,
180 vnode_t
**vpp
, int x1
, void *x2
, vnode_t
*vp
, int fd
);
181 extern int vn_rdwr(uio_rw_t uio
, vnode_t
*vp
, void *addr
, ssize_t len
,
182 offset_t off
, uio_seg_t seg
, int x1
, rlim64_t x2
,
183 void *x3
, ssize_t
*residp
);
184 extern int vn_close(vnode_t
*vp
, int flags
, int x1
, int x2
, void *x3
, void *x4
);
185 extern int vn_seek(vnode_t
*vp
, offset_t o
, offset_t
*op
, void *ct
);
187 extern int vn_remove(const char *path
, uio_seg_t seg
, int flags
);
188 extern int vn_rename(const char *path1
, const char *path2
, int x1
);
189 extern int vn_getattr(vnode_t
*vp
, vattr_t
*vap
, int flags
, void *x3
, void *x4
);
190 extern int vn_fsync(vnode_t
*vp
, int flags
, void *x3
, void *x4
);
191 extern int vn_space(vnode_t
*vp
, int cmd
, struct flock
*bfp
, int flag
,
192 offset_t offset
, void *x6
, void *x7
);
193 extern file_t
*vn_getf(int fd
);
194 extern void vn_releasef(int fd
);
195 extern int vn_set_pwd(const char *filename
);
197 int spl_vn_init_kallsyms_lookup(void);
198 int spl_vn_init(void);
199 void spl_vn_fini(void);
201 #define VOP_CLOSE vn_close
202 #define VOP_SEEK vn_seek
203 #define VOP_GETATTR vn_getattr
204 #define VOP_FSYNC vn_fsync
205 #define VOP_SPACE vn_space
206 #define VOP_PUTPAGE(vp, o, s, f, x1, x2) ((void)0)
207 #define vn_is_readonly(vp) 0
209 #define releasef vn_releasef
211 extern vnode_t
*rootdir
;
213 #endif /* SPL_VNODE_H */