4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2011, Lawrence Livermore National Security, LLC.
26 #include <sys/zfs_vfsops.h>
27 #include <sys/zfs_vnops.h>
28 #include <sys/zfs_znode.h>
33 zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
35 struct dentry *dentry = filp->f_path.dentry;
39 cr = (cred_t *)get_current_cred();
40 error = -zfs_readdir(dentry->d_inode, dirent, filldir,
43 ASSERT3S(error, <=, 0);
49 zpl_fsync(struct file *filp, struct dentry *dentry, int datasync)
54 cr = (cred_t *)get_current_cred();
55 error = -zfs_fsync(filp->f_path.dentry->d_inode, datasync, cr);
57 ASSERT3S(error, <=, 0);
63 zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
64 uio_seg_t segment, int flags, cred_t *cr)
70 iov.iov_base = (void *)buf;
76 uio.uio_loffset = pos;
77 uio.uio_limit = MAXOFFSET_T;
78 uio.uio_segflg = segment;
80 error = -zfs_read(ip, &uio, flags, cr);
84 return (len - uio.uio_resid);
88 zpl_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
93 cr = (cred_t *)get_current_cred();
94 read = zpl_read_common(filp->f_mapping->host, buf, len, *ppos,
95 UIO_USERSPACE, filp->f_flags, cr);
106 zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
107 uio_seg_t segment, int flags, cred_t *cr)
113 iov.iov_base = (void *)buf;
119 uio.uio_loffset = pos;
120 uio.uio_limit = MAXOFFSET_T;
121 uio.uio_segflg = segment;
123 error = -zfs_write(ip, &uio, flags, cr);
127 return (len - uio.uio_resid);
131 zpl_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
136 cr = (cred_t *)get_current_cred();
137 wrote = zpl_write_common(filp->f_mapping->host, buf, len, *ppos,
138 UIO_USERSPACE, filp->f_flags, cr);
148 const struct address_space_operations zpl_address_space_operations = {
150 .readpage = zpl_readpage,
151 .writepage = zpl_writepage,
152 .direct_IO = zpl_direct_IO,
156 const struct file_operations zpl_file_operations = {
157 .open = generic_file_open,
158 .llseek = generic_file_llseek,
159 .read = zpl_read, /* do_sync_read */
160 .write = zpl_write, /* do_sync_write */
161 .readdir = zpl_readdir,
162 .mmap = generic_file_mmap,
164 .aio_read = NULL, /* generic_file_aio_read */
165 .aio_write = NULL, /* generic_file_aio_write */
168 const struct file_operations zpl_dir_file_operations = {
169 .llseek = generic_file_llseek,
170 .read = generic_read_dir,
171 .readdir = zpl_readdir,