-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 218943 b: refs/heads/master c: 85ff872 h: refs/heads/master i: 218941: 244595c 218939: ae7843d 218935: 4c6f581 218927: d6e6148 218911: 1fc4750 218879: a10a715 v: v3
- Loading branch information
Aneesh Kumar K.V
authored and
Eric Van Hensbergen
committed
Oct 28, 2010
1 parent
bf8db29
commit 43c3486
Showing
9 changed files
with
187 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 8e44a0805fc9d77475060280136aa491aa7d7060 | ||
refs/heads/master: 85ff872d3f4a62d076d698bd1fa15ca2a4d7c100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright IBM Corporation, 2010 | ||
* Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2.1 of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it would be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/fs.h> | ||
#include <net/9p/9p.h> | ||
#include <net/9p/client.h> | ||
#include <linux/slab.h> | ||
#include <linux/posix_acl_xattr.h> | ||
#include "xattr.h" | ||
#include "acl.h" | ||
|
||
static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name) | ||
{ | ||
ssize_t size; | ||
void *value = NULL; | ||
struct posix_acl *acl = NULL;; | ||
|
||
size = v9fs_fid_xattr_get(fid, name, NULL, 0); | ||
if (size > 0) { | ||
value = kzalloc(size, GFP_NOFS); | ||
if (!value) | ||
return ERR_PTR(-ENOMEM); | ||
size = v9fs_fid_xattr_get(fid, name, value, size); | ||
if (size > 0) { | ||
acl = posix_acl_from_xattr(value, size); | ||
if (IS_ERR(acl)) | ||
goto err_out; | ||
} | ||
} else if (size == -ENODATA || size == 0 || | ||
size == -ENOSYS || size == -EOPNOTSUPP) { | ||
acl = NULL; | ||
} else | ||
acl = ERR_PTR(-EIO); | ||
|
||
err_out: | ||
kfree(value); | ||
return acl; | ||
} | ||
|
||
int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) | ||
{ | ||
int retval = 0; | ||
struct posix_acl *pacl, *dacl; | ||
|
||
/* get the default/access acl values and cache them */ | ||
dacl = __v9fs_get_acl(fid, POSIX_ACL_XATTR_DEFAULT); | ||
pacl = __v9fs_get_acl(fid, POSIX_ACL_XATTR_ACCESS); | ||
|
||
if (!IS_ERR(dacl) && !IS_ERR(pacl)) { | ||
set_cached_acl(inode, ACL_TYPE_DEFAULT, dacl); | ||
set_cached_acl(inode, ACL_TYPE_ACCESS, pacl); | ||
posix_acl_release(dacl); | ||
posix_acl_release(pacl); | ||
} else | ||
retval = -EIO; | ||
|
||
return retval; | ||
} | ||
|
||
static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type) | ||
{ | ||
struct posix_acl *acl; | ||
/* | ||
* 9p Always cache the acl value when | ||
* instantiating the inode (v9fs_inode_from_fid) | ||
*/ | ||
acl = get_cached_acl(inode, type); | ||
BUG_ON(acl == ACL_NOT_CACHED); | ||
return acl; | ||
} | ||
|
||
int v9fs_check_acl(struct inode *inode, int mask) | ||
{ | ||
struct posix_acl *acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); | ||
|
||
if (IS_ERR(acl)) | ||
return PTR_ERR(acl); | ||
if (acl) { | ||
int error = posix_acl_permission(inode, acl, mask); | ||
posix_acl_release(acl); | ||
return error; | ||
} | ||
return -EAGAIN; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright IBM Corporation, 2010 | ||
* Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2.1 of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it would be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* | ||
*/ | ||
#ifndef FS_9P_ACL_H | ||
#define FS_9P_ACL_H | ||
|
||
#ifdef CONFIG_9P_FS_POSIX_ACL | ||
extern int v9fs_get_acl(struct inode *, struct p9_fid *); | ||
extern int v9fs_check_acl(struct inode *inode, int mask); | ||
#else | ||
#define v9fs_check_acl NULL | ||
static inline int v9fs_get_acl(struct inode *inode, struct p9_fid *fid) | ||
{ | ||
return 0; | ||
} | ||
#endif | ||
#endif /* FS_9P_XATTR_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters