mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "Assorted stuff; the biggest pile here is Christoph's ACL series. Plus assorted cleanups and fixes all over the place... There will be another pile later this week" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (43 commits) __dentry_path() fixes vfs: Remove second variable named error in __dentry_path vfs: Is mounted should be testing mnt_ns for NULL or error. Fix race when checking i_size on direct i/o read hfsplus: remove can_set_xattr nfsd: use get_acl and ->set_acl fs: remove generic_acl nfs: use generic posix ACL infrastructure for v3 Posix ACLs gfs2: use generic posix ACL infrastructure jfs: use generic posix ACL infrastructure xfs: use generic posix ACL infrastructure reiserfs: use generic posix ACL infrastructure ocfs2: use generic posix ACL infrastructure jffs2: use generic posix ACL infrastructure hfsplus: use generic posix ACL infrastructure f2fs: use generic posix ACL infrastructure ext2/3/4: use generic posix ACL infrastructure btrfs: use generic posix ACL infrastructure fs: make posix_acl_create more useful fs: make posix_acl_chmod more useful ...
This commit is contained in:
commit
bf3d846b78
179 changed files with 1543 additions and 3851 deletions
|
|
@ -48,18 +48,18 @@ static inline int reiserfs_acl_count(size_t size)
|
|||
|
||||
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
|
||||
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
|
||||
int reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
|
||||
int reiserfs_acl_chmod(struct inode *inode);
|
||||
int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
||||
struct inode *dir, struct dentry *dentry,
|
||||
struct inode *inode);
|
||||
int reiserfs_cache_default_acl(struct inode *dir);
|
||||
extern const struct xattr_handler reiserfs_posix_acl_default_handler;
|
||||
extern const struct xattr_handler reiserfs_posix_acl_access_handler;
|
||||
|
||||
#else
|
||||
|
||||
#define reiserfs_cache_default_acl(inode) 0
|
||||
#define reiserfs_get_acl NULL
|
||||
#define reiserfs_set_acl NULL
|
||||
|
||||
static inline int reiserfs_acl_chmod(struct inode *inode)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -260,4 +260,5 @@ const struct inode_operations reiserfs_file_inode_operations = {
|
|||
.removexattr = reiserfs_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
.set_acl = reiserfs_set_acl,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1522,6 +1522,7 @@ const struct inode_operations reiserfs_dir_inode_operations = {
|
|||
.removexattr = reiserfs_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
.set_acl = reiserfs_set_acl,
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -1538,8 +1539,6 @@ const struct inode_operations reiserfs_symlink_inode_operations = {
|
|||
.listxattr = reiserfs_listxattr,
|
||||
.removexattr = reiserfs_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -1553,4 +1552,5 @@ const struct inode_operations reiserfs_special_inode_operations = {
|
|||
.removexattr = reiserfs_removexattr,
|
||||
.permission = reiserfs_permission,
|
||||
.get_acl = reiserfs_get_acl,
|
||||
.set_acl = reiserfs_set_acl,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -419,7 +419,7 @@ int reiserfs_proc_info_init(struct super_block *sb)
|
|||
char *s;
|
||||
|
||||
/* Some block devices use /'s */
|
||||
strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
|
||||
strlcpy(b, sb->s_id, BDEVNAME_SIZE);
|
||||
s = strchr(b, '/');
|
||||
if (s)
|
||||
*s = '!';
|
||||
|
|
@ -449,7 +449,7 @@ int reiserfs_proc_info_done(struct super_block *sb)
|
|||
char *s;
|
||||
|
||||
/* Some block devices use /'s */
|
||||
strlcpy(b, reiserfs_bdevname(sb), BDEVNAME_SIZE);
|
||||
strlcpy(b, sb->s_id, BDEVNAME_SIZE);
|
||||
s = strchr(b, '/');
|
||||
if (s)
|
||||
*s = '!';
|
||||
|
|
|
|||
|
|
@ -608,14 +608,6 @@ int reiserfs_resize(struct super_block *, unsigned long);
|
|||
|
||||
#define SB_DISK_JOURNAL_HEAD(s) (SB_JOURNAL(s)->j_header_bh->)
|
||||
|
||||
/* A safe version of the "bdevname", which returns the "s_id" field of
|
||||
* a superblock or else "Null superblock" if the super block is NULL.
|
||||
*/
|
||||
static inline char *reiserfs_bdevname(struct super_block *s)
|
||||
{
|
||||
return (s == NULL) ? "Null superblock" : s->s_id;
|
||||
}
|
||||
|
||||
#define reiserfs_is_journal_aborted(journal) (unlikely (__reiserfs_is_journal_aborted (journal)))
|
||||
static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal
|
||||
*journal)
|
||||
|
|
|
|||
|
|
@ -1479,7 +1479,7 @@ static int read_super_block(struct super_block *s, int offset)
|
|||
if (!bh) {
|
||||
reiserfs_warning(s, "sh-2006",
|
||||
"bread failed (dev %s, block %lu, size %lu)",
|
||||
reiserfs_bdevname(s), offset / s->s_blocksize,
|
||||
s->s_id, offset / s->s_blocksize,
|
||||
s->s_blocksize);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1500,7 +1500,7 @@ static int read_super_block(struct super_block *s, int offset)
|
|||
if (!bh) {
|
||||
reiserfs_warning(s, "sh-2007",
|
||||
"bread failed (dev %s, block %lu, size %lu)",
|
||||
reiserfs_bdevname(s), offset / s->s_blocksize,
|
||||
s->s_id, offset / s->s_blocksize,
|
||||
s->s_blocksize);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1509,7 +1509,7 @@ static int read_super_block(struct super_block *s, int offset)
|
|||
if (sb_blocksize(rs) != s->s_blocksize) {
|
||||
reiserfs_warning(s, "sh-2011", "can't find a reiserfs "
|
||||
"filesystem on (dev %s, block %Lu, size %lu)",
|
||||
reiserfs_bdevname(s),
|
||||
s->s_id,
|
||||
(unsigned long long)bh->b_blocknr,
|
||||
s->s_blocksize);
|
||||
brelse(bh);
|
||||
|
|
@ -1825,7 +1825,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
|
|||
/* try new format (64-th 1k block), which can contain reiserfs super block */
|
||||
else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
|
||||
SWARN(silent, s, "sh-2021", "can not find reiserfs on %s",
|
||||
reiserfs_bdevname(s));
|
||||
s->s_id);
|
||||
goto error_unlocked;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#include <linux/stat.h>
|
||||
#include <linux/quotaops.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/posix_acl_xattr.h>
|
||||
|
||||
#define PRIVROOT_NAME ".reiserfs_priv"
|
||||
#define XAROOT_NAME "xattrs"
|
||||
|
|
@ -904,8 +905,8 @@ static const struct xattr_handler *reiserfs_xattr_handlers[] = {
|
|||
&reiserfs_xattr_security_handler,
|
||||
#endif
|
||||
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
|
||||
&reiserfs_posix_acl_access_handler,
|
||||
&reiserfs_posix_acl_default_handler,
|
||||
&posix_acl_access_xattr_handler,
|
||||
&posix_acl_default_xattr_handler,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,35 +11,19 @@
|
|||
#include "acl.h"
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
static int reiserfs_set_acl(struct reiserfs_transaction_handle *th,
|
||||
static int __reiserfs_set_acl(struct reiserfs_transaction_handle *th,
|
||||
struct inode *inode, int type,
|
||||
struct posix_acl *acl);
|
||||
|
||||
static int
|
||||
posix_acl_set(struct dentry *dentry, const char *name, const void *value,
|
||||
size_t size, int flags, int type)
|
||||
|
||||
int
|
||||
reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
|
||||
{
|
||||
struct inode *inode = dentry->d_inode;
|
||||
struct posix_acl *acl;
|
||||
int error, error2;
|
||||
struct reiserfs_transaction_handle th;
|
||||
size_t jcreate_blocks;
|
||||
if (!reiserfs_posixacl(inode->i_sb))
|
||||
return -EOPNOTSUPP;
|
||||
if (!inode_owner_or_capable(inode))
|
||||
return -EPERM;
|
||||
int size = acl ? posix_acl_xattr_size(acl->a_count) : 0;
|
||||
|
||||
if (value) {
|
||||
acl = posix_acl_from_xattr(&init_user_ns, value, size);
|
||||
if (IS_ERR(acl)) {
|
||||
return PTR_ERR(acl);
|
||||
} else if (acl) {
|
||||
error = posix_acl_valid(acl);
|
||||
if (error)
|
||||
goto release_and_out;
|
||||
}
|
||||
} else
|
||||
acl = NULL;
|
||||
|
||||
/* Pessimism: We can't assume that anything from the xattr root up
|
||||
* has been created. */
|
||||
|
|
@ -51,7 +35,7 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value,
|
|||
error = journal_begin(&th, inode->i_sb, jcreate_blocks);
|
||||
reiserfs_write_unlock(inode->i_sb);
|
||||
if (error == 0) {
|
||||
error = reiserfs_set_acl(&th, inode, type, acl);
|
||||
error = __reiserfs_set_acl(&th, inode, type, acl);
|
||||
reiserfs_write_lock(inode->i_sb);
|
||||
error2 = journal_end(&th, inode->i_sb, jcreate_blocks);
|
||||
reiserfs_write_unlock(inode->i_sb);
|
||||
|
|
@ -59,36 +43,13 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value,
|
|||
error = error2;
|
||||
}
|
||||
|
||||
release_and_out:
|
||||
posix_acl_release(acl);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
posix_acl_get(struct dentry *dentry, const char *name, void *buffer,
|
||||
size_t size, int type)
|
||||
{
|
||||
struct posix_acl *acl;
|
||||
int error;
|
||||
|
||||
if (!reiserfs_posixacl(dentry->d_sb))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
acl = reiserfs_get_acl(dentry->d_inode, type);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
if (acl == NULL)
|
||||
return -ENODATA;
|
||||
error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
|
||||
posix_acl_release(acl);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert from filesystem to in-memory representation.
|
||||
*/
|
||||
static struct posix_acl *posix_acl_from_disk(const void *value, size_t size)
|
||||
static struct posix_acl *reiserfs_posix_acl_from_disk(const void *value, size_t size)
|
||||
{
|
||||
const char *end = (char *)value + size;
|
||||
int n, count;
|
||||
|
|
@ -158,7 +119,7 @@ static struct posix_acl *posix_acl_from_disk(const void *value, size_t size)
|
|||
/*
|
||||
* Convert from in-memory to filesystem representation.
|
||||
*/
|
||||
static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
|
||||
static void *reiserfs_posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
|
||||
{
|
||||
reiserfs_acl_header *ext_acl;
|
||||
char *e;
|
||||
|
|
@ -221,10 +182,6 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
|||
int size;
|
||||
int retval;
|
||||
|
||||
acl = get_cached_acl(inode, type);
|
||||
if (acl != ACL_NOT_CACHED)
|
||||
return acl;
|
||||
|
||||
switch (type) {
|
||||
case ACL_TYPE_ACCESS:
|
||||
name = POSIX_ACL_XATTR_ACCESS;
|
||||
|
|
@ -257,7 +214,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
|||
} else if (retval < 0) {
|
||||
acl = ERR_PTR(retval);
|
||||
} else {
|
||||
acl = posix_acl_from_disk(value, retval);
|
||||
acl = reiserfs_posix_acl_from_disk(value, retval);
|
||||
}
|
||||
if (!IS_ERR(acl))
|
||||
set_cached_acl(inode, type, acl);
|
||||
|
|
@ -273,7 +230,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
|
|||
* BKL held [before 2.5.x]
|
||||
*/
|
||||
static int
|
||||
reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
||||
__reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
||||
int type, struct posix_acl *acl)
|
||||
{
|
||||
char *name;
|
||||
|
|
@ -281,9 +238,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
|||
size_t size = 0;
|
||||
int error;
|
||||
|
||||
if (S_ISLNK(inode->i_mode))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
switch (type) {
|
||||
case ACL_TYPE_ACCESS:
|
||||
name = POSIX_ACL_XATTR_ACCESS;
|
||||
|
|
@ -307,7 +261,7 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
|
|||
}
|
||||
|
||||
if (acl) {
|
||||
value = posix_acl_to_disk(acl, &size);
|
||||
value = reiserfs_posix_acl_to_disk(acl, &size);
|
||||
if (IS_ERR(value))
|
||||
return (int)PTR_ERR(value);
|
||||
}
|
||||
|
|
@ -343,7 +297,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
|||
struct inode *dir, struct dentry *dentry,
|
||||
struct inode *inode)
|
||||
{
|
||||
struct posix_acl *acl;
|
||||
struct posix_acl *default_acl, *acl;
|
||||
int err = 0;
|
||||
|
||||
/* ACLs only get applied to files and directories */
|
||||
|
|
@ -363,37 +317,28 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
|
|||
goto apply_umask;
|
||||
}
|
||||
|
||||
acl = reiserfs_get_acl(dir, ACL_TYPE_DEFAULT);
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (default_acl) {
|
||||
err = __reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
|
||||
default_acl);
|
||||
posix_acl_release(default_acl);
|
||||
}
|
||||
if (acl) {
|
||||
/* Copy the default ACL to the default ACL of a new directory */
|
||||
if (S_ISDIR(inode->i_mode)) {
|
||||
err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
|
||||
acl);
|
||||
if (err)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Now we reconcile the new ACL and the mode,
|
||||
potentially modifying both */
|
||||
err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* If we need an ACL.. */
|
||||
if (err > 0)
|
||||
err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
|
||||
cleanup:
|
||||
if (!err)
|
||||
err = __reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS,
|
||||
acl);
|
||||
posix_acl_release(acl);
|
||||
} else {
|
||||
apply_umask:
|
||||
/* no ACL, apply umask */
|
||||
inode->i_mode &= ~current_umask();
|
||||
}
|
||||
|
||||
return err;
|
||||
|
||||
apply_umask:
|
||||
/* no ACL, apply umask */
|
||||
inode->i_mode &= ~current_umask();
|
||||
return err;
|
||||
}
|
||||
|
||||
/* This is used to cache the default acl before a new object is created.
|
||||
|
|
@ -442,84 +387,11 @@ int reiserfs_cache_default_acl(struct inode *inode)
|
|||
*/
|
||||
int reiserfs_acl_chmod(struct inode *inode)
|
||||
{
|
||||
struct reiserfs_transaction_handle th;
|
||||
struct posix_acl *acl;
|
||||
size_t size;
|
||||
int error;
|
||||
|
||||
if (IS_PRIVATE(inode))
|
||||
return 0;
|
||||
|
||||
if (S_ISLNK(inode->i_mode))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (get_inode_sd_version(inode) == STAT_DATA_V1 ||
|
||||
!reiserfs_posixacl(inode->i_sb)) {
|
||||
!reiserfs_posixacl(inode->i_sb))
|
||||
return 0;
|
||||
}
|
||||
|
||||
acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
|
||||
if (!acl)
|
||||
return 0;
|
||||
if (IS_ERR(acl))
|
||||
return PTR_ERR(acl);
|
||||
error = posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count));
|
||||
reiserfs_write_lock(inode->i_sb);
|
||||
error = journal_begin(&th, inode->i_sb, size * 2);
|
||||
reiserfs_write_unlock(inode->i_sb);
|
||||
if (!error) {
|
||||
int error2;
|
||||
error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, acl);
|
||||
reiserfs_write_lock(inode->i_sb);
|
||||
error2 = journal_end(&th, inode->i_sb, size * 2);
|
||||
reiserfs_write_unlock(inode->i_sb);
|
||||
if (error2)
|
||||
error = error2;
|
||||
}
|
||||
posix_acl_release(acl);
|
||||
return error;
|
||||
return posix_acl_chmod(inode, inode->i_mode);
|
||||
}
|
||||
|
||||
static size_t posix_acl_access_list(struct dentry *dentry, char *list,
|
||||
size_t list_size, const char *name,
|
||||
size_t name_len, int type)
|
||||
{
|
||||
const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
|
||||
if (!reiserfs_posixacl(dentry->d_sb))
|
||||
return 0;
|
||||
if (list && size <= list_size)
|
||||
memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
const struct xattr_handler reiserfs_posix_acl_access_handler = {
|
||||
.prefix = POSIX_ACL_XATTR_ACCESS,
|
||||
.flags = ACL_TYPE_ACCESS,
|
||||
.get = posix_acl_get,
|
||||
.set = posix_acl_set,
|
||||
.list = posix_acl_access_list,
|
||||
};
|
||||
|
||||
static size_t posix_acl_default_list(struct dentry *dentry, char *list,
|
||||
size_t list_size, const char *name,
|
||||
size_t name_len, int type)
|
||||
{
|
||||
const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
|
||||
if (!reiserfs_posixacl(dentry->d_sb))
|
||||
return 0;
|
||||
if (list && size <= list_size)
|
||||
memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
const struct xattr_handler reiserfs_posix_acl_default_handler = {
|
||||
.prefix = POSIX_ACL_XATTR_DEFAULT,
|
||||
.flags = ACL_TYPE_DEFAULT,
|
||||
.get = posix_acl_get,
|
||||
.set = posix_acl_set,
|
||||
.list = posix_acl_default_list,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue