]>
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://github.com/behlendorf/spl/>.
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 */
70 * The vnode AT_ flags are mapped to the Linux ATTR_* flags.
71 * This allows them to be used safely with an iattr structure.
72 * The AT_XVATTR flag has been added and mapped to the upper
73 * bit range to avoid conflicting with the standard Linux set.
78 #define AT_MODE ATTR_MODE
79 #define AT_UID ATTR_UID
80 #define AT_GID ATTR_GID
81 #define AT_SIZE ATTR_SIZE
82 #define AT_ATIME ATTR_ATIME
83 #define AT_MTIME ATTR_MTIME
84 #define AT_CTIME ATTR_CTIME
86 #define ATTR_XVATTR (1 << 31)
87 #define AT_XVATTR ATTR_XVATTR
89 #define ATTR_IATTR_MASK (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE | \
90 ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_FILE)
98 #define LOOKUP_DIR 0x01
99 #define LOOKUP_XATTR 0x02
100 #define CREATE_XATTR_DIR 0x04
101 #define ATTR_NOACLCHECK 0x20
103 #ifdef HAVE_PATH_IN_NAMEIDATA
104 # define nd_dentry path.dentry
105 # define nd_mnt path.mnt
107 # define nd_dentry dentry
126 typedef struct vattr
{
127 enum vtype va_type
; /* vnode type */
128 u_int va_mask
; /* attribute bit-mask */
129 u_short va_mode
; /* acc mode */
130 uid_t va_uid
; /* owner uid */
131 gid_t va_gid
; /* owner gid */
132 long va_fsid
; /* fs id */
133 long va_nodeid
; /* node # */
134 uint32_t va_nlink
; /* # links */
135 uint64_t va_size
; /* file size */
136 struct timespec va_atime
; /* last acc */
137 struct timespec va_mtime
; /* last mod */
138 struct timespec va_ctime
; /* last chg */
139 dev_t va_rdev
; /* dev */
140 uint64_t va_nblocks
; /* space used */
141 uint32_t va_blksize
; /* block size */
142 uint32_t va_seq
; /* sequence */
143 struct dentry
*va_dentry
; /* dentry to wire */
146 typedef struct vnode
{
148 kmutex_t v_lock
; /* protects vnode fields */
149 uint_t v_flag
; /* vnode flags (see below) */
150 uint_t v_count
; /* reference count */
151 void *v_data
; /* private data for fs */
152 struct vfs
*v_vfsp
; /* ptr to containing VFS */
153 struct stdata
*v_stream
; /* associated stream */
154 enum vtype v_type
; /* vnode type */
155 dev_t v_rdev
; /* device (VCHR, VBLK) */
156 gfp_t v_gfp_mask
; /* original mapping gfp mask */
159 typedef struct vn_file
{
160 int f_fd
; /* linux fd for lookup */
161 struct file
*f_file
; /* linux file struct */
162 atomic_t f_ref
; /* ref count */
163 kmutex_t f_lock
; /* struct lock */
164 loff_t f_offset
; /* offset */
165 vnode_t
*f_vnode
; /* vnode */
166 struct list_head f_list
; /* list referenced file_t's */
169 extern vnode_t
*vn_alloc(int flag
);
170 void vn_free(vnode_t
*vp
);
171 extern vtype_t
vn_mode_to_vtype(mode_t
);
172 extern mode_t
vn_vtype_to_mode(vtype_t
);
173 extern int vn_open(const char *path
, uio_seg_t seg
, int flags
, int mode
,
174 vnode_t
**vpp
, int x1
, void *x2
);
175 extern int vn_openat(const char *path
, uio_seg_t seg
, int flags
, int mode
,
176 vnode_t
**vpp
, int x1
, void *x2
, vnode_t
*vp
, int fd
);
177 extern int vn_rdwr(uio_rw_t uio
, vnode_t
*vp
, void *addr
, ssize_t len
,
178 offset_t off
, uio_seg_t seg
, int x1
, rlim64_t x2
,
179 void *x3
, ssize_t
*residp
);
180 extern int vn_close(vnode_t
*vp
, int flags
, int x1
, int x2
, void *x3
, void *x4
);
181 extern int vn_seek(vnode_t
*vp
, offset_t o
, offset_t
*op
, void *ct
);
183 extern int vn_remove(const char *path
, uio_seg_t seg
, int flags
);
184 extern int vn_rename(const char *path1
, const char *path2
, int x1
);
185 extern int vn_getattr(vnode_t
*vp
, vattr_t
*vap
, int flags
, void *x3
, void *x4
);
186 extern int vn_fsync(vnode_t
*vp
, int flags
, void *x3
, void *x4
);
187 extern file_t
*vn_getf(int fd
);
188 extern void vn_releasef(int fd
);
189 extern int vn_set_pwd(const char *filename
);
194 #define VOP_CLOSE vn_close
195 #define VOP_SEEK vn_seek
196 #define VOP_GETATTR vn_getattr
197 #define VOP_FSYNC vn_fsync
198 #define VOP_PUTPAGE(vp, o, s, f, x1, x2) ((void)0)
199 #define vn_is_readonly(vp) 0
201 #define releasef vn_releasef
203 extern vnode_t
*rootdir
;
205 #endif /* SPL_VNODE_H */