summaryrefslogtreecommitdiffstats
path: root/module/zfs/zpl_file.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-03-22 11:13:41 -0700
committerBrian Behlendorf <[email protected]>2011-03-22 12:15:54 -0700
commit81e97e21872a9c38ad66c37fafe1436ee25abee3 (patch)
treeec6c61e27476f7321ac19ba4bd1c0cd5b155dd43 /module/zfs/zpl_file.c
parentbdf4328b04544ac3759d689d0a68e514b6df1025 (diff)
Linux 2.6.29 compat, credentials
As of Linux 2.6.29 a clean credential API was added to the Linux kernel. Previously the credential was embedded in the task_struct. Because the SPL already has considerable support for handling this API change the ZPL code has been updated to use the Solaris credential API.
Diffstat (limited to 'module/zfs/zpl_file.c')
-rw-r--r--module/zfs/zpl_file.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
index d76e62d43..c8a3fedb7 100644
--- a/module/zfs/zpl_file.c
+++ b/module/zfs/zpl_file.c
@@ -32,12 +32,12 @@
static int
zpl_open(struct inode *ip, struct file *filp)
{
- cred_t *cr;
+ cred_t *cr = CRED();
int error;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
error = -zfs_open(ip, filp->f_mode, filp->f_flags, cr);
- put_cred(cr);
+ crfree(cr);
ASSERT3S(error, <=, 0);
if (error)
@@ -49,12 +49,12 @@ zpl_open(struct inode *ip, struct file *filp)
static int
zpl_release(struct inode *ip, struct file *filp)
{
- cred_t *cr;
+ cred_t *cr = CRED();
int error;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
error = -zfs_close(ip, filp->f_flags, cr);
- put_cred(cr);
+ crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
@@ -64,13 +64,13 @@ static int
zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct dentry *dentry = filp->f_path.dentry;
- cred_t *cr;
+ cred_t *cr = CRED();
int error;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
error = -zfs_readdir(dentry->d_inode, dirent, filldir,
&filp->f_pos, cr);
- put_cred(cr);
+ crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
@@ -78,12 +78,12 @@ zpl_readdir(struct file *filp, void *dirent, filldir_t filldir)
ZPL_FSYNC_PROTO(zpl_fsync, filp, unused_dentry, datasync)
{
- cred_t *cr;
+ cred_t *cr = CRED();
int error;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
error = -zfs_fsync(filp->f_path.dentry->d_inode, datasync, cr);
- put_cred(cr);
+ crfree(cr);
ASSERT3S(error, <=, 0);
return (error);
@@ -117,13 +117,13 @@ zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
static ssize_t
zpl_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
{
- cred_t *cr;
+ cred_t *cr = CRED();
ssize_t read;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
read = zpl_read_common(filp->f_mapping->host, buf, len, *ppos,
UIO_USERSPACE, filp->f_flags, cr);
- put_cred(cr);
+ crfree(cr);
if (read < 0)
return (read);
@@ -160,13 +160,13 @@ zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
static ssize_t
zpl_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
{
- cred_t *cr;
+ cred_t *cr = CRED();
ssize_t wrote;
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
wrote = zpl_write_common(filp->f_mapping->host, buf, len, *ppos,
UIO_USERSPACE, filp->f_flags, cr);
- put_cred(cr);
+ crfree(cr);
if (wrote < 0)
return (wrote);
@@ -250,7 +250,7 @@ zpl_readpage(struct file *filp, struct page *pp)
struct inode *ip;
loff_t off, i_size;
size_t len, wrote;
- cred_t *cr;
+ cred_t *cr = CRED();
void *pb;
int error = 0;
@@ -260,7 +260,7 @@ zpl_readpage(struct file *filp, struct page *pp)
i_size = i_size_read(ip);
ASSERT3S(off, <, i_size);
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
len = MIN(PAGE_CACHE_SIZE, i_size - off);
pb = kmap(pp);
@@ -274,7 +274,7 @@ zpl_readpage(struct file *filp, struct page *pp)
memset(pb + len, 0, PAGE_CACHE_SIZE - len);
kunmap(pp);
- put_cred(cr);
+ crfree(cr);
if (error) {
SetPageError(pp);
@@ -306,7 +306,7 @@ zpl_writepage(struct page *pp, struct writeback_control *wbc)
struct inode *ip;
loff_t off, i_size;
size_t len, read;
- cred_t *cr;
+ cred_t *cr = CRED();
void *pb;
int error = 0;
@@ -315,7 +315,7 @@ zpl_writepage(struct page *pp, struct writeback_control *wbc)
off = page_offset(pp);
i_size = i_size_read(ip);
- cr = (cred_t *)get_current_cred();
+ crhold(cr);
len = MIN(PAGE_CACHE_SIZE, i_size - off);
pb = kmap(pp);
@@ -326,7 +326,7 @@ zpl_writepage(struct page *pp, struct writeback_control *wbc)
error = -EIO;
kunmap(pp);
- put_cred(cr);
+ crfree(cr);
if (error) {
SetPageError(pp);