2017-10-04 16:33:43 +00:00
|
|
|
/*
|
2010-05-17 22:18:00 +00:00
|
|
|
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
|
|
|
|
* Copyright (C) 2007 The Regents of the University of California.
|
|
|
|
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
|
|
|
|
* Written by Brian Behlendorf <behlendorf1@llnl.gov>.
|
2008-05-26 04:38:26 +00:00
|
|
|
* UCRL-CODE-235197
|
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* This file is part of the SPL, Solaris Porting Layer.
|
2013-03-05 01:26:55 +00:00
|
|
|
* For details, see <http://zfsonlinux.org/>.
|
2010-05-17 22:18:00 +00:00
|
|
|
*
|
|
|
|
* The SPL is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
2008-05-26 04:38:26 +00:00
|
|
|
*
|
2010-05-17 22:18:00 +00:00
|
|
|
* The SPL is distributed in the hope that it will be useful, but WITHOUT
|
2008-05-26 04:38:26 +00:00
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
2010-05-17 22:18:00 +00:00
|
|
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-04 16:33:43 +00:00
|
|
|
*/
|
2008-05-26 04:38:26 +00:00
|
|
|
|
2008-03-07 23:07:02 +00:00
|
|
|
#ifndef _SPL_VNODE_H
|
2018-02-07 19:49:38 +00:00
|
|
|
#define _SPL_VNODE_H
|
2008-03-07 23:07:02 +00:00
|
|
|
|
2008-03-12 20:52:46 +00:00
|
|
|
#include <linux/module.h>
|
2008-03-10 17:05:34 +00:00
|
|
|
#include <linux/syscalls.h>
|
2008-03-12 20:52:46 +00:00
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/buffer_head.h>
|
|
|
|
#include <linux/dcache.h>
|
|
|
|
#include <linux/namei.h>
|
2008-03-18 23:20:30 +00:00
|
|
|
#include <linux/file.h>
|
2008-03-12 20:52:46 +00:00
|
|
|
#include <linux/fs.h>
|
2009-11-10 22:06:57 +00:00
|
|
|
#include <linux/fs_struct.h>
|
2008-06-02 17:28:49 +00:00
|
|
|
#include <linux/mount.h>
|
2008-03-14 00:04:01 +00:00
|
|
|
#include <sys/kmem.h>
|
|
|
|
#include <sys/mutex.h>
|
2008-03-12 20:52:46 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/uio.h>
|
2015-02-17 15:12:56 +00:00
|
|
|
#include <sys/user.h>
|
2008-03-10 17:05:34 +00:00
|
|
|
|
2010-06-30 17:47:36 +00:00
|
|
|
/*
|
|
|
|
* Prior to linux-2.6.33 only O_DSYNC semantics were implemented and
|
|
|
|
* they used the O_SYNC flag. As of linux-2.6.33 the this behavior
|
|
|
|
* was properly split in to O_SYNC and O_DSYNC respectively.
|
|
|
|
*/
|
|
|
|
#ifndef O_DSYNC
|
2018-02-07 19:49:38 +00:00
|
|
|
#define O_DSYNC O_SYNC
|
2010-06-30 17:47:36 +00:00
|
|
|
#endif
|
2008-03-12 23:48:28 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define FREAD 1
|
|
|
|
#define FWRITE 2
|
|
|
|
#define FCREAT O_CREAT
|
|
|
|
#define FTRUNC O_TRUNC
|
|
|
|
#define FOFFMAX O_LARGEFILE
|
|
|
|
#define FSYNC O_SYNC
|
|
|
|
#define FDSYNC O_DSYNC
|
|
|
|
#define FEXCL O_EXCL
|
|
|
|
#define FDIRECT O_DIRECT
|
|
|
|
#define FAPPEND O_APPEND
|
2008-03-12 20:52:46 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define FNODSYNC 0x10000 /* fsync pseudo flag */
|
|
|
|
#define FNOFOLLOW 0x20000 /* don't follow symlinks */
|
2008-03-12 20:52:46 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define F_FREESP 11 /* Free file space */
|
2012-09-03 12:56:26 +00:00
|
|
|
|
|
|
|
|
2011-03-01 22:02:06 +00:00
|
|
|
/*
|
|
|
|
* The vnode AT_ flags are mapped to the Linux ATTR_* flags.
|
|
|
|
* This allows them to be used safely with an iattr structure.
|
|
|
|
* The AT_XVATTR flag has been added and mapped to the upper
|
|
|
|
* bit range to avoid conflicting with the standard Linux set.
|
|
|
|
*/
|
|
|
|
#undef AT_UID
|
|
|
|
#undef AT_GID
|
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define AT_MODE ATTR_MODE
|
|
|
|
#define AT_UID ATTR_UID
|
|
|
|
#define AT_GID ATTR_GID
|
|
|
|
#define AT_SIZE ATTR_SIZE
|
|
|
|
#define AT_ATIME ATTR_ATIME
|
|
|
|
#define AT_MTIME ATTR_MTIME
|
|
|
|
#define AT_CTIME ATTR_CTIME
|
2011-03-01 22:02:06 +00:00
|
|
|
|
2018-02-16 01:53:18 +00:00
|
|
|
#define ATTR_XVATTR (1U << 31)
|
2018-02-07 19:49:38 +00:00
|
|
|
#define AT_XVATTR ATTR_XVATTR
|
2011-03-01 22:02:06 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define ATTR_IATTR_MASK (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE | \
|
2011-03-01 22:02:06 +00:00
|
|
|
ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_FILE)
|
2008-03-12 20:52:46 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define CRCREAT 0x01
|
|
|
|
#define RMFILE 0x02
|
2008-03-12 20:52:46 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define B_INVAL 0x01
|
|
|
|
#define B_TRUNC 0x02
|
2008-03-12 23:48:28 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define LOOKUP_DIR 0x01
|
|
|
|
#define LOOKUP_XATTR 0x02
|
|
|
|
#define CREATE_XATTR_DIR 0x04
|
|
|
|
#define ATTR_NOACLCHECK 0x20
|
2011-01-11 20:00:35 +00:00
|
|
|
|
2008-03-10 17:05:34 +00:00
|
|
|
typedef enum vtype {
|
2008-03-12 20:52:46 +00:00
|
|
|
VNON = 0,
|
|
|
|
VREG = 1,
|
|
|
|
VDIR = 2,
|
|
|
|
VBLK = 3,
|
|
|
|
VCHR = 4,
|
|
|
|
VLNK = 5,
|
|
|
|
VFIFO = 6,
|
|
|
|
VDOOR = 7,
|
|
|
|
VPROC = 8,
|
|
|
|
VSOCK = 9,
|
|
|
|
VPORT = 10,
|
|
|
|
VBAD = 11
|
2008-03-10 17:05:34 +00:00
|
|
|
} vtype_t;
|
|
|
|
|
2008-03-12 20:52:46 +00:00
|
|
|
typedef struct vattr {
|
2009-01-09 18:03:37 +00:00
|
|
|
enum vtype va_type; /* vnode type */
|
2018-02-16 01:53:18 +00:00
|
|
|
uint32_t va_mask; /* attribute bit-mask */
|
2018-02-07 19:49:38 +00:00
|
|
|
ushort_t va_mode; /* acc mode */
|
2011-01-11 19:56:00 +00:00
|
|
|
uid_t va_uid; /* owner uid */
|
|
|
|
gid_t va_gid; /* owner gid */
|
2009-01-09 18:03:37 +00:00
|
|
|
long va_fsid; /* fs id */
|
|
|
|
long va_nodeid; /* node # */
|
2011-01-11 19:56:00 +00:00
|
|
|
uint32_t va_nlink; /* # links */
|
|
|
|
uint64_t va_size; /* file size */
|
2018-06-20 04:51:18 +00:00
|
|
|
inode_timespec_t va_atime; /* last acc */
|
|
|
|
inode_timespec_t va_mtime; /* last mod */
|
|
|
|
inode_timespec_t va_ctime; /* last chg */
|
2009-01-09 18:03:37 +00:00
|
|
|
dev_t va_rdev; /* dev */
|
2011-03-01 22:02:06 +00:00
|
|
|
uint64_t va_nblocks; /* space used */
|
|
|
|
uint32_t va_blksize; /* block size */
|
|
|
|
uint32_t va_seq; /* sequence */
|
2011-03-30 05:46:38 +00:00
|
|
|
struct dentry *va_dentry; /* dentry to wire */
|
2008-03-12 20:52:46 +00:00
|
|
|
} vattr_t;
|
2008-03-07 23:07:02 +00:00
|
|
|
|
2008-03-14 00:04:01 +00:00
|
|
|
typedef struct vnode {
|
2008-03-18 23:20:30 +00:00
|
|
|
struct file *v_file;
|
2008-03-14 00:04:01 +00:00
|
|
|
kmutex_t v_lock; /* protects vnode fields */
|
|
|
|
uint_t v_flag; /* vnode flags (see below) */
|
|
|
|
uint_t v_count; /* reference count */
|
|
|
|
void *v_data; /* private data for fs */
|
|
|
|
struct vfs *v_vfsp; /* ptr to containing VFS */
|
|
|
|
struct stdata *v_stream; /* associated stream */
|
|
|
|
enum vtype v_type; /* vnode type */
|
|
|
|
dev_t v_rdev; /* device (VCHR, VBLK) */
|
2010-08-12 16:24:31 +00:00
|
|
|
gfp_t v_gfp_mask; /* original mapping gfp mask */
|
2008-03-14 00:04:01 +00:00
|
|
|
} vnode_t;
|
|
|
|
|
2008-03-18 23:20:30 +00:00
|
|
|
typedef struct vn_file {
|
2009-01-09 18:03:37 +00:00
|
|
|
int f_fd; /* linux fd for lookup */
|
2011-10-11 16:50:52 +00:00
|
|
|
struct task_struct *f_task; /* linux task this fd belongs to */
|
2009-01-09 18:03:37 +00:00
|
|
|
struct file *f_file; /* linux file struct */
|
|
|
|
atomic_t f_ref; /* ref count */
|
|
|
|
kmutex_t f_lock; /* struct lock */
|
|
|
|
loff_t f_offset; /* offset */
|
|
|
|
vnode_t *f_vnode; /* vnode */
|
2009-01-09 18:05:03 +00:00
|
|
|
struct list_head f_list; /* list referenced file_t's */
|
2008-03-18 23:20:30 +00:00
|
|
|
} file_t;
|
|
|
|
|
2008-03-14 00:04:01 +00:00
|
|
|
extern vnode_t *vn_alloc(int flag);
|
|
|
|
void vn_free(vnode_t *vp);
|
2011-01-11 19:53:05 +00:00
|
|
|
extern vtype_t vn_mode_to_vtype(mode_t);
|
|
|
|
extern mode_t vn_vtype_to_mode(vtype_t);
|
2008-03-13 19:49:09 +00:00
|
|
|
extern int vn_open(const char *path, uio_seg_t seg, int flags, int mode,
|
2018-02-07 19:49:38 +00:00
|
|
|
vnode_t **vpp, int x1, void *x2);
|
2008-03-13 19:49:09 +00:00
|
|
|
extern int vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
|
2018-02-07 19:49:38 +00:00
|
|
|
vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd);
|
2008-03-12 20:52:46 +00:00
|
|
|
extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len,
|
2018-02-07 19:49:38 +00:00
|
|
|
offset_t off, uio_seg_t seg, int x1, rlim64_t x2,
|
|
|
|
void *x3, ssize_t *residp);
|
2008-03-12 21:33:28 +00:00
|
|
|
extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4);
|
2011-03-01 22:02:06 +00:00
|
|
|
extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, void *ct);
|
2009-01-09 21:59:39 +00:00
|
|
|
|
2008-03-12 23:48:28 +00:00
|
|
|
extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4);
|
2008-03-12 21:33:28 +00:00
|
|
|
extern int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4);
|
2012-09-03 12:56:26 +00:00
|
|
|
extern int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag,
|
|
|
|
offset_t offset, void *x6, void *x7);
|
2008-03-18 23:20:30 +00:00
|
|
|
extern file_t *vn_getf(int fd);
|
|
|
|
extern void vn_releasef(int fd);
|
2015-02-17 15:12:56 +00:00
|
|
|
extern void vn_areleasef(int fd, uf_info_t *fip);
|
2009-10-01 23:06:15 +00:00
|
|
|
extern int vn_set_pwd(const char *filename);
|
2008-03-12 20:52:46 +00:00
|
|
|
|
2011-11-09 20:29:51 +00:00
|
|
|
int spl_vn_init(void);
|
|
|
|
void spl_vn_fini(void);
|
2008-03-14 00:04:01 +00:00
|
|
|
|
2018-02-07 19:49:38 +00:00
|
|
|
#define VOP_CLOSE vn_close
|
|
|
|
#define VOP_SEEK vn_seek
|
|
|
|
#define VOP_GETATTR vn_getattr
|
|
|
|
#define VOP_FSYNC vn_fsync
|
|
|
|
#define VOP_SPACE vn_space
|
|
|
|
#define VOP_PUTPAGE(vp, o, s, f, x1, x2) ((void)0)
|
|
|
|
#define vn_is_readonly(vp) 0
|
|
|
|
#define getf vn_getf
|
|
|
|
#define releasef vn_releasef
|
|
|
|
#define areleasef vn_areleasef
|
2008-03-12 20:52:46 +00:00
|
|
|
|
2009-10-01 23:06:15 +00:00
|
|
|
extern vnode_t *rootdir;
|
2008-03-07 23:07:02 +00:00
|
|
|
|
|
|
|
#endif /* SPL_VNODE_H */
|