]> Pileus Git - ~andy/linux/commitdiff
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Jan 2014 16:38:04 +0000 (08:38 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 28 Jan 2014 16:38:04 +0000 (08:38 -0800)
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
  ...

179 files changed:
arch/blackfin/kernel/setup.c
arch/cris/arch-v32/drivers/axisflashmap.c
fs/9p/acl.c
fs/Kconfig
fs/Makefile
fs/affs/super.c
fs/afs/internal.h
fs/afs/proc.c
fs/befs/linuxvfs.c
fs/btrfs/acl.c
fs/btrfs/ctree.h
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/xattr.c
fs/btrfs/xattr.h
fs/cramfs/inode.c
fs/cramfs/internal.h [moved from include/linux/cramfs_fs.h with 70% similarity]
fs/cramfs/uncompress.c
fs/dcache.c
fs/ecryptfs/inode.c
fs/efs/super.c
fs/eventfd.c
fs/ext2/acl.c
fs/ext2/acl.h
fs/ext2/file.c
fs/ext2/inode.c
fs/ext2/namei.c
fs/ext2/xattr.c
fs/ext2/xattr.h
fs/ext3/acl.c
fs/ext3/acl.h
fs/ext3/file.c
fs/ext3/inode.c
fs/ext3/namei.c
fs/ext3/xattr.c
fs/ext3/xattr.h
fs/ext4/acl.c
fs/ext4/acl.h
fs/ext4/file.c
fs/ext4/inode.c
fs/ext4/namei.c
fs/ext4/xattr.c
fs/ext4/xattr.h
fs/f2fs/acl.c
fs/f2fs/acl.h
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/namei.c
fs/f2fs/xattr.c
fs/f2fs/xattr.h
fs/file.c
fs/fuse/file.c
fs/generic_acl.c [deleted file]
fs/gfs2/acl.c
fs/gfs2/acl.h
fs/gfs2/inode.c
fs/gfs2/xattr.c
fs/hfsplus/acl.h
fs/hfsplus/dir.c
fs/hfsplus/inode.c
fs/hfsplus/posix_acl.c
fs/hfsplus/xattr.c
fs/hfsplus/xattr.h
fs/jffs2/acl.c
fs/jffs2/acl.h
fs/jffs2/dir.c
fs/jffs2/file.c
fs/jffs2/fs.c
fs/jffs2/symlink.c
fs/jffs2/xattr.c
fs/jfs/acl.c
fs/jfs/file.c
fs/jfs/jfs_acl.h
fs/jfs/jfs_xattr.h
fs/jfs/namei.c
fs/jfs/super.c
fs/jfs/xattr.c
fs/mount.h
fs/namei.c
fs/nfs/inode.c
fs/nfs/nfs3acl.c
fs/nfs/nfs3proc.c
fs/nfs/nfs3super.c
fs/nfsd/acl.h
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs4acl.c
fs/nfsd/nfs4proc.c
fs/nfsd/vfs.c
fs/nfsd/vfs.h
fs/nls/mac-celtic.c
fs/nls/mac-centeuro.c
fs/nls/mac-croatian.c
fs/nls/mac-cyrillic.c
fs/nls/mac-gaelic.c
fs/nls/mac-greek.c
fs/nls/mac-iceland.c
fs/nls/mac-inuit.c
fs/nls/mac-roman.c
fs/nls/mac-romanian.c
fs/nls/mac-turkish.c
fs/nls/nls_ascii.c
fs/nls/nls_base.c
fs/nls/nls_cp1250.c
fs/nls/nls_cp1251.c
fs/nls/nls_cp1255.c
fs/nls/nls_cp437.c
fs/nls/nls_cp737.c
fs/nls/nls_cp775.c
fs/nls/nls_cp850.c
fs/nls/nls_cp852.c
fs/nls/nls_cp855.c
fs/nls/nls_cp857.c
fs/nls/nls_cp860.c
fs/nls/nls_cp861.c
fs/nls/nls_cp862.c
fs/nls/nls_cp863.c
fs/nls/nls_cp864.c
fs/nls/nls_cp865.c
fs/nls/nls_cp866.c
fs/nls/nls_cp869.c
fs/nls/nls_cp874.c
fs/nls/nls_cp932.c
fs/nls/nls_cp936.c
fs/nls/nls_cp949.c
fs/nls/nls_cp950.c
fs/nls/nls_euc-jp.c
fs/nls/nls_iso8859-1.c
fs/nls/nls_iso8859-13.c
fs/nls/nls_iso8859-14.c
fs/nls/nls_iso8859-15.c
fs/nls/nls_iso8859-2.c
fs/nls/nls_iso8859-3.c
fs/nls/nls_iso8859-4.c
fs/nls/nls_iso8859-5.c
fs/nls/nls_iso8859-6.c
fs/nls/nls_iso8859-7.c
fs/nls/nls_iso8859-9.c
fs/nls/nls_koi8-r.c
fs/nls/nls_koi8-ru.c
fs/nls/nls_koi8-u.c
fs/nls/nls_utf8.c
fs/ocfs2/acl.c
fs/ocfs2/acl.h
fs/ocfs2/file.c
fs/ocfs2/namei.c
fs/ocfs2/refcounttree.c
fs/ocfs2/xattr.c
fs/ocfs2/xattr.h
fs/posix_acl.c
fs/qnx4/inode.c
fs/qnx4/qnx4.h
fs/reiserfs/acl.h
fs/reiserfs/file.c
fs/reiserfs/namei.c
fs/reiserfs/procfs.c
fs/reiserfs/reiserfs.h
fs/reiserfs/super.c
fs/reiserfs/xattr.c
fs/reiserfs/xattr_acl.c
fs/xattr_acl.c [deleted file]
fs/xfs/xfs_acl.c
fs/xfs/xfs_acl.h
fs/xfs/xfs_iops.c
fs/xfs/xfs_iops.h
fs/xfs/xfs_xattr.c
include/linux/cramfs_fs_sb.h [deleted file]
include/linux/fdtable.h
include/linux/fs.h
include/linux/generic_acl.h [deleted file]
include/linux/nfs_fs.h
include/linux/nls.h
include/linux/posix_acl.h
include/linux/posix_acl_xattr.h
include/linux/rcupdate.h
init/do_mounts_rd.c
kernel/rcu/update.c
mm/filemap.c
mm/shmem.c

index 3961930421274b9f89e47f691554c6dbad61ecb6..4f424ae3b36de8225e5bee3977bde03a82548bb4 100644 (file)
@@ -17,7 +17,7 @@
 #ifdef CONFIG_MTD_UCLINUX
 #include <linux/mtd/map.h>
 #include <linux/ext2_fs.h>
-#include <linux/cramfs_fs.h>
+#include <uapi/linux/cramfs_fs.h>
 #include <linux/romfs_fs.h>
 #endif
 
index 1b6ad6247204c0b9d09f63f7e4731aaf70cb83cd..28dd77144e8fe8e24a0ac94cd309b5ac1587aac4 100644 (file)
@@ -24,8 +24,6 @@
 #include <linux/mtd/mtdram.h>
 #include <linux/mtd/partitions.h>
 
-#include <linux/cramfs_fs.h>
-
 #include <asm/axisflashmap.h>
 #include <asm/mmu.h>
 
index 7af425f53beef91a6d21dc86b76e161ff7ed1696..8482f2d1160667ba1255ee5b48434287bc51da65 100644 (file)
@@ -156,7 +156,7 @@ int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid)
                return -EOPNOTSUPP;
        acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
        if (acl) {
-               retval = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+               retval = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
                if (retval)
                        return retval;
                set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
@@ -200,7 +200,7 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep,
        if (acl) {
                if (S_ISDIR(mode))
                        *dpacl = posix_acl_dup(acl);
-               retval = posix_acl_create(&acl, GFP_NOFS, &mode);
+               retval = __posix_acl_create(&acl, GFP_NOFS, &mode);
                if (retval < 0)
                        return retval;
                if (retval > 0)
index c229f828eb012ea32a13c306cf1953ae85e3ca2a..7385e54be4b9adbdd8a4c2d0ed3cafd3b516820a 100644 (file)
@@ -68,10 +68,6 @@ source "fs/quota/Kconfig"
 source "fs/autofs4/Kconfig"
 source "fs/fuse/Kconfig"
 
-config GENERIC_ACL
-       bool
-       select FS_POSIX_ACL
-
 menu "Caches"
 
 source "fs/fscache/Kconfig"
@@ -119,7 +115,7 @@ config TMPFS_POSIX_ACL
        bool "Tmpfs POSIX Access Control Lists"
        depends on TMPFS
        select TMPFS_XATTR
-       select GENERIC_ACL
+       select FS_POSIX_ACL
        help
          POSIX Access Control Lists (ACLs) support additional access rights
          for users and groups beyond the standard owner/group/world scheme,
index 39a824f44e7c17c807988ca970a2eefbe2113ece..47ac07bb4acc6b44b318776c44e7a6cd7bf79113 100644 (file)
@@ -42,9 +42,8 @@ obj-$(CONFIG_BINFMT_SOM)      += binfmt_som.o
 obj-$(CONFIG_BINFMT_FLAT)      += binfmt_flat.o
 
 obj-$(CONFIG_FS_MBCACHE)       += mbcache.o
-obj-$(CONFIG_FS_POSIX_ACL)     += posix_acl.o xattr_acl.o
+obj-$(CONFIG_FS_POSIX_ACL)     += posix_acl.o
 obj-$(CONFIG_NFS_COMMON)       += nfs_common/
-obj-$(CONFIG_GENERIC_ACL)      += generic_acl.o
 obj-$(CONFIG_COREDUMP)         += coredump.o
 obj-$(CONFIG_SYSCTL)           += drop_caches.o
 
index 45161a832bbc9e4aa2d7f6b72a950273e0af7062..d098731b82ffa794853e66ff0bcb4e05aa59fcbc 100644 (file)
@@ -49,11 +49,6 @@ affs_put_super(struct super_block *sb)
        pr_debug("AFFS: put_super()\n");
 
        cancel_delayed_work_sync(&sbi->sb_work);
-       kfree(sbi->s_prefix);
-       affs_free_bitmap(sb);
-       affs_brelse(sbi->s_root_bh);
-       kfree(sbi);
-       sb->s_fs_info = NULL;
 }
 
 static int
@@ -316,7 +311,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
        unsigned long            mount_flags;
        int                      tmp_flags;     /* fix remount prototype... */
        u8                       sig[4];
-       int                      ret = -EINVAL;
+       int                      ret;
 
        save_mount_options(sb, data);
 
@@ -412,17 +407,19 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
        if (!silent)
                printk(KERN_ERR "AFFS: No valid root block on device %s\n",
                        sb->s_id);
-       goto out_error;
+       return -EINVAL;
 
        /* N.B. after this point bh must be released */
 got_root:
+       /* Keep super block in cache */
+       sbi->s_root_bh = root_bh;
        root_block = sbi->s_root_block;
 
        /* Find out which kind of FS we have */
        boot_bh = sb_bread(sb, 0);
        if (!boot_bh) {
                printk(KERN_ERR "AFFS: Cannot read boot block\n");
-               goto out_error;
+               return -EINVAL;
        }
        memcpy(sig, boot_bh->b_data, 4);
        brelse(boot_bh);
@@ -471,7 +468,7 @@ got_root:
                default:
                        printk(KERN_ERR "AFFS: Unknown filesystem on device %s: %08X\n",
                                sb->s_id, chksum);
-                       goto out_error;
+                       return -EINVAL;
        }
 
        if (mount_flags & SF_VERBOSE) {
@@ -488,22 +485,17 @@ got_root:
        if (sbi->s_flags & SF_OFS)
                sbi->s_data_blksize -= 24;
 
-       /* Keep super block in cache */
-       sbi->s_root_bh = root_bh;
-       /* N.B. after this point s_root_bh must be released */
-
        tmp_flags = sb->s_flags;
-       if (affs_init_bitmap(sb, &tmp_flags))
-               goto out_error;
+       ret = affs_init_bitmap(sb, &tmp_flags);
+       if (ret)
+               return ret;
        sb->s_flags = tmp_flags;
 
        /* set up enough so that it can read an inode */
 
        root_inode = affs_iget(sb, root_block);
-       if (IS_ERR(root_inode)) {
-               ret = PTR_ERR(root_inode);
-               goto out_error;
-       }
+       if (IS_ERR(root_inode))
+               return PTR_ERR(root_inode);
 
        if (AFFS_SB(sb)->s_flags & SF_INTL)
                sb->s_d_op = &affs_intl_dentry_operations;
@@ -513,22 +505,11 @@ got_root:
        sb->s_root = d_make_root(root_inode);
        if (!sb->s_root) {
                printk(KERN_ERR "AFFS: Get root inode failed\n");
-               goto out_error;
+               return -ENOMEM;
        }
 
        pr_debug("AFFS: s_flags=%lX\n",sb->s_flags);
        return 0;
-
-       /*
-        * Begin the cascaded cleanup ...
-        */
-out_error:
-       kfree(sbi->s_bitmap);
-       affs_brelse(root_bh);
-       kfree(sbi->s_prefix);
-       kfree(sbi);
-       sb->s_fs_info = NULL;
-       return ret;
 }
 
 static int
@@ -615,11 +596,23 @@ static struct dentry *affs_mount(struct file_system_type *fs_type,
        return mount_bdev(fs_type, flags, dev_name, data, affs_fill_super);
 }
 
+static void affs_kill_sb(struct super_block *sb)
+{
+       struct affs_sb_info *sbi = AFFS_SB(sb);
+       kill_block_super(sb);
+       if (sbi) {
+               affs_free_bitmap(sb);
+               affs_brelse(sbi->s_root_bh);
+               kfree(sbi->s_prefix);
+               kfree(sbi);
+       }
+}
+
 static struct file_system_type affs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "affs",
        .mount          = affs_mount,
-       .kill_sb        = kill_block_super,
+       .kill_sb        = affs_kill_sb,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("affs");
index a306bb6d88d9937badc2a1df1462d3bb0f469829..6621f800812287f6f0fc27cdc7f71a2a32287af2 100644 (file)
@@ -195,7 +195,6 @@ struct afs_cell {
        struct list_head        link;           /* main cell list link */
        struct key              *anonymous_key; /* anonymous user key for this cell */
        struct list_head        proc_link;      /* /proc cell list link */
-       struct proc_dir_entry   *proc_dir;      /* /proc dir for this cell */
 #ifdef CONFIG_AFS_FSCACHE
        struct fscache_cookie   *cache;         /* caching cookie */
 #endif
index 526e4bbbde59e4936f91367101adac8c7373053e..bddc5120ed4089caa19bef3c2420725c63ef7f37 100644 (file)
@@ -41,11 +41,8 @@ static const struct file_operations afs_proc_cells_fops = {
        .write          = afs_proc_cells_write,
        .llseek         = seq_lseek,
        .release        = seq_release,
-       .owner          = THIS_MODULE,
 };
 
-static int afs_proc_rootcell_open(struct inode *inode, struct file *file);
-static int afs_proc_rootcell_release(struct inode *inode, struct file *file);
 static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
                                      size_t size, loff_t *_pos);
 static ssize_t afs_proc_rootcell_write(struct file *file,
@@ -53,17 +50,12 @@ static ssize_t afs_proc_rootcell_write(struct file *file,
                                       size_t size, loff_t *_pos);
 
 static const struct file_operations afs_proc_rootcell_fops = {
-       .open           = afs_proc_rootcell_open,
        .read           = afs_proc_rootcell_read,
        .write          = afs_proc_rootcell_write,
        .llseek         = no_llseek,
-       .release        = afs_proc_rootcell_release,
-       .owner          = THIS_MODULE,
 };
 
 static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file);
-static int afs_proc_cell_volumes_release(struct inode *inode,
-                                        struct file *file);
 static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);
 static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
                                        loff_t *pos);
@@ -81,14 +73,11 @@ static const struct file_operations afs_proc_cell_volumes_fops = {
        .open           = afs_proc_cell_volumes_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
-       .release        = afs_proc_cell_volumes_release,
-       .owner          = THIS_MODULE,
+       .release        = seq_release,
 };
 
 static int afs_proc_cell_vlservers_open(struct inode *inode,
                                        struct file *file);
-static int afs_proc_cell_vlservers_release(struct inode *inode,
-                                          struct file *file);
 static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);
 static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
                                          loff_t *pos);
@@ -106,13 +95,10 @@ static const struct file_operations afs_proc_cell_vlservers_fops = {
        .open           = afs_proc_cell_vlservers_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
-       .release        = afs_proc_cell_vlservers_release,
-       .owner          = THIS_MODULE,
+       .release        = seq_release,
 };
 
 static int afs_proc_cell_servers_open(struct inode *inode, struct file *file);
-static int afs_proc_cell_servers_release(struct inode *inode,
-                                        struct file *file);
 static void *afs_proc_cell_servers_start(struct seq_file *p, loff_t *pos);
 static void *afs_proc_cell_servers_next(struct seq_file *p, void *v,
                                        loff_t *pos);
@@ -130,8 +116,7 @@ static const struct file_operations afs_proc_cell_servers_fops = {
        .open           = afs_proc_cell_servers_open,
        .read           = seq_read,
        .llseek         = seq_lseek,
-       .release        = afs_proc_cell_servers_release,
-       .owner          = THIS_MODULE,
+       .release        = seq_release,
 };
 
 /*
@@ -139,29 +124,21 @@ static const struct file_operations afs_proc_cell_servers_fops = {
  */
 int afs_proc_init(void)
 {
-       struct proc_dir_entry *p;
-
        _enter("");
 
        proc_afs = proc_mkdir("fs/afs", NULL);
        if (!proc_afs)
                goto error_dir;
 
-       p = proc_create("cells", 0, proc_afs, &afs_proc_cells_fops);
-       if (!p)
-               goto error_cells;
-
-       p = proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops);
-       if (!p)
-               goto error_rootcell;
+       if (!proc_create("cells", 0, proc_afs, &afs_proc_cells_fops) ||
+           !proc_create("rootcell", 0, proc_afs, &afs_proc_rootcell_fops))
+               goto error_tree;
 
        _leave(" = 0");
        return 0;
 
-error_rootcell:
-       remove_proc_entry("cells", proc_afs);
-error_cells:
-       remove_proc_entry("fs/afs", NULL);
+error_tree:
+       remove_proc_subtree("fs/afs", NULL);
 error_dir:
        _leave(" = -ENOMEM");
        return -ENOMEM;
@@ -172,9 +149,7 @@ error_dir:
  */
 void afs_proc_cleanup(void)
 {
-       remove_proc_entry("rootcell", proc_afs);
-       remove_proc_entry("cells", proc_afs);
-       remove_proc_entry("fs/afs", NULL);
+       remove_proc_subtree("fs/afs", NULL);
 }
 
 /*
@@ -319,19 +294,6 @@ inval:
        goto done;
 }
 
-/*
- * Stubs for /proc/fs/afs/rootcell
- */
-static int afs_proc_rootcell_open(struct inode *inode, struct file *file)
-{
-       return 0;
-}
-
-static int afs_proc_rootcell_release(struct inode *inode, struct file *file)
-{
-       return 0;
-}
-
 static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
                                      size_t size, loff_t *_pos)
 {
@@ -387,38 +349,27 @@ nomem:
  */
 int afs_proc_cell_setup(struct afs_cell *cell)
 {
-       struct proc_dir_entry *p;
+       struct proc_dir_entry *dir;
 
        _enter("%p{%s}", cell, cell->name);
 
-       cell->proc_dir = proc_mkdir(cell->name, proc_afs);
-       if (!cell->proc_dir)
+       dir = proc_mkdir(cell->name, proc_afs);
+       if (!dir)
                goto error_dir;
 
-       p = proc_create_data("servers", 0, cell->proc_dir,
-                            &afs_proc_cell_servers_fops, cell);
-       if (!p)
-               goto error_servers;
-
-       p = proc_create_data("vlservers", 0, cell->proc_dir,
-                            &afs_proc_cell_vlservers_fops, cell);
-       if (!p)
-               goto error_vlservers;
-
-       p = proc_create_data("volumes", 0, cell->proc_dir,
-                            &afs_proc_cell_volumes_fops, cell);
-       if (!p)
-               goto error_volumes;
+       if (!proc_create_data("servers", 0, dir,
+                            &afs_proc_cell_servers_fops, cell) ||
+           !proc_create_data("vlservers", 0, dir,
+                            &afs_proc_cell_vlservers_fops, cell) ||
+           !proc_create_data("volumes", 0, dir,
+                            &afs_proc_cell_volumes_fops, cell))
+               goto error_tree;
 
        _leave(" = 0");
        return 0;
 
-error_volumes:
-       remove_proc_entry("vlservers", cell->proc_dir);
-error_vlservers:
-       remove_proc_entry("servers", cell->proc_dir);
-error_servers:
-       remove_proc_entry(cell->name, proc_afs);
+error_tree:
+       remove_proc_subtree(cell->name, proc_afs);
 error_dir:
        _leave(" = -ENOMEM");
        return -ENOMEM;
@@ -431,10 +382,7 @@ void afs_proc_cell_remove(struct afs_cell *cell)
 {
        _enter("");
 
-       remove_proc_entry("volumes", cell->proc_dir);
-       remove_proc_entry("vlservers", cell->proc_dir);
-       remove_proc_entry("servers", cell->proc_dir);
-       remove_proc_entry(cell->name, proc_afs);
+       remove_proc_subtree(cell->name, proc_afs);
 
        _leave("");
 }
@@ -462,14 +410,6 @@ static int afs_proc_cell_volumes_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-/*
- * close the file and release the ref to the cell
- */
-static int afs_proc_cell_volumes_release(struct inode *inode, struct file *file)
-{
-       return seq_release(inode, file);
-}
-
 /*
  * set up the iterator to start reading from the cells list and return the
  * first item
@@ -568,15 +508,6 @@ static int afs_proc_cell_vlservers_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-/*
- * close the file and release the ref to the cell
- */
-static int afs_proc_cell_vlservers_release(struct inode *inode,
-                                          struct file *file)
-{
-       return seq_release(inode, file);
-}
-
 /*
  * set up the iterator to start reading from the cells list and return the
  * first item
@@ -672,15 +603,6 @@ static int afs_proc_cell_servers_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-/*
- * close the file and release the ref to the cell
- */
-static int afs_proc_cell_servers_release(struct inode *inode,
-                                        struct file *file)
-{
-       return seq_release(inode, file);
-}
-
 /*
  * set up the iterator to start reading from the cells list and return the
  * first item
index daa15d6ba45077755d2bc859cfffb44f6a82bfd0..845d2d690ce2dc2becddef70041a3e6b69440d62 100644 (file)
@@ -324,8 +324,8 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
        befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
 
        inode = iget_locked(sb, ino);
-       if (IS_ERR(inode))
-               return inode;
+       if (!inode)
+               return ERR_PTR(-ENOMEM);
        if (!(inode->i_state & I_NEW))
                return inode;
 
index 0890c83643e944f69e43a22f4151e381e7503f04..ff9b3995d45394a607a7973458de3383ccd920ff 100644 (file)
@@ -35,13 +35,6 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
        char *value = NULL;
        struct posix_acl *acl;
 
-       if (!IS_POSIXACL(inode))
-               return NULL;
-
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name = POSIX_ACL_XATTR_ACCESS;
@@ -76,31 +69,10 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
        return acl;
 }
 
-static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name,
-               void *value, size_t size, int type)
-{
-       struct posix_acl *acl;
-       int ret = 0;
-
-       if (!IS_POSIXACL(dentry->d_inode))
-               return -EOPNOTSUPP;
-
-       acl = btrfs_get_acl(dentry->d_inode, type);
-
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (acl == NULL)
-               return -ENODATA;
-       ret = posix_acl_to_xattr(&init_user_ns, acl, value, size);
-       posix_acl_release(acl);
-
-       return ret;
-}
-
 /*
  * Needs to be called with fs_mutex held
  */
-static int btrfs_set_acl(struct btrfs_trans_handle *trans,
+static int __btrfs_set_acl(struct btrfs_trans_handle *trans,
                         struct inode *inode, struct posix_acl *acl, int type)
 {
        int ret, size = 0;
@@ -158,35 +130,9 @@ out:
        return ret;
 }
 
-static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags, int type)
+int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-       int ret;
-       struct posix_acl *acl = NULL;
-
-       if (!inode_owner_or_capable(dentry->d_inode))
-               return -EPERM;
-
-       if (!IS_POSIXACL(dentry->d_inode))
-               return -EOPNOTSUPP;
-
-       if (value) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-
-               if (acl) {
-                       ret = posix_acl_valid(acl);
-                       if (ret)
-                               goto out;
-               }
-       }
-
-       ret = btrfs_set_acl(NULL, dentry->d_inode, acl, type);
-out:
-       posix_acl_release(acl);
-
-       return ret;
+       return __btrfs_set_acl(NULL, inode, acl, type);
 }
 
 /*
@@ -197,83 +143,31 @@ out:
 int btrfs_init_acl(struct btrfs_trans_handle *trans,
                   struct inode *inode, struct inode *dir)
 {
-       struct posix_acl *acl = NULL;
+       struct posix_acl *default_acl, *acl;
        int ret = 0;
 
        /* this happens with subvols */
        if (!dir)
                return 0;
 
-       if (!S_ISLNK(inode->i_mode)) {
-               if (IS_POSIXACL(dir)) {
-                       acl = btrfs_get_acl(dir, ACL_TYPE_DEFAULT);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               }
+       ret = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (ret)
+               return ret;
 
-               if (!acl)
-                       inode->i_mode &= ~current_umask();
+       if (default_acl) {
+               ret = __btrfs_set_acl(trans, inode, default_acl,
+                                     ACL_TYPE_DEFAULT);
+               posix_acl_release(default_acl);
        }
 
-       if (IS_POSIXACL(dir) && acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       ret = btrfs_set_acl(trans, inode, acl,
-                                           ACL_TYPE_DEFAULT);
-                       if (ret)
-                               goto failed;
-               }
-               ret = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
-               if (ret < 0)
-                       return ret;
-
-               if (ret > 0) {
-                       /* we need an acl */
-                       ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS);
-               } else if (ret < 0) {
-                       cache_no_acl(inode);
-               }
-       } else {
-               cache_no_acl(inode);
+       if (acl) {
+               if (!ret)
+                       ret = __btrfs_set_acl(trans, inode, acl,
+                                             ACL_TYPE_ACCESS);
+               posix_acl_release(acl);
        }
-failed:
-       posix_acl_release(acl);
-
-       return ret;
-}
 
-int btrfs_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
-       int ret = 0;
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       if (!IS_POSIXACL(inode))
-               return 0;
-
-       acl = btrfs_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR_OR_NULL(acl))
-               return PTR_ERR(acl);
-
-       ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (ret)
-               return ret;
-       ret = btrfs_set_acl(NULL, inode, acl, ACL_TYPE_ACCESS);
-       posix_acl_release(acl);
+       if (!default_acl && !acl)
+               cache_no_acl(inode);
        return ret;
 }
-
-const struct xattr_handler btrfs_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .get    = btrfs_xattr_acl_get,
-       .set    = btrfs_xattr_acl_set,
-};
-
-const struct xattr_handler btrfs_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .get    = btrfs_xattr_acl_get,
-       .set    = btrfs_xattr_acl_set,
-};
index 54ab86127f7af49500f6a0bf2bf4b63cd6074c40..7506825211a29d44772cdcd93732875258281daf 100644 (file)
@@ -3899,20 +3899,17 @@ do {                                                                    \
 /* acl.c */
 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
 struct posix_acl *btrfs_get_acl(struct inode *inode, int type);
+int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 int btrfs_init_acl(struct btrfs_trans_handle *trans,
                   struct inode *inode, struct inode *dir);
-int btrfs_acl_chmod(struct inode *inode);
 #else
 #define btrfs_get_acl NULL
+#define btrfs_set_acl NULL
 static inline int btrfs_init_acl(struct btrfs_trans_handle *trans,
                                 struct inode *inode, struct inode *dir)
 {
        return 0;
 }
-static inline int btrfs_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
 #endif
 
 /* relocation.c */
index 471a4f7f4044d4171f823e996ff89b68d237abb0..514b291b135405dd1fbd21f9a8e4edc1b161f5af 100644 (file)
@@ -4468,7 +4468,7 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
                err = btrfs_dirty_inode(inode);
 
                if (!err && attr->ia_valid & ATTR_MODE)
-                       err = btrfs_acl_chmod(inode);
+                       err = posix_acl_chmod(inode, inode->i_mode);
        }
 
        return err;
@@ -8653,12 +8653,14 @@ static const struct inode_operations btrfs_dir_inode_operations = {
        .removexattr    = btrfs_removexattr,
        .permission     = btrfs_permission,
        .get_acl        = btrfs_get_acl,
+       .set_acl        = btrfs_set_acl,
        .update_time    = btrfs_update_time,
 };
 static const struct inode_operations btrfs_dir_ro_inode_operations = {
        .lookup         = btrfs_lookup,
        .permission     = btrfs_permission,
        .get_acl        = btrfs_get_acl,
+       .set_acl        = btrfs_set_acl,
        .update_time    = btrfs_update_time,
 };
 
@@ -8728,6 +8730,7 @@ static const struct inode_operations btrfs_file_inode_operations = {
        .permission     = btrfs_permission,
        .fiemap         = btrfs_fiemap,
        .get_acl        = btrfs_get_acl,
+       .set_acl        = btrfs_set_acl,
        .update_time    = btrfs_update_time,
 };
 static const struct inode_operations btrfs_special_inode_operations = {
@@ -8739,6 +8742,7 @@ static const struct inode_operations btrfs_special_inode_operations = {
        .listxattr      = btrfs_listxattr,
        .removexattr    = btrfs_removexattr,
        .get_acl        = btrfs_get_acl,
+       .set_acl        = btrfs_set_acl,
        .update_time    = btrfs_update_time,
 };
 static const struct inode_operations btrfs_symlink_inode_operations = {
@@ -8752,7 +8756,6 @@ static const struct inode_operations btrfs_symlink_inode_operations = {
        .getxattr       = btrfs_getxattr,
        .listxattr      = btrfs_listxattr,
        .removexattr    = btrfs_removexattr,
-       .get_acl        = btrfs_get_acl,
        .update_time    = btrfs_update_time,
 };
 
index 21da5762b0b1b33d193f3bd7f664995a43062bd6..ad27dcea319c74558d9f38e4647111bca362654a 100644 (file)
@@ -2686,14 +2686,11 @@ out_unlock:
 #define BTRFS_MAX_DEDUPE_LEN   (16 * 1024 * 1024)
 
 static long btrfs_ioctl_file_extent_same(struct file *file,
-                                        void __user *argp)
+                       struct btrfs_ioctl_same_args __user *argp)
 {
-       struct btrfs_ioctl_same_args tmp;
        struct btrfs_ioctl_same_args *same;
        struct btrfs_ioctl_same_extent_info *info;
-       struct inode *src = file->f_dentry->d_inode;
-       struct file *dst_file = NULL;
-       struct inode *dst;
+       struct inode *src = file_inode(file);
        u64 off;
        u64 len;
        int i;
@@ -2701,6 +2698,7 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
        unsigned long size;
        u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize;
        bool is_admin = capable(CAP_SYS_ADMIN);
+       u16 count;
 
        if (!(file->f_mode & FMODE_READ))
                return -EINVAL;
@@ -2709,17 +2707,14 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
        if (ret)
                return ret;
 
-       if (copy_from_user(&tmp,
-                          (struct btrfs_ioctl_same_args __user *)argp,
-                          sizeof(tmp))) {
+       if (get_user(count, &argp->dest_count)) {
                ret = -EFAULT;
                goto out;
        }
 
-       size = sizeof(tmp) +
-               tmp.dest_count * sizeof(struct btrfs_ioctl_same_extent_info);
+       size = offsetof(struct btrfs_ioctl_same_args __user, info[count]);
 
-       same = memdup_user((struct btrfs_ioctl_same_args __user *)argp, size);
+       same = memdup_user(argp, size);
 
        if (IS_ERR(same)) {
                ret = PTR_ERR(same);
@@ -2756,52 +2751,35 @@ static long btrfs_ioctl_file_extent_same(struct file *file,
                goto out;
 
        /* pre-format output fields to sane values */
-       for (i = 0; i < same->dest_count; i++) {
+       for (i = 0; i < count; i++) {
                same->info[i].bytes_deduped = 0ULL;
                same->info[i].status = 0;
        }
 
-       ret = 0;
-       for (i = 0; i < same->dest_count; i++) {
-               info = &same->info[i];
-
-               dst_file = fget(info->fd);
-               if (!dst_file) {
+       for (i = 0, info = same->info; i < count; i++, info++) {
+               struct inode *dst;
+               struct fd dst_file = fdget(info->fd);
+               if (!dst_file.file) {
                        info->status = -EBADF;
-                       goto next;
+                       continue;
                }
+               dst = file_inode(dst_file.file);
 
-               if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+               if (!(is_admin || (dst_file.file->f_mode & FMODE_WRITE))) {
                        info->status = -EINVAL;
-                       goto next;
-               }
-
-               info->status = -EXDEV;
-               if (file->f_path.mnt != dst_file->f_path.mnt)
-                       goto next;
-
-               dst = dst_file->f_dentry->d_inode;
-               if (src->i_sb != dst->i_sb)
-                       goto next;
-
-               if (S_ISDIR(dst->i_mode)) {
+               } else if (file->f_path.mnt != dst_file.file->f_path.mnt) {
+                       info->status = -EXDEV;
+               } else if (S_ISDIR(dst->i_mode)) {
                        info->status = -EISDIR;
-                       goto next;
-               }
-
-               if (!S_ISREG(dst->i_mode)) {
+               } else if (!S_ISREG(dst->i_mode)) {
                        info->status = -EACCES;
-                       goto next;
+               } else {
+                       info->status = btrfs_extent_same(src, off, len, dst,
+                                                       info->logical_offset);
+                       if (info->status == 0)
+                               info->bytes_deduped += len;
                }
-
-               info->status = btrfs_extent_same(src, off, len, dst,
-                                               info->logical_offset);
-               if (info->status == 0)
-                       info->bytes_deduped += len;
-
-next:
-               if (dst_file)
-                       fput(dst_file);
+               fdput(dst_file);
        }
 
        ret = copy_to_user(argp, same, size);
index 05740b9789e4f97dd92b65f0d000e87dac7558e6..3d1c301c9260299fbecc13eaeade5b6521c3ef26 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/rwsem.h>
 #include <linux/xattr.h>
 #include <linux/security.h>
+#include <linux/posix_acl_xattr.h>
 #include "ctree.h"
 #include "btrfs_inode.h"
 #include "transaction.h"
@@ -313,8 +314,8 @@ err:
  */
 const struct xattr_handler *btrfs_xattr_handlers[] = {
 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
-       &btrfs_xattr_acl_access_handler,
-       &btrfs_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
        NULL,
 };
index b3cc8039134bc4ed59420f51b48ab72c04f2eedc..5049608d13889e1e647cdb447851a6b30319990d 100644 (file)
@@ -21,8 +21,6 @@
 
 #include <linux/xattr.h>
 
-extern const struct xattr_handler btrfs_xattr_acl_access_handler;
-extern const struct xattr_handler btrfs_xattr_acl_default_handler;
 extern const struct xattr_handler *btrfs_xattr_handlers[];
 
 extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name,
index e501ac3a49ff7380a1bd2644ecc8abc3f648ce64..06610cf94d579a8da72a5d6af53b098ec43e482d 100644 (file)
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/blkdev.h>
-#include <linux/cramfs_fs.h>
 #include <linux/slab.h>
-#include <linux/cramfs_fs_sb.h>
 #include <linux/vfs.h>
 #include <linux/mutex.h>
-
+#include <uapi/linux/cramfs_fs.h>
 #include <asm/uaccess.h>
 
+#include "internal.h"
+
+/*
+ * cramfs super-block data in memory
+ */
+struct cramfs_sb_info {
+       unsigned long magic;
+       unsigned long size;
+       unsigned long blocks;
+       unsigned long files;
+       unsigned long flags;
+};
+
+static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb)
+{
+       return sb->s_fs_info;
+}
+
 static const struct super_operations cramfs_ops;
 static const struct inode_operations cramfs_dir_inode_operations;
 static const struct file_operations cramfs_directory_operations;
@@ -219,10 +235,11 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
        return read_buffers[buffer] + offset;
 }
 
-static void cramfs_put_super(struct super_block *sb)
+static void cramfs_kill_sb(struct super_block *sb)
 {
-       kfree(sb->s_fs_info);
-       sb->s_fs_info = NULL;
+       struct cramfs_sb_info *sbi = CRAMFS_SB(sb);
+       kill_block_super(sb);
+       kfree(sbi);
 }
 
 static int cramfs_remount(struct super_block *sb, int *flags, char *data)
@@ -261,7 +278,7 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
                if (super.magic == CRAMFS_MAGIC_WEND) {
                        if (!silent)
                                printk(KERN_ERR "cramfs: wrong endianness\n");
-                       goto out;
+                       return -EINVAL;
                }
 
                /* check at 512 byte offset */
@@ -273,20 +290,20 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
                                printk(KERN_ERR "cramfs: wrong endianness\n");
                        else if (!silent)
                                printk(KERN_ERR "cramfs: wrong magic\n");
-                       goto out;
+                       return -EINVAL;
                }
        }
 
        /* get feature flags first */
        if (super.flags & ~CRAMFS_SUPPORTED_FLAGS) {
                printk(KERN_ERR "cramfs: unsupported filesystem features\n");
-               goto out;
+               return -EINVAL;
        }
 
        /* Check that the root inode is in a sane state */
        if (!S_ISDIR(super.root.mode)) {
                printk(KERN_ERR "cramfs: root is not a directory\n");
-               goto out;
+               return -EINVAL;
        }
        /* correct strange, hard-coded permissions of mkcramfs */
        super.root.mode |= (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
@@ -310,22 +327,18 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
                  (root_offset != 512 + sizeof(struct cramfs_super))))
        {
                printk(KERN_ERR "cramfs: bad root offset %lu\n", root_offset);
-               goto out;
+               return -EINVAL;
        }
 
        /* Set it all up.. */
        sb->s_op = &cramfs_ops;
        root = get_cramfs_inode(sb, &super.root, 0);
        if (IS_ERR(root))
-               goto out;
+               return PTR_ERR(root);
        sb->s_root = d_make_root(root);
        if (!sb->s_root)
-               goto out;
+               return -ENOMEM;
        return 0;
-out:
-       kfree(sbi);
-       sb->s_fs_info = NULL;
-       return -EINVAL;
 }
 
 static int cramfs_statfs(struct dentry *dentry, struct kstatfs *buf)
@@ -550,7 +563,6 @@ static const struct inode_operations cramfs_dir_inode_operations = {
 };
 
 static const struct super_operations cramfs_ops = {
-       .put_super      = cramfs_put_super,
        .remount_fs     = cramfs_remount,
        .statfs         = cramfs_statfs,
 };
@@ -565,7 +577,7 @@ static struct file_system_type cramfs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "cramfs",
        .mount          = cramfs_mount,
-       .kill_sb        = kill_block_super,
+       .kill_sb        = cramfs_kill_sb,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("cramfs");
similarity index 70%
rename from include/linux/cramfs_fs.h
rename to fs/cramfs/internal.h
index 133789609f239e5f25edfade82be8fe7f6ddb381..349d71272157ab8678805b0eb49902b3a96b50ec 100644 (file)
@@ -1,10 +1,4 @@
-#ifndef __CRAMFS_H
-#define __CRAMFS_H
-
-#include <uapi/linux/cramfs_fs.h>
-
 /* Uncompression interfaces to the underlying zlib */
 int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen);
 int cramfs_uncompress_init(void);
 void cramfs_uncompress_exit(void);
-#endif
index 023329800d2e42152fec5a531f91f4310cae1729..1760c1b84d9787cc27cc23e22387147ad65129e7 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/errno.h>
 #include <linux/vmalloc.h>
 #include <linux/zlib.h>
-#include <linux/cramfs_fs.h>
+#include "internal.h"
 
 static z_stream stream;
 static int initialized;
index cb4a10690868263cb58e28012ee8f9abc4880da5..265e0ce9769c70db65d5f9df11c4365f44c6dd29 100644 (file)
@@ -3116,26 +3116,28 @@ char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
 /*
  * Write full pathname from the root of the filesystem into the buffer.
  */
-static char *__dentry_path(struct dentry *dentry, char *buf, int buflen)
+static char *__dentry_path(struct dentry *d, char *buf, int buflen)
 {
+       struct dentry *dentry;
        char *end, *retval;
        int len, seq = 0;
        int error = 0;
 
+       if (buflen < 2)
+               goto Elong;
+
        rcu_read_lock();
 restart:
+       dentry = d;
        end = buf + buflen;
        len = buflen;
        prepend(&end, &len, "\0", 1);
-       if (buflen < 1)
-               goto Elong;
        /* Get '/' right */
        retval = end-1;
        *retval = '/';
        read_seqbegin_or_lock(&rename_lock, &seq);
        while (!IS_ROOT(dentry)) {
                struct dentry *parent = dentry->d_parent;
-               int error;
 
                prefetch(parent);
                error = prepend_name(&end, &len, &dentry->d_name);
index c36c4482447159c219a4d4f56506087229ebb276..b167ca48b8eef4984dec79a609644012421e6fea 100644 (file)
@@ -659,19 +659,17 @@ out_lock:
        return rc;
 }
 
-static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
-                                  size_t *bufsiz)
+static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
 {
        struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
        char *lower_buf;
+       char *buf;
        mm_segment_t old_fs;
        int rc;
 
        lower_buf = kmalloc(PATH_MAX, GFP_KERNEL);
-       if (!lower_buf) {
-               rc = -ENOMEM;
-               goto out;
-       }
+       if (!lower_buf)
+               return ERR_PTR(-ENOMEM);
        old_fs = get_fs();
        set_fs(get_ds());
        rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
@@ -680,21 +678,18 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
        set_fs(old_fs);
        if (rc < 0)
                goto out;
-       rc = ecryptfs_decode_and_decrypt_filename(buf, bufsiz, dentry->d_sb,
+       rc = ecryptfs_decode_and_decrypt_filename(&buf, bufsiz, dentry->d_sb,
                                                  lower_buf, rc);
 out:
        kfree(lower_buf);
-       return rc;
+       return rc ? ERR_PTR(rc) : buf;
 }
 
 static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-       char *buf;
-       size_t len = PATH_MAX;
-       int rc;
-
-       rc = ecryptfs_readlink_lower(dentry, &buf, &len);
-       if (rc)
+       size_t len;
+       char *buf = ecryptfs_readlink_lower(dentry, &len);
+       if (IS_ERR(buf))
                goto out;
        fsstack_copy_attr_atime(dentry->d_inode,
                                ecryptfs_dentry_to_lower(dentry)->d_inode);
@@ -1003,10 +998,12 @@ static int ecryptfs_getattr_link(struct vfsmount *mnt, struct dentry *dentry,
                char *target;
                size_t targetsiz;
 
-               rc = ecryptfs_readlink_lower(dentry, &target, &targetsiz);
-               if (!rc) {
+               target = ecryptfs_readlink_lower(dentry, &targetsiz);
+               if (!IS_ERR(target)) {
                        kfree(target);
                        stat->size = targetsiz;
+               } else {
+                       rc = PTR_ERR(target);
                }
        }
        return rc;
index c6f57a74a559da265bc8f062eab06488d8d7c00a..50215bbd646313fdad24ae3b521af017b834bcf9 100644 (file)
@@ -26,11 +26,18 @@ static struct dentry *efs_mount(struct file_system_type *fs_type,
        return mount_bdev(fs_type, flags, dev_name, data, efs_fill_super);
 }
 
+static void efs_kill_sb(struct super_block *s)
+{
+       struct efs_sb_info *sbi = SUPER_INFO(s);
+       kill_block_super(s);
+       kfree(sbi);
+}
+
 static struct file_system_type efs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "efs",
        .mount          = efs_mount,
-       .kill_sb        = kill_block_super,
+       .kill_sb        = efs_kill_sb,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("efs");
@@ -105,12 +112,6 @@ static void destroy_inodecache(void)
        kmem_cache_destroy(efs_inode_cachep);
 }
 
-static void efs_put_super(struct super_block *s)
-{
-       kfree(s->s_fs_info);
-       s->s_fs_info = NULL;
-}
-
 static int efs_remount(struct super_block *sb, int *flags, char *data)
 {
        *flags |= MS_RDONLY;
@@ -120,7 +121,6 @@ static int efs_remount(struct super_block *sb, int *flags, char *data)
 static const struct super_operations efs_superblock_operations = {
        .alloc_inode    = efs_alloc_inode,
        .destroy_inode  = efs_destroy_inode,
-       .put_super      = efs_put_super,
        .statfs         = efs_statfs,
        .remount_fs     = efs_remount,
 };
@@ -259,7 +259,6 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        struct efs_sb_info *sb;
        struct buffer_head *bh;
        struct inode *root;
-       int ret = -EINVAL;
 
        sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
        if (!sb)
@@ -270,7 +269,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
                printk(KERN_ERR "EFS: device does not support %d byte blocks\n",
                        EFS_BLOCKSIZE);
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
   
        /* read the vh (volume header) block */
@@ -278,7 +277,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
 
        if (!bh) {
                printk(KERN_ERR "EFS: cannot read volume header\n");
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
 
        /*
@@ -290,13 +289,13 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        brelse(bh);
 
        if (sb->fs_start == -1) {
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
 
        bh = sb_bread(s, sb->fs_start + EFS_SUPER);
        if (!bh) {
                printk(KERN_ERR "EFS: cannot read superblock\n");
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
                
        if (efs_validate_super(sb, (struct efs_super *) bh->b_data)) {
@@ -304,7 +303,7 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
                printk(KERN_WARNING "EFS: invalid superblock at block %u\n", sb->fs_start + EFS_SUPER);
 #endif
                brelse(bh);
-               goto out_no_fs_ul;
+               return -EINVAL;
        }
        brelse(bh);
 
@@ -319,24 +318,16 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
        root = efs_iget(s, EFS_ROOTINODE);
        if (IS_ERR(root)) {
                printk(KERN_ERR "EFS: get root inode failed\n");
-               ret = PTR_ERR(root);
-               goto out_no_fs;
+               return PTR_ERR(root);
        }
 
        s->s_root = d_make_root(root);
        if (!(s->s_root)) {
                printk(KERN_ERR "EFS: get root dentry failed\n");
-               ret = -ENOMEM;
-               goto out_no_fs;
+               return -ENOMEM;
        }
 
        return 0;
-
-out_no_fs_ul:
-out_no_fs:
-       s->s_fs_info = NULL;
-       kfree(sb);
-       return ret;
 }
 
 static int efs_statfs(struct dentry *dentry, struct kstatfs *buf) {
index 35470d9b96e68951de6f1a63fe3657f09a8296c4..d6a88e7812f3e68a84888ce104cce4285ea50538 100644 (file)
@@ -349,15 +349,12 @@ EXPORT_SYMBOL_GPL(eventfd_fget);
  */
 struct eventfd_ctx *eventfd_ctx_fdget(int fd)
 {
-       struct file *file;
        struct eventfd_ctx *ctx;
-
-       file = eventfd_fget(fd);
-       if (IS_ERR(file))
-               return (struct eventfd_ctx *) file;
-       ctx = eventfd_ctx_get(file->private_data);
-       fput(file);
-
+       struct fd f = fdget(fd);
+       if (!f.file)
+               return ERR_PTR(-EBADF);
+       ctx = eventfd_ctx_fileget(f.file);
+       fdput(f);
        return ctx;
 }
 EXPORT_SYMBOL_GPL(eventfd_ctx_fdget);
index 110b6b371a4edc353fc1904bcc79299580087184..1b8001bbe94778ec09cfab5ecd8d08136d384a5a 100644 (file)
@@ -148,13 +148,6 @@ ext2_get_acl(struct inode *inode, int type)
        struct posix_acl *acl;
        int retval;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return NULL;
-
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -189,19 +182,14 @@ ext2_get_acl(struct inode *inode, int type)
 /*
  * inode->i_mutex: down
  */
-static int
-ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
+int
+ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
        int name_index;
        void *value = NULL;
        size_t size = 0;
        int error;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return 0;
-
        switch(type) {
                case ACL_TYPE_ACCESS:
                        name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -250,169 +238,21 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
 int
 ext2_init_acl(struct inode *inode, struct inode *dir)
 {
-       struct posix_acl *acl = NULL;
-       int error = 0;
-
-       if (!S_ISLNK(inode->i_mode)) {
-               if (test_opt(dir->i_sb, POSIX_ACL)) {
-                       acl = ext2_get_acl(dir, ACL_TYPE_DEFAULT);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               }
-               if (!acl)
-                       inode->i_mode &= ~current_umask();
-       }
-       if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
-                       if (error)
-                               goto cleanup;
-               }
-               error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
-               if (error < 0)
-                       return error;
-               if (error > 0) {
-                       /* This is an extended ACL */
-                       error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
-               }
-       }
-cleanup:
-       posix_acl_release(acl);
-       return error;
-}
-
-/*
- * Does chmod for an inode that may have an Access Control List. The
- * inode->i_mode field must be updated to the desired value by the caller
- * before calling this function.
- * Returns 0 on success, or a negative error number.
- *
- * We change the ACL rather than storing some ACL entries in the file
- * mode permission bits (which would be more efficient), because that
- * would break once additional permissions (like  ACL_APPEND, ACL_DELETE
- * for directories) are added. There are no more bits available in the
- * file mode.
- *
- * inode->i_mutex: down
- */
-int
-ext2_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
-        int error;
+       struct posix_acl *default_acl, *acl;
+       int error;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return 0;
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+       error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
        if (error)
                return error;
-       error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
-       posix_acl_release(acl);
-       return error;
-}
 
-/*
- * Extended attribut handlers
- */
-static size_t
-ext2_xattr_list_acl_access(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 (!test_opt(dentry->d_sb, POSIX_ACL))
-               return 0;
-       if (list && size <= list_size)
-               memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
-       return size;
-}
-
-static size_t
-ext2_xattr_list_acl_default(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 (!test_opt(dentry->d_sb, POSIX_ACL))
-               return 0;
-       if (list && size <= list_size)
-               memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
-       return size;
-}
-
-static int
-ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
-                  size_t size, int type)
-{
-       struct posix_acl *acl;
-       int error;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return -EOPNOTSUPP;
-
-       acl = ext2_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;
-}
-
-static int
-ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
-                  size_t size, int flags, int type)
-{
-       struct posix_acl *acl;
-       int error;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return -EOPNOTSUPP;
-       if (!inode_owner_or_capable(dentry->d_inode))
-               return -EPERM;
-
-       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;
-
-       error = ext2_set_acl(dentry->d_inode, type, acl);
-
-release_and_out:
-       posix_acl_release(acl);
+       if (default_acl) {
+               error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+               posix_acl_release(default_acl);
+       }
+       if (acl) {
+               if (!error)
+                       error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
+               posix_acl_release(acl);
+       }
        return error;
 }
-
-const struct xattr_handler ext2_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .list   = ext2_xattr_list_acl_access,
-       .get    = ext2_xattr_get_acl,
-       .set    = ext2_xattr_set_acl,
-};
-
-const struct xattr_handler ext2_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = ext2_xattr_list_acl_default,
-       .get    = ext2_xattr_get_acl,
-       .set    = ext2_xattr_set_acl,
-};
index 503bfb0ed79b208365c50a0695243d55c43bca19..44937f9fcf327522bb65fe4d2463c1cb2f8bc3b8 100644 (file)
@@ -55,7 +55,7 @@ static inline int ext2_acl_count(size_t size)
 
 /* acl.c */
 extern struct posix_acl *ext2_get_acl(struct inode *inode, int type);
-extern int ext2_acl_chmod (struct inode *);
+extern int ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int ext2_init_acl (struct inode *, struct inode *);
 
 #else
@@ -63,12 +63,6 @@ extern int ext2_init_acl (struct inode *, struct inode *);
 #define ext2_get_acl   NULL
 #define ext2_set_acl   NULL
 
-static inline int
-ext2_acl_chmod (struct inode *inode)
-{
-       return 0;
-}
-
 static inline int ext2_init_acl (struct inode *inode, struct inode *dir)
 {
        return 0;
index a5b3a5db31206f8f3c84781362f7c45e919ddf0e..44c36e5907655982cc10e26b822cc1061312fbd1 100644 (file)
@@ -103,5 +103,6 @@ const struct inode_operations ext2_file_inode_operations = {
 #endif
        .setattr        = ext2_setattr,
        .get_acl        = ext2_get_acl,
+       .set_acl        = ext2_set_acl,
        .fiemap         = ext2_fiemap,
 };
index 8a337640a46a06fec154fe9ae1fef1e054000c23..94ed36849b717bb83d3824527b9ae4f2f7d4b90a 100644 (file)
@@ -1566,7 +1566,7 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr)
        }
        setattr_copy(inode, iattr);
        if (iattr->ia_valid & ATTR_MODE)
-               error = ext2_acl_chmod(inode);
+               error = posix_acl_chmod(inode, inode->i_mode);
        mark_inode_dirty(inode);
 
        return error;
index 256dd5f4c1c4ade3f1ba160726ed0defabfccaf8..c268d0af1db93c5c9b3db0dd93dd6819d977b42e 100644 (file)
@@ -421,6 +421,7 @@ const struct inode_operations ext2_dir_inode_operations = {
 #endif
        .setattr        = ext2_setattr,
        .get_acl        = ext2_get_acl,
+       .set_acl        = ext2_set_acl,
        .tmpfile        = ext2_tmpfile,
 };
 
@@ -433,4 +434,5 @@ const struct inode_operations ext2_special_inode_operations = {
 #endif
        .setattr        = ext2_setattr,
        .get_acl        = ext2_get_acl,
+       .set_acl        = ext2_set_acl,
 };
index 2d7557db3ae855b614b0c70d2803adafb0f64181..91426141c33a32a1bd37bb95fa2414da5bcbad92 100644 (file)
@@ -103,8 +103,8 @@ static struct mb_cache *ext2_xattr_cache;
 static const struct xattr_handler *ext2_xattr_handler_map[] = {
        [EXT2_XATTR_INDEX_USER]              = &ext2_xattr_user_handler,
 #ifdef CONFIG_EXT2_FS_POSIX_ACL
-       [EXT2_XATTR_INDEX_POSIX_ACL_ACCESS]  = &ext2_xattr_acl_access_handler,
-       [EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext2_xattr_acl_default_handler,
+       [EXT2_XATTR_INDEX_POSIX_ACL_ACCESS]  = &posix_acl_access_xattr_handler,
+       [EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
 #endif
        [EXT2_XATTR_INDEX_TRUSTED]           = &ext2_xattr_trusted_handler,
 #ifdef CONFIG_EXT2_FS_SECURITY
@@ -116,8 +116,8 @@ const struct xattr_handler *ext2_xattr_handlers[] = {
        &ext2_xattr_user_handler,
        &ext2_xattr_trusted_handler,
 #ifdef CONFIG_EXT2_FS_POSIX_ACL
-       &ext2_xattr_acl_access_handler,
-       &ext2_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
 #ifdef CONFIG_EXT2_FS_SECURITY
        &ext2_xattr_security_handler,
index 5e41cccff7622a212fec0a8f2a43fe7e38d8b2d9..60edf298644ea2ad9a45b960425392697cbdf373 100644 (file)
@@ -57,8 +57,6 @@ struct ext2_xattr_entry {
 
 extern const struct xattr_handler ext2_xattr_user_handler;
 extern const struct xattr_handler ext2_xattr_trusted_handler;
-extern const struct xattr_handler ext2_xattr_acl_access_handler;
-extern const struct xattr_handler ext2_xattr_acl_default_handler;
 extern const struct xattr_handler ext2_xattr_security_handler;
 
 extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
index dbb5ad59a7fc3c22380ce30b9034f8942bec967b..8bbaf5bcf9820c6d538298a0a5d6922a52f3d231 100644 (file)
@@ -145,13 +145,6 @@ ext3_get_acl(struct inode *inode, int type)
        struct posix_acl *acl;
        int retval;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return NULL;
-
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -190,7 +183,7 @@ ext3_get_acl(struct inode *inode, int type)
  * inode->i_mutex: down unless called from ext3_new_inode
  */
 static int
-ext3_set_acl(handle_t *handle, struct inode *inode, int type,
+__ext3_set_acl(handle_t *handle, struct inode *inode, int type,
             struct posix_acl *acl)
 {
        int name_index;
@@ -198,9 +191,6 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
        size_t size = 0;
        int error;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
        switch(type) {
                case ACL_TYPE_ACCESS:
                        name_index = EXT3_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -243,204 +233,49 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
        return error;
 }
 
-/*
- * Initialize the ACLs of a new inode. Called from ext3_new_inode.
- *
- * dir->i_mutex: down
- * inode->i_mutex: up (access to inode is still exclusive)
- */
 int
-ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+ext3_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-       struct posix_acl *acl = NULL;
-       int error = 0;
-
-       if (!S_ISLNK(inode->i_mode)) {
-               if (test_opt(dir->i_sb, POSIX_ACL)) {
-                       acl = ext3_get_acl(dir, ACL_TYPE_DEFAULT);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               }
-               if (!acl)
-                       inode->i_mode &= ~current_umask();
-       }
-       if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       error = ext3_set_acl(handle, inode,
-                                            ACL_TYPE_DEFAULT, acl);
-                       if (error)
-                               goto cleanup;
-               }
-               error = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
-               if (error < 0)
-                       return error;
-
-               if (error > 0) {
-                       /* This is an extended ACL */
-                       error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
-               }
-       }
-cleanup:
-       posix_acl_release(acl);
-       return error;
-}
-
-/*
- * Does chmod for an inode that may have an Access Control List. The
- * inode->i_mode field must be updated to the desired value by the caller
- * before calling this function.
- * Returns 0 on success, or a negative error number.
- *
- * We change the ACL rather than storing some ACL entries in the file
- * mode permission bits (which would be more efficient), because that
- * would break once additional permissions (like  ACL_APPEND, ACL_DELETE
- * for directories) are added. There are no more bits available in the
- * file mode.
- *
- * inode->i_mutex: down
- */
-int
-ext3_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
        handle_t *handle;
-       int retries = 0;
-        int error;
+       int error, retries = 0;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return 0;
-       acl = ext3_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (error)
-               return error;
 retry:
-       handle = ext3_journal_start(inode,
-                       EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
-       if (IS_ERR(handle)) {
-               error = PTR_ERR(handle);
-               ext3_std_error(inode->i_sb, error);
-               goto out;
-       }
-       error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
+       handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
+       if (IS_ERR(handle))
+               return PTR_ERR(handle);
+       error = __ext3_set_acl(handle, inode, type, acl);
        ext3_journal_stop(handle);
-       if (error == -ENOSPC &&
-           ext3_should_retry_alloc(inode->i_sb, &retries))
+       if (error == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
                goto retry;
-out:
-       posix_acl_release(acl);
        return error;
 }
 
 /*
- * Extended attribute handlers
+ * Initialize the ACLs of a new inode. Called from ext3_new_inode.
+ *
+ * dir->i_mutex: down
+ * inode->i_mutex: up (access to inode is still exclusive)
  */
-static size_t
-ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len,
-                          const char *name, size_t name_len, int type)
-{
-       const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
-
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return 0;
-       if (list && size <= list_len)
-               memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
-       return size;
-}
-
-static size_t
-ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len,
-                           const char *name, size_t name_len, int type)
-{
-       const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
-
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return 0;
-       if (list && size <= list_len)
-               memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
-       return size;
-}
-
-static int
-ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
-                  size_t size, int type)
+int
+ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
 {
-       struct posix_acl *acl;
+       struct posix_acl *default_acl, *acl;
        int error;
 
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return -EOPNOTSUPP;
-
-       acl = ext3_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;
-}
-
-static int
-ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
-                  size_t size, int flags, int type)
-{
-       struct inode *inode = dentry->d_inode;
-       handle_t *handle;
-       struct posix_acl *acl;
-       int error, retries = 0;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return -EOPNOTSUPP;
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       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;
-
-retry:
-       handle = ext3_journal_start(inode, EXT3_DATA_TRANS_BLOCKS(inode->i_sb));
-       if (IS_ERR(handle))
-               return PTR_ERR(handle);
-       error = ext3_set_acl(handle, inode, type, acl);
-       ext3_journal_stop(handle);
-       if (error == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
-               goto retry;
+       error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (error)
+               return error;
 
-release_and_out:
-       posix_acl_release(acl);
+       if (default_acl) {
+               error = __ext3_set_acl(handle, inode, ACL_TYPE_DEFAULT,
+                                      default_acl);
+               posix_acl_release(default_acl);
+       }
+       if (acl) {
+               if (!error)
+                       error = __ext3_set_acl(handle, inode, ACL_TYPE_ACCESS,
+                                              acl);
+               posix_acl_release(acl);
+       }
        return error;
 }
-
-const struct xattr_handler ext3_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .list   = ext3_xattr_list_acl_access,
-       .get    = ext3_xattr_get_acl,
-       .set    = ext3_xattr_set_acl,
-};
-
-const struct xattr_handler ext3_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = ext3_xattr_list_acl_default,
-       .get    = ext3_xattr_get_acl,
-       .set    = ext3_xattr_set_acl,
-};
index dbc921e458c5599177fb86fc6e3fc95481cf06ab..ea1c69edab9e15dd1a9447f2be4a0e83650252c7 100644 (file)
@@ -55,18 +55,13 @@ static inline int ext3_acl_count(size_t size)
 
 /* acl.c */
 extern struct posix_acl *ext3_get_acl(struct inode *inode, int type);
-extern int ext3_acl_chmod (struct inode *);
+extern int ext3_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int ext3_init_acl (handle_t *, struct inode *, struct inode *);
 
 #else  /* CONFIG_EXT3_FS_POSIX_ACL */
 #include <linux/sched.h>
 #define ext3_get_acl NULL
-
-static inline int
-ext3_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
+#define ext3_set_acl NULL
 
 static inline int
 ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
index 25cb413277e906edb1f037ba625ece7aa92903bb..aad05311392a046f3df724102580c511185c0fa2 100644 (file)
@@ -75,6 +75,7 @@ const struct inode_operations ext3_file_inode_operations = {
        .removexattr    = generic_removexattr,
 #endif
        .get_acl        = ext3_get_acl,
+       .set_acl        = ext3_set_acl,
        .fiemap         = ext3_fiemap,
 };
 
index 2bd85486b87974b390892a2280676a49d8eb274e..384b6ebb655f1aefa21e53b6b28f6598c40db1b2 100644 (file)
@@ -3365,7 +3365,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
        mark_inode_dirty(inode);
 
        if (ia_valid & ATTR_MODE)
-               rc = ext3_acl_chmod(inode);
+               rc = posix_acl_chmod(inode, inode->i_mode);
 
 err_out:
        ext3_std_error(inode->i_sb, error);
index f8cde46de9cd77c3047182e94164bdfdac4a317d..f197736dccfa16cca207fecb81e6445a18e96973 100644 (file)
@@ -2569,6 +2569,7 @@ const struct inode_operations ext3_dir_inode_operations = {
        .removexattr    = generic_removexattr,
 #endif
        .get_acl        = ext3_get_acl,
+       .set_acl        = ext3_set_acl,
 };
 
 const struct inode_operations ext3_special_inode_operations = {
@@ -2580,4 +2581,5 @@ const struct inode_operations ext3_special_inode_operations = {
        .removexattr    = generic_removexattr,
 #endif
        .get_acl        = ext3_get_acl,
+       .set_acl        = ext3_set_acl,
 };
index b1fc96383e087157879e853b2affbf0cb87982ec..c6874be6d58b41f02bcaa3b93cf182845bd85bec 100644 (file)
@@ -102,8 +102,8 @@ static struct mb_cache *ext3_xattr_cache;
 static const struct xattr_handler *ext3_xattr_handler_map[] = {
        [EXT3_XATTR_INDEX_USER]              = &ext3_xattr_user_handler,
 #ifdef CONFIG_EXT3_FS_POSIX_ACL
-       [EXT3_XATTR_INDEX_POSIX_ACL_ACCESS]  = &ext3_xattr_acl_access_handler,
-       [EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext3_xattr_acl_default_handler,
+       [EXT3_XATTR_INDEX_POSIX_ACL_ACCESS]  = &posix_acl_access_xattr_handler,
+       [EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
 #endif
        [EXT3_XATTR_INDEX_TRUSTED]           = &ext3_xattr_trusted_handler,
 #ifdef CONFIG_EXT3_FS_SECURITY
@@ -115,8 +115,8 @@ const struct xattr_handler *ext3_xattr_handlers[] = {
        &ext3_xattr_user_handler,
        &ext3_xattr_trusted_handler,
 #ifdef CONFIG_EXT3_FS_POSIX_ACL
-       &ext3_xattr_acl_access_handler,
-       &ext3_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
 #ifdef CONFIG_EXT3_FS_SECURITY
        &ext3_xattr_security_handler,
index 2be4f69bfa64b301d437e5130868f433a01d5f50..32e93ebf80315bed89dd5e919202a4de2d2f4de3 100644 (file)
@@ -60,8 +60,6 @@ struct ext3_xattr_entry {
 
 extern const struct xattr_handler ext3_xattr_user_handler;
 extern const struct xattr_handler ext3_xattr_trusted_handler;
-extern const struct xattr_handler ext3_xattr_acl_access_handler;
-extern const struct xattr_handler ext3_xattr_acl_default_handler;
 extern const struct xattr_handler ext3_xattr_security_handler;
 
 extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
index 39a54a0e9fe4a9a6290f75b961cde9ccea06f669..d40c8dbbb0d66a3622915c68dc104841ab1f5753 100644 (file)
@@ -152,13 +152,6 @@ ext4_get_acl(struct inode *inode, int type)
        struct posix_acl *acl;
        int retval;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return NULL;
-
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -196,7 +189,7 @@ ext4_get_acl(struct inode *inode, int type)
  * inode->i_mutex: down unless called from ext4_new_inode
  */
 static int
-ext4_set_acl(handle_t *handle, struct inode *inode, int type,
+__ext4_set_acl(handle_t *handle, struct inode *inode, int type,
             struct posix_acl *acl)
 {
        int name_index;
@@ -204,9 +197,6 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,
        size_t size = 0;
        int error;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -248,208 +238,51 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,
        return error;
 }
 
-/*
- * Initialize the ACLs of a new inode. Called from ext4_new_inode.
- *
- * dir->i_mutex: down
- * inode->i_mutex: up (access to inode is still exclusive)
- */
 int
-ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-       struct posix_acl *acl = NULL;
-       int error = 0;
-
-       if (!S_ISLNK(inode->i_mode)) {
-               if (test_opt(dir->i_sb, POSIX_ACL)) {
-                       acl = ext4_get_acl(dir, ACL_TYPE_DEFAULT);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               }
-               if (!acl)
-                       inode->i_mode &= ~current_umask();
-       }
-       if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       error = ext4_set_acl(handle, inode,
-                                            ACL_TYPE_DEFAULT, acl);
-                       if (error)
-                               goto cleanup;
-               }
-               error = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
-               if (error < 0)
-                       return error;
-
-               if (error > 0) {
-                       /* This is an extended ACL */
-                       error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
-               }
-       }
-cleanup:
-       posix_acl_release(acl);
-       return error;
-}
-
-/*
- * Does chmod for an inode that may have an Access Control List. The
- * inode->i_mode field must be updated to the desired value by the caller
- * before calling this function.
- * Returns 0 on success, or a negative error number.
- *
- * We change the ACL rather than storing some ACL entries in the file
- * mode permission bits (which would be more efficient), because that
- * would break once additional permissions (like  ACL_APPEND, ACL_DELETE
- * for directories) are added. There are no more bits available in the
- * file mode.
- *
- * inode->i_mutex: down
- */
-int
-ext4_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
        handle_t *handle;
-       int retries = 0;
-       int error;
-
+       int error, retries = 0;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return 0;
-       acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (error)
-               return error;
 retry:
        handle = ext4_journal_start(inode, EXT4_HT_XATTR,
                                    ext4_jbd2_credits_xattr(inode));
-       if (IS_ERR(handle)) {
-               error = PTR_ERR(handle);
-               ext4_std_error(inode->i_sb, error);
-               goto out;
-       }
-       error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
+       if (IS_ERR(handle))
+               return PTR_ERR(handle);
+
+       error = __ext4_set_acl(handle, inode, type, acl);
        ext4_journal_stop(handle);
-       if (error == -ENOSPC &&
-           ext4_should_retry_alloc(inode->i_sb, &retries))
+       if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
                goto retry;
-out:
-       posix_acl_release(acl);
        return error;
 }
 
 /*
- * Extended attribute handlers
+ * Initialize the ACLs of a new inode. Called from ext4_new_inode.
+ *
+ * dir->i_mutex: down
+ * inode->i_mutex: up (access to inode is still exclusive)
  */
-static size_t
-ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len,
-                          const char *name, size_t name_len, int type)
-{
-       const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
-
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return 0;
-       if (list && size <= list_len)
-               memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
-       return size;
-}
-
-static size_t
-ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len,
-                           const char *name, size_t name_len, int type)
-{
-       const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
-
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return 0;
-       if (list && size <= list_len)
-               memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
-       return size;
-}
-
-static int
-ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
-                  size_t size, int type)
+int
+ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
 {
-       struct posix_acl *acl;
+       struct posix_acl *default_acl, *acl;
        int error;
 
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(dentry->d_sb, POSIX_ACL))
-               return -EOPNOTSUPP;
-
-       acl = ext4_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;
-}
-
-static int
-ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
-                  size_t size, int flags, int type)
-{
-       struct inode *inode = dentry->d_inode;
-       handle_t *handle;
-       struct posix_acl *acl;
-       int error, retries = 0;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(inode->i_sb, POSIX_ACL))
-               return -EOPNOTSUPP;
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       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;
+       error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (error)
+               return error;
 
-retry:
-       handle = ext4_journal_start(inode, EXT4_HT_XATTR,
-                                   ext4_jbd2_credits_xattr(inode));
-       if (IS_ERR(handle)) {
-               error = PTR_ERR(handle);
-               goto release_and_out;
+       if (default_acl) {
+               error = __ext4_set_acl(handle, inode, ACL_TYPE_DEFAULT,
+                                      default_acl);
+               posix_acl_release(default_acl);
+       }
+       if (acl) {
+               if (!error)
+                       error = __ext4_set_acl(handle, inode, ACL_TYPE_ACCESS,
+                                              acl);
+               posix_acl_release(acl);
        }
-       error = ext4_set_acl(handle, inode, type, acl);
-       ext4_journal_stop(handle);
-       if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
-               goto retry;
-
-release_and_out:
-       posix_acl_release(acl);
        return error;
 }
-
-const struct xattr_handler ext4_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .list   = ext4_xattr_list_acl_access,
-       .get    = ext4_xattr_get_acl,
-       .set    = ext4_xattr_set_acl,
-};
-
-const struct xattr_handler ext4_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = ext4_xattr_list_acl_default,
-       .get    = ext4_xattr_get_acl,
-       .set    = ext4_xattr_set_acl,
-};
index 18cb39ed7c7bbb88dfb72f67150b40cf859e2a58..da2c79577d724ae14e7fbf3b5adb4cb3e2848e5d 100644 (file)
@@ -55,18 +55,13 @@ static inline int ext4_acl_count(size_t size)
 
 /* acl.c */
 struct posix_acl *ext4_get_acl(struct inode *inode, int type);
-extern int ext4_acl_chmod(struct inode *);
+int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
 
 #else  /* CONFIG_EXT4_FS_POSIX_ACL */
 #include <linux/sched.h>
 #define ext4_get_acl NULL
-
-static inline int
-ext4_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
+#define ext4_set_acl NULL
 
 static inline int
 ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
index 3da21945ff1fff3e16b8b70b332a0a6ee330c93e..43e64f6022eb4af22e7ac95eb6aaa34e7e6735a9 100644 (file)
@@ -617,6 +617,7 @@ const struct inode_operations ext4_file_inode_operations = {
        .listxattr      = ext4_listxattr,
        .removexattr    = generic_removexattr,
        .get_acl        = ext4_get_acl,
+       .set_acl        = ext4_set_acl,
        .fiemap         = ext4_fiemap,
 };
 
index 31fa964742bcba1b0f9dbd494e469feb56ee8428..fe4793e754d11b2963740751be9864d0b45fbd2e 100644 (file)
@@ -4667,7 +4667,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
                ext4_orphan_del(NULL, inode);
 
        if (!rc && (ia_valid & ATTR_MODE))
-               rc = ext4_acl_chmod(inode);
+               rc = posix_acl_chmod(inode, inode->i_mode);
 
 err_out:
        ext4_std_error(inode->i_sb, error);
index 5a0408d7b1147094c3e82b6d11750b33396b7732..e77c1ba6c8af3043e010a2d6fd4588b9bce371c2 100644 (file)
@@ -3225,6 +3225,7 @@ const struct inode_operations ext4_dir_inode_operations = {
        .listxattr      = ext4_listxattr,
        .removexattr    = generic_removexattr,
        .get_acl        = ext4_get_acl,
+       .set_acl        = ext4_set_acl,
        .fiemap         = ext4_fiemap,
 };
 
@@ -3235,4 +3236,5 @@ const struct inode_operations ext4_special_inode_operations = {
        .listxattr      = ext4_listxattr,
        .removexattr    = generic_removexattr,
        .get_acl        = ext4_get_acl,
+       .set_acl        = ext4_set_acl,
 };
index 1423c4816a4783da4208b6d51fc33815b25597f4..e175e94116acefdc7685896e5c8744f7bd677dc4 100644 (file)
@@ -95,8 +95,8 @@ static struct mb_cache *ext4_xattr_cache;
 static const struct xattr_handler *ext4_xattr_handler_map[] = {
        [EXT4_XATTR_INDEX_USER]              = &ext4_xattr_user_handler,
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
-       [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS]  = &ext4_xattr_acl_access_handler,
-       [EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &ext4_xattr_acl_default_handler,
+       [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS]  = &posix_acl_access_xattr_handler,
+       [EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
 #endif
        [EXT4_XATTR_INDEX_TRUSTED]           = &ext4_xattr_trusted_handler,
 #ifdef CONFIG_EXT4_FS_SECURITY
@@ -108,8 +108,8 @@ const struct xattr_handler *ext4_xattr_handlers[] = {
        &ext4_xattr_user_handler,
        &ext4_xattr_trusted_handler,
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
-       &ext4_xattr_acl_access_handler,
-       &ext4_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
 #ifdef CONFIG_EXT4_FS_SECURITY
        &ext4_xattr_security_handler,
index c767dbdd7fc495e5a4fd4a5c581455db73c5c1c3..819d6398833f9d98ea7a9e78552381f63f7b83fd 100644 (file)
@@ -96,8 +96,6 @@ struct ext4_xattr_ibody_find {
 
 extern const struct xattr_handler ext4_xattr_user_handler;
 extern const struct xattr_handler ext4_xattr_trusted_handler;
-extern const struct xattr_handler ext4_xattr_acl_access_handler;
-extern const struct xattr_handler ext4_xattr_acl_default_handler;
 extern const struct xattr_handler ext4_xattr_security_handler;
 
 extern ssize_t ext4_listxattr(struct dentry *, char *, size_t);
index d0fc287efeff4511fa7f4e84369cf77f0ae31538..fa8da4cb8c4b9a3aa647f2a4f51467fc86549fc5 100644 (file)
@@ -17,9 +17,6 @@
 #include "xattr.h"
 #include "acl.h"
 
-#define get_inode_mode(i)      ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \
-                                       (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
-
 static inline size_t f2fs_acl_size(int count)
 {
        if (count <= 4) {
@@ -167,19 +164,11 @@ fail:
 
 struct posix_acl *f2fs_get_acl(struct inode *inode, int type)
 {
-       struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
        int name_index = F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT;
        void *value = NULL;
        struct posix_acl *acl;
        int retval;
 
-       if (!test_opt(sbi, POSIX_ACL))
-               return NULL;
-
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        if (type == ACL_TYPE_ACCESS)
                name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
 
@@ -205,21 +194,15 @@ struct posix_acl *f2fs_get_acl(struct inode *inode, int type)
        return acl;
 }
 
-static int f2fs_set_acl(struct inode *inode, int type,
+static int __f2fs_set_acl(struct inode *inode, int type,
                        struct posix_acl *acl, struct page *ipage)
 {
-       struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
        struct f2fs_inode_info *fi = F2FS_I(inode);
        int name_index;
        void *value = NULL;
        size_t size = 0;
        int error;
 
-       if (!test_opt(sbi, POSIX_ACL))
-               return 0;
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -261,154 +244,31 @@ static int f2fs_set_acl(struct inode *inode, int type,
        return error;
 }
 
-int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage)
+int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-       struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
-       struct posix_acl *acl = NULL;
-       int error = 0;
-
-       if (!S_ISLNK(inode->i_mode)) {
-               if (test_opt(sbi, POSIX_ACL)) {
-                       acl = f2fs_get_acl(dir, ACL_TYPE_DEFAULT);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               }
-               if (!acl)
-                       inode->i_mode &= ~current_umask();
-       }
-
-       if (!test_opt(sbi, POSIX_ACL) || !acl)
-               goto cleanup;
-
-       if (S_ISDIR(inode->i_mode)) {
-               error = f2fs_set_acl(inode, ACL_TYPE_DEFAULT, acl, ipage);
-               if (error)
-                       goto cleanup;
-       }
-       error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
-       if (error < 0)
-               return error;
-       if (error > 0)
-               error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, ipage);
-cleanup:
-       posix_acl_release(acl);
-       return error;
+       return __f2fs_set_acl(inode, type, acl, NULL);
 }
 
-int f2fs_acl_chmod(struct inode *inode)
+int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage)
 {
-       struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
-       struct posix_acl *acl;
-       int error;
-       umode_t mode = get_inode_mode(inode);
-
-       if (!test_opt(sbi, POSIX_ACL))
-               return 0;
-       if (S_ISLNK(mode))
-               return -EOPNOTSUPP;
-
-       acl = f2fs_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
+       struct posix_acl *default_acl, *acl;
+       int error = 0;
 
-       error = posix_acl_chmod(&acl, GFP_KERNEL, mode);
+       error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
        if (error)
                return error;
 
-       error = f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, NULL);
-       posix_acl_release(acl);
-       return error;
-}
-
-static size_t f2fs_xattr_list_acl(struct dentry *dentry, char *list,
-               size_t list_size, const char *name, size_t name_len, int type)
-{
-       struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
-       const char *xname = POSIX_ACL_XATTR_DEFAULT;
-       size_t size;
-
-       if (!test_opt(sbi, POSIX_ACL))
-               return 0;
-
-       if (type == ACL_TYPE_ACCESS)
-               xname = POSIX_ACL_XATTR_ACCESS;
-
-       size = strlen(xname) + 1;
-       if (list && size <= list_size)
-               memcpy(list, xname, size);
-       return size;
-}
-
-static int f2fs_xattr_get_acl(struct dentry *dentry, const char *name,
-               void *buffer, size_t size, int type)
-{
-       struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
-       struct posix_acl *acl;
-       int error;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(sbi, POSIX_ACL))
-               return -EOPNOTSUPP;
-
-       acl = f2fs_get_acl(dentry->d_inode, type);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (!acl)
-               return -ENODATA;
-       error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-       posix_acl_release(acl);
-
-       return error;
-}
-
-static int f2fs_xattr_set_acl(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags, int type)
-{
-       struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl = NULL;
-       int error;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!test_opt(sbi, POSIX_ACL))
-               return -EOPNOTSUPP;
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       if (value) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               if (acl) {
-                       error = posix_acl_valid(acl);
-                       if (error)
-                               goto release_and_out;
-               }
-       } else {
-               acl = NULL;
+       if (default_acl) {
+               error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl,
+                                      ipage);
+               posix_acl_release(default_acl);
+       }
+       if (acl) {
+               if (error)
+                       error = __f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl,
+                                              ipage);
+               posix_acl_release(acl);
        }
 
-       error = f2fs_set_acl(inode, type, acl, NULL);
-
-release_and_out:
-       posix_acl_release(acl);
        return error;
 }
-
-const struct xattr_handler f2fs_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags = ACL_TYPE_DEFAULT,
-       .list = f2fs_xattr_list_acl,
-       .get = f2fs_xattr_get_acl,
-       .set = f2fs_xattr_set_acl,
-};
-
-const struct xattr_handler f2fs_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags = ACL_TYPE_ACCESS,
-       .list = f2fs_xattr_list_acl,
-       .get = f2fs_xattr_get_acl,
-       .set = f2fs_xattr_set_acl,
-};
index 49633131e038db76e14d21803538f1701a93d873..e0864651cdc1c09661e9d28c094c79c12603846f 100644 (file)
@@ -37,18 +37,13 @@ struct f2fs_acl_header {
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
 
 extern struct posix_acl *f2fs_get_acl(struct inode *, int);
-extern int f2fs_acl_chmod(struct inode *);
+extern int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int f2fs_init_acl(struct inode *, struct inode *, struct page *);
 #else
 #define f2fs_check_acl NULL
 #define f2fs_get_acl   NULL
 #define f2fs_set_acl   NULL
 
-static inline int f2fs_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
-
 static inline int f2fs_init_acl(struct inode *inode, struct inode *dir,
                                                        struct page *page)
 {
index af51a0bd2dee4c267e715d8d39c38b917b115743..fc3c558cb4f3d5a71b8ed03016e838cf5ec84cdf 100644 (file)
@@ -1023,6 +1023,10 @@ static inline int f2fs_readonly(struct super_block *sb)
        return sb->s_flags & MS_RDONLY;
 }
 
+#define get_inode_mode(i) \
+       ((is_inode_flag_set(F2FS_I(i), FI_ACL_MODE)) ? \
+        (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
+
 /*
  * file.c
  */
index 85e91ca88d5791835d25dffe6fc0932f9640203b..0dfcef53a6ed830e442f8c174ea166b0d1b2eabd 100644 (file)
@@ -382,7 +382,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
        __setattr_copy(inode, attr);
 
        if (attr->ia_valid & ATTR_MODE) {
-               err = f2fs_acl_chmod(inode);
+               err = posix_acl_chmod(inode, get_inode_mode(inode));
                if (err || is_inode_flag_set(fi, FI_ACL_MODE)) {
                        inode->i_mode = fi->i_acl_mode;
                        clear_inode_flag(fi, FI_ACL_MODE);
@@ -397,6 +397,7 @@ const struct inode_operations f2fs_file_inode_operations = {
        .getattr        = f2fs_getattr,
        .setattr        = f2fs_setattr,
        .get_acl        = f2fs_get_acl,
+       .set_acl        = f2fs_set_acl,
 #ifdef CONFIG_F2FS_FS_XATTR
        .setxattr       = generic_setxattr,
        .getxattr       = generic_getxattr,
index 3d32f2969c5e047f54ffe9aec4b73dc132d9a8ca..397d459e97bf9f1ee2107c1079f02a282a47e5fa 100644 (file)
@@ -501,6 +501,7 @@ const struct inode_operations f2fs_dir_inode_operations = {
        .getattr        = f2fs_getattr,
        .setattr        = f2fs_setattr,
        .get_acl        = f2fs_get_acl,
+       .set_acl        = f2fs_set_acl,
 #ifdef CONFIG_F2FS_FS_XATTR
        .setxattr       = generic_setxattr,
        .getxattr       = generic_getxattr,
@@ -527,6 +528,7 @@ const struct inode_operations f2fs_special_inode_operations = {
        .getattr        = f2fs_getattr,
        .setattr        = f2fs_setattr,
        .get_acl        = f2fs_get_acl,
+       .set_acl        = f2fs_set_acl,
 #ifdef CONFIG_F2FS_FS_XATTR
        .setxattr       = generic_setxattr,
        .getxattr       = generic_getxattr,
index b0fb8a27f3da6fe3b810eca732361953aeebc030..89d0422a91a88fea51ecf5935d31c2920545f8a6 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/rwsem.h>
 #include <linux/f2fs_fs.h>
 #include <linux/security.h>
+#include <linux/posix_acl_xattr.h>
 #include "f2fs.h"
 #include "xattr.h"
 
@@ -216,8 +217,8 @@ const struct xattr_handler f2fs_xattr_security_handler = {
 static const struct xattr_handler *f2fs_xattr_handler_map[] = {
        [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler,
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
-       [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &f2fs_xattr_acl_access_handler,
-       [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &f2fs_xattr_acl_default_handler,
+       [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
+       [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
 #endif
        [F2FS_XATTR_INDEX_TRUSTED] = &f2fs_xattr_trusted_handler,
 #ifdef CONFIG_F2FS_FS_SECURITY
@@ -229,8 +230,8 @@ static const struct xattr_handler *f2fs_xattr_handler_map[] = {
 const struct xattr_handler *f2fs_xattr_handlers[] = {
        &f2fs_xattr_user_handler,
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
-       &f2fs_xattr_acl_access_handler,
-       &f2fs_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
        &f2fs_xattr_trusted_handler,
 #ifdef CONFIG_F2FS_FS_SECURITY
index 02a08fb88a151c9b38a4e5aabc78decb2f0b4101..b21d9ebdeff39efdf64485116bf53ce17263bb7e 100644 (file)
@@ -108,8 +108,6 @@ struct f2fs_xattr_entry {
 #ifdef CONFIG_F2FS_FS_XATTR
 extern const struct xattr_handler f2fs_xattr_user_handler;
 extern const struct xattr_handler f2fs_xattr_trusted_handler;
-extern const struct xattr_handler f2fs_xattr_acl_access_handler;
-extern const struct xattr_handler f2fs_xattr_acl_default_handler;
 extern const struct xattr_handler f2fs_xattr_advise_handler;
 extern const struct xattr_handler f2fs_xattr_security_handler;
 
index 4a78f981557a4b012919458993506f61fd5187a4..771578b33fb6c7fee9a7c28d01138e4670e07e59 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -348,21 +348,16 @@ out:
        return NULL;
 }
 
-static void close_files(struct files_struct * files)
+static struct fdtable *close_files(struct files_struct * files)
 {
-       int i, j;
-       struct fdtable *fdt;
-
-       j = 0;
-
        /*
         * It is safe to dereference the fd table without RCU or
         * ->file_lock because this is the last reference to the
-        * files structure.  But use RCU to shut RCU-lockdep up.
+        * files structure.
         */
-       rcu_read_lock();
-       fdt = files_fdtable(files);
-       rcu_read_unlock();
+       struct fdtable *fdt = rcu_dereference_raw(files->fdt);
+       int i, j = 0;
+
        for (;;) {
                unsigned long set;
                i = j * BITS_PER_LONG;
@@ -381,6 +376,8 @@ static void close_files(struct files_struct * files)
                        set >>= 1;
                }
        }
+
+       return fdt;
 }
 
 struct files_struct *get_files_struct(struct task_struct *task)
@@ -398,14 +395,9 @@ struct files_struct *get_files_struct(struct task_struct *task)
 
 void put_files_struct(struct files_struct *files)
 {
-       struct fdtable *fdt;
-
        if (atomic_dec_and_test(&files->count)) {
-               close_files(files);
-               /* not really needed, since nobody can see us */
-               rcu_read_lock();
-               fdt = files_fdtable(files);
-               rcu_read_unlock();
+               struct fdtable *fdt = close_files(files);
+
                /* free the arrays if they are not embedded */
                if (fdt != &files->fdtab)
                        __free_fdtable(fdt);
@@ -645,16 +637,16 @@ void do_close_on_exec(struct files_struct *files)
        spin_unlock(&files->file_lock);
 }
 
-struct file *fget(unsigned int fd)
+static struct file *__fget(unsigned int fd, fmode_t mask)
 {
-       struct file *file;
        struct files_struct *files = current->files;
+       struct file *file;
 
        rcu_read_lock();
        file = fcheck_files(files, fd);
        if (file) {
                /* File object ref couldn't be taken */
-               if (file->f_mode & FMODE_PATH ||
+               if ((file->f_mode & mask) ||
                    !atomic_long_inc_not_zero(&file->f_count))
                        file = NULL;
        }
@@ -663,25 +655,16 @@ struct file *fget(unsigned int fd)
        return file;
 }
 
+struct file *fget(unsigned int fd)
+{
+       return __fget(fd, FMODE_PATH);
+}
 EXPORT_SYMBOL(fget);
 
 struct file *fget_raw(unsigned int fd)
 {
-       struct file *file;
-       struct files_struct *files = current->files;
-
-       rcu_read_lock();
-       file = fcheck_files(files, fd);
-       if (file) {
-               /* File object ref couldn't be taken */
-               if (!atomic_long_inc_not_zero(&file->f_count))
-                       file = NULL;
-       }
-       rcu_read_unlock();
-
-       return file;
+       return __fget(fd, 0);
 }
-
 EXPORT_SYMBOL(fget_raw);
 
 /*
@@ -700,56 +683,33 @@ EXPORT_SYMBOL(fget_raw);
  * The fput_needed flag returned by fget_light should be passed to the
  * corresponding fput_light.
  */
-struct file *fget_light(unsigned int fd, int *fput_needed)
+struct file *__fget_light(unsigned int fd, fmode_t mask, int *fput_needed)
 {
-       struct file *file;
        struct files_struct *files = current->files;
+       struct file *file;
 
        *fput_needed = 0;
        if (atomic_read(&files->count) == 1) {
-               file = fcheck_files(files, fd);
-               if (file && (file->f_mode & FMODE_PATH))
+               file = __fcheck_files(files, fd);
+               if (file && (file->f_mode & mask))
                        file = NULL;
        } else {
-               rcu_read_lock();
-               file = fcheck_files(files, fd);
-               if (file) {
-                       if (!(file->f_mode & FMODE_PATH) &&
-                           atomic_long_inc_not_zero(&file->f_count))
-                               *fput_needed = 1;
-                       else
-                               /* Didn't get the reference, someone's freed */
-                               file = NULL;
-               }
-               rcu_read_unlock();
+               file = __fget(fd, mask);
+               if (file)
+                       *fput_needed = 1;
        }
 
        return file;
 }
+struct file *fget_light(unsigned int fd, int *fput_needed)
+{
+       return __fget_light(fd, FMODE_PATH, fput_needed);
+}
 EXPORT_SYMBOL(fget_light);
 
 struct file *fget_raw_light(unsigned int fd, int *fput_needed)
 {
-       struct file *file;
-       struct files_struct *files = current->files;
-
-       *fput_needed = 0;
-       if (atomic_read(&files->count) == 1) {
-               file = fcheck_files(files, fd);
-       } else {
-               rcu_read_lock();
-               file = fcheck_files(files, fd);
-               if (file) {
-                       if (atomic_long_inc_not_zero(&file->f_count))
-                               *fput_needed = 1;
-                       else
-                               /* Didn't get the reference, someone's freed */
-                               file = NULL;
-               }
-               rcu_read_unlock();
-       }
-
-       return file;
+       return __fget_light(fd, 0, fput_needed);
 }
 
 void set_close_on_exec(unsigned int fd, int flag)
index 74f6ca50050447832b4fbe41d8ee2f2a8bf4fa1f..77bcc303c3aeb9214ba4b13098da14fb8bcbe20b 100644 (file)
@@ -2727,6 +2727,9 @@ fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
        inode = file->f_mapping->host;
        i_size = i_size_read(inode);
 
+       if ((rw == READ) && (offset > i_size))
+               return 0;
+
        /* optimization for short read */
        if (async_dio && rw != WRITE && offset + count > i_size) {
                if (offset >= i_size)
diff --git a/fs/generic_acl.c b/fs/generic_acl.c
deleted file mode 100644 (file)
index b3f3676..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * (C) 2005 Andreas Gruenbacher <agruen@suse.de>
- *
- * This file is released under the GPL.
- *
- * Generic ACL support for in-memory filesystems.
- */
-
-#include <linux/sched.h>
-#include <linux/gfp.h>
-#include <linux/fs.h>
-#include <linux/generic_acl.h>
-#include <linux/posix_acl.h>
-#include <linux/posix_acl_xattr.h>
-
-
-static size_t
-generic_acl_list(struct dentry *dentry, char *list, size_t list_size,
-               const char *name, size_t name_len, int type)
-{
-       struct posix_acl *acl;
-       const char *xname;
-       size_t size;
-
-       acl = get_cached_acl(dentry->d_inode, type);
-       if (!acl)
-               return 0;
-       posix_acl_release(acl);
-
-       switch (type) {
-       case ACL_TYPE_ACCESS:
-               xname = POSIX_ACL_XATTR_ACCESS;
-               break;
-       case ACL_TYPE_DEFAULT:
-               xname = POSIX_ACL_XATTR_DEFAULT;
-               break;
-       default:
-               return 0;
-       }
-       size = strlen(xname) + 1;
-       if (list && size <= list_size)
-               memcpy(list, xname, size);
-       return size;
-}
-
-static int
-generic_acl_get(struct dentry *dentry, const char *name, void *buffer,
-                    size_t size, int type)
-{
-       struct posix_acl *acl;
-       int error;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-
-       acl = get_cached_acl(dentry->d_inode, type);
-       if (!acl)
-               return -ENODATA;
-       error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-       posix_acl_release(acl);
-
-       return error;
-}
-
-static int
-generic_acl_set(struct dentry *dentry, const char *name, const void *value,
-                    size_t size, int flags, int type)
-{
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl = NULL;
-       int error;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-       if (value) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-       }
-       if (acl) {
-               error = posix_acl_valid(acl);
-               if (error)
-                       goto failed;
-               switch (type) {
-               case ACL_TYPE_ACCESS:
-                       error = posix_acl_equiv_mode(acl, &inode->i_mode);
-                       if (error < 0)
-                               goto failed;
-                       inode->i_ctime = CURRENT_TIME;
-                       if (error == 0) {
-                               posix_acl_release(acl);
-                               acl = NULL;
-                       }
-                       break;
-               case ACL_TYPE_DEFAULT:
-                       if (!S_ISDIR(inode->i_mode)) {
-                               error = -EINVAL;
-                               goto failed;
-                       }
-                       break;
-               }
-       }
-       set_cached_acl(inode, type, acl);
-       error = 0;
-failed:
-       posix_acl_release(acl);
-       return error;
-}
-
-/**
- * generic_acl_init  -  Take care of acl inheritance at @inode create time
- *
- * Files created inside a directory with a default ACL inherit the
- * directory's default ACL.
- */
-int
-generic_acl_init(struct inode *inode, struct inode *dir)
-{
-       struct posix_acl *acl = NULL;
-       int error;
-
-       if (!S_ISLNK(inode->i_mode))
-               acl = get_cached_acl(dir, ACL_TYPE_DEFAULT);
-       if (acl) {
-               if (S_ISDIR(inode->i_mode))
-                       set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
-               error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
-               if (error < 0)
-                       return error;
-               if (error > 0)
-                       set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
-       } else {
-               inode->i_mode &= ~current_umask();
-       }
-       error = 0;
-
-       posix_acl_release(acl);
-       return error;
-}
-
-/**
- * generic_acl_chmod  -  change the access acl of @inode upon chmod()
- *
- * A chmod also changes the permissions of the owner, group/mask, and
- * other ACL entries.
- */
-int
-generic_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
-       int error = 0;
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
-       if (acl) {
-               error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-               if (error)
-                       return error;
-               set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
-               posix_acl_release(acl);
-       }
-       return error;
-}
-
-const struct xattr_handler generic_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .list   = generic_acl_list,
-       .get    = generic_acl_get,
-       .set    = generic_acl_set,
-};
-
-const struct xattr_handler generic_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = generic_acl_list,
-       .get    = generic_acl_get,
-       .set    = generic_acl_set,
-};
index f69ac0af5496cd456bf6df4d0c932747b6767779..ba9456685f47d761d51afae92a55328e2d54d78a 100644 (file)
@@ -49,10 +49,6 @@ struct posix_acl *gfs2_get_acl(struct inode *inode, int type)
        if (!ip->i_eattr)
                return NULL;
 
-       acl = get_cached_acl(&ip->i_inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        name = gfs2_acl_name(type);
        if (name == NULL)
                return ERR_PTR(-EINVAL);
@@ -80,7 +76,7 @@ static int gfs2_set_mode(struct inode *inode, umode_t mode)
        return error;
 }
 
-static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl)
+int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
        int error;
        int len;
@@ -88,219 +84,49 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl)
        const char *name = gfs2_acl_name(type);
 
        BUG_ON(name == NULL);
-       len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0);
-       if (len == 0)
-               return 0;
-       data = kmalloc(len, GFP_NOFS);
-       if (data == NULL)
-               return -ENOMEM;
-       error = posix_acl_to_xattr(&init_user_ns, acl, data, len);
-       if (error < 0)
-               goto out;
-       error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS);
-       if (!error)
-               set_cached_acl(inode, type, acl);
-out:
-       kfree(data);
-       return error;
-}
-
-int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode)
-{
-       struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
-       struct posix_acl *acl;
-       umode_t mode = inode->i_mode;
-       int error = 0;
-
-       if (!sdp->sd_args.ar_posix_acl)
-               return 0;
-       if (S_ISLNK(inode->i_mode))
-               return 0;
-
-       acl = gfs2_get_acl(&dip->i_inode, ACL_TYPE_DEFAULT);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (!acl) {
-               mode &= ~current_umask();
-               return gfs2_set_mode(inode, mode);
-       }
-
-       if (S_ISDIR(inode->i_mode)) {
-               error = gfs2_acl_set(inode, ACL_TYPE_DEFAULT, acl);
-               if (error)
-                       goto out;
-       }
-
-       error = posix_acl_create(&acl, GFP_NOFS, &mode);
-       if (error < 0)
-               return error;
 
-       if (error == 0)
-               goto munge;
-
-       error = gfs2_acl_set(inode, ACL_TYPE_ACCESS, acl);
-       if (error)
-               goto out;
-munge:
-       error = gfs2_set_mode(inode, mode);
-out:
-       posix_acl_release(acl);
-       return error;
-}
-
-int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr)
-{
-       struct inode *inode = &ip->i_inode;
-       struct posix_acl *acl;
-       char *data;
-       unsigned int len;
-       int error;
-
-       acl = gfs2_get_acl(&ip->i_inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (!acl)
-               return gfs2_setattr_simple(inode, attr);
-
-       error = posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode);
-       if (error)
-               return error;
-
-       len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0);
-       data = kmalloc(len, GFP_NOFS);
-       error = -ENOMEM;
-       if (data == NULL)
-               goto out;
-       posix_acl_to_xattr(&init_user_ns, acl, data, len);
-       error = gfs2_xattr_acl_chmod(ip, attr, data);
-       kfree(data);
-       set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl);
-
-out:
-       posix_acl_release(acl);
-       return error;
-}
-
-static int gfs2_acl_type(const char *name)
-{
-       if (strcmp(name, GFS2_POSIX_ACL_ACCESS) == 0)
-               return ACL_TYPE_ACCESS;
-       if (strcmp(name, GFS2_POSIX_ACL_DEFAULT) == 0)
-               return ACL_TYPE_DEFAULT;
-       return -EINVAL;
-}
-
-static int gfs2_xattr_system_get(struct dentry *dentry, const char *name,
-                                void *buffer, size_t size, int xtype)
-{
-       struct inode *inode = dentry->d_inode;
-       struct gfs2_sbd *sdp = GFS2_SB(inode);
-       struct posix_acl *acl;
-       int type;
-       int error;
-
-       if (!sdp->sd_args.ar_posix_acl)
-               return -EOPNOTSUPP;
-
-       type = gfs2_acl_type(name);
-       if (type < 0)
-               return type;
-
-       acl = gfs2_get_acl(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;
-}
-
-static int gfs2_xattr_system_set(struct dentry *dentry, const char *name,
-                                const void *value, size_t size, int flags,
-                                int xtype)
-{
-       struct inode *inode = dentry->d_inode;
-       struct gfs2_sbd *sdp = GFS2_SB(inode);
-       struct posix_acl *acl = NULL;
-       int error = 0, type;
-
-       if (!sdp->sd_args.ar_posix_acl)
-               return -EOPNOTSUPP;
-
-       type = gfs2_acl_type(name);
-       if (type < 0)
-               return type;
-       if (flags & XATTR_CREATE)
-               return -EINVAL;
-       if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
-               return value ? -EACCES : 0;
-       if (!uid_eq(current_fsuid(), inode->i_uid) && !capable(CAP_FOWNER))
-               return -EPERM;
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       if (!value)
-               goto set_acl;
-
-       acl = posix_acl_from_xattr(&init_user_ns, value, size);
-       if (!acl) {
-               /*
-                * acl_set_file(3) may request that we set default ACLs with
-                * zero length -- defend (gracefully) against that here.
-                */
-               goto out;
-       }
-       if (IS_ERR(acl)) {
-               error = PTR_ERR(acl);
-               goto out;
-       }
-
-       error = posix_acl_valid(acl);
-       if (error)
-               goto out_release;
-
-       error = -EINVAL;
        if (acl->a_count > GFS2_ACL_MAX_ENTRIES)
-               goto out_release;
+               return -EINVAL;
 
        if (type == ACL_TYPE_ACCESS) {
                umode_t mode = inode->i_mode;
+
                error = posix_acl_equiv_mode(acl, &mode);
+               if (error < 0)
+                       return error;
 
-               if (error <= 0) {
-                       posix_acl_release(acl);
+               if (error == 0)
                        acl = NULL;
 
-                       if (error < 0)
-                               return error;
-               }
-
                error = gfs2_set_mode(inode, mode);
                if (error)
-                       goto out_release;
+                       return error;
        }
 
-set_acl:
-       error = __gfs2_xattr_set(inode, name, value, size, 0, GFS2_EATYPE_SYS);
-       if (!error) {
-               if (acl)
-                       set_cached_acl(inode, type, acl);
-               else
-                       forget_cached_acl(inode, type);
+       if (acl) {
+               len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0);
+               if (len == 0)
+                       return 0;
+               data = kmalloc(len, GFP_NOFS);
+               if (data == NULL)
+                       return -ENOMEM;
+               error = posix_acl_to_xattr(&init_user_ns, acl, data, len);
+               if (error < 0)
+                       goto out;
+       } else {
+               data = NULL;
+               len = 0;
        }
-out_release:
-       posix_acl_release(acl);
+
+       error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS);
+       if (error)
+               goto out;
+
+       if (acl)
+               set_cached_acl(inode, type, acl);
+       else
+               forget_cached_acl(inode, type);
 out:
+       kfree(data);
        return error;
 }
-
-const struct xattr_handler gfs2_xattr_system_handler = {
-       .prefix = XATTR_SYSTEM_PREFIX,
-       .flags  = GFS2_EATYPE_SYS,
-       .get    = gfs2_xattr_system_get,
-       .set    = gfs2_xattr_system_set,
-};
-
index 0da38dc7efec24959a1ad656ff2cda8b561db1e0..301260c999ba994bbcab3af270962cd93058dcd9 100644 (file)
@@ -17,8 +17,6 @@
 #define GFS2_ACL_MAX_ENTRIES           25
 
 extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type);
-extern int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode);
-extern int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr);
-extern const struct xattr_handler gfs2_xattr_system_handler;
+extern int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 
 #endif /* __ACL_DOT_H__ */
index 890588c7fb33f79208c3f4203eaf88dadeba8772..5c524180c98e85a50e8e4c63ce233f71ff82ea39 100644 (file)
@@ -571,6 +571,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
                             unsigned int size, int excl, int *opened)
 {
        const struct qstr *name = &dentry->d_name;
+       struct posix_acl *default_acl, *acl;
        struct gfs2_holder ghs[2];
        struct inode *inode = NULL;
        struct gfs2_inode *dip = GFS2_I(dir), *ip;
@@ -633,10 +634,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
        if (!inode)
                goto fail_gunlock;
 
+       error = posix_acl_create(dir, &mode, &default_acl, &acl);
+       if (error)
+               goto fail_free_vfs_inode;
+
        ip = GFS2_I(inode);
        error = gfs2_rs_alloc(ip);
        if (error)
-               goto fail_free_inode;
+               goto fail_free_acls;
 
        inode->i_mode = mode;
        set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
@@ -704,7 +709,16 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
        gfs2_set_iop(inode);
        insert_inode_hash(inode);
 
-       error = gfs2_acl_create(dip, inode);
+       if (default_acl) {
+               error = gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+               posix_acl_release(default_acl);
+       }
+       if (acl) {
+               if (!error)
+                       error = gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS);
+               posix_acl_release(acl);
+       }
+
        if (error)
                goto fail_gunlock3;
 
@@ -738,6 +752,12 @@ fail_free_inode:
        if (ip->i_gl)
                gfs2_glock_put(ip->i_gl);
        gfs2_rs_delete(ip, NULL);
+fail_free_acls:
+       if (default_acl)
+               posix_acl_release(default_acl);
+       if (acl)
+               posix_acl_release(acl);
+fail_free_vfs_inode:
        free_inode_nonrcu(inode);
        inode = NULL;
 fail_gunlock:
@@ -1716,10 +1736,11 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
                error = gfs2_setattr_size(inode, attr->ia_size);
        else if (attr->ia_valid & (ATTR_UID | ATTR_GID))
                error = setattr_chown(inode, attr);
-       else if ((attr->ia_valid & ATTR_MODE) && IS_POSIXACL(inode))
-               error = gfs2_acl_chmod(ip, attr);
-       else
+       else {
                error = gfs2_setattr_simple(inode, attr);
+               if (!error && attr->ia_valid & ATTR_MODE)
+                       error = posix_acl_chmod(inode, inode->i_mode);
+       }
 
 out:
        if (!error)
@@ -1879,6 +1900,7 @@ const struct inode_operations gfs2_file_iops = {
        .removexattr = gfs2_removexattr,
        .fiemap = gfs2_fiemap,
        .get_acl = gfs2_get_acl,
+       .set_acl = gfs2_set_acl,
 };
 
 const struct inode_operations gfs2_dir_iops = {
@@ -1900,6 +1922,7 @@ const struct inode_operations gfs2_dir_iops = {
        .removexattr = gfs2_removexattr,
        .fiemap = gfs2_fiemap,
        .get_acl = gfs2_get_acl,
+       .set_acl = gfs2_set_acl,
        .atomic_open = gfs2_atomic_open,
 };
 
@@ -1915,6 +1938,5 @@ const struct inode_operations gfs2_symlink_iops = {
        .listxattr = gfs2_listxattr,
        .removexattr = gfs2_removexattr,
        .fiemap = gfs2_fiemap,
-       .get_acl = gfs2_get_acl,
 };
 
index 8c6a6f6bdba978f9c3b37703a79d4c409516557b..0b81f783f78724293b174cd997d7f7b7321468b9 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/buffer_head.h>
 #include <linux/xattr.h>
 #include <linux/gfs2_ondisk.h>
+#include <linux/posix_acl_xattr.h>
 #include <asm/uaccess.h>
 
 #include "gfs2.h"
@@ -1500,7 +1501,8 @@ static const struct xattr_handler gfs2_xattr_security_handler = {
 const struct xattr_handler *gfs2_xattr_handlers[] = {
        &gfs2_xattr_user_handler,
        &gfs2_xattr_security_handler,
-       &gfs2_xattr_system_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
        NULL,
 };
 
index 07c0d4947527f33f46b433686e4a996dbb4aa984..95c8ed9ec17f7006940cf9c0fccdfe3c07a7868f 100644 (file)
 
 /* posix_acl.c */
 struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type);
-extern int hfsplus_posix_acl_chmod(struct inode *);
+int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
+               int type);
 extern int hfsplus_init_posix_acl(struct inode *, struct inode *);
 
 #else  /* CONFIG_HFSPLUS_FS_POSIX_ACL */
 #define hfsplus_get_posix_acl NULL
-
-static inline int hfsplus_posix_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
+#define hfsplus_set_posix_acl NULL
 
 static inline int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
 {
index 4a4fea0026735c8fb365d031c57165888e9bb079..9ee62985e739eba797e01318278712be6ee0dfac 100644 (file)
@@ -532,6 +532,7 @@ const struct inode_operations hfsplus_dir_inode_operations = {
        .removexattr            = hfsplus_removexattr,
 #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
        .get_acl                = hfsplus_get_posix_acl,
+       .set_acl                = hfsplus_set_posix_acl,
 #endif
 };
 
index 3ebda928229cb375486da2a05f15e860b5380fbc..4551cbd6bd43aaaebbde666c22c726c76112ab6e 100644 (file)
@@ -261,7 +261,7 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
        mark_inode_dirty(inode);
 
        if (attr->ia_valid & ATTR_MODE) {
-               error = hfsplus_posix_acl_chmod(inode);
+               error = posix_acl_chmod(inode, inode->i_mode);
                if (unlikely(error))
                        return error;
        }
@@ -334,6 +334,7 @@ static const struct inode_operations hfsplus_file_inode_operations = {
        .removexattr    = hfsplus_removexattr,
 #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
        .get_acl        = hfsplus_get_posix_acl,
+       .set_acl        = hfsplus_set_posix_acl,
 #endif
 };
 
index b609cc14c72e03c21063abbda72372c4ef94b1c7..df0c9af68d05ef0df5a127d53562677bc8a2d882 100644 (file)
@@ -17,9 +17,7 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type)
        char *value = NULL;
        ssize_t size;
 
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
+       hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino);
 
        switch (type) {
        case ACL_TYPE_ACCESS:
@@ -56,17 +54,15 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type)
        return acl;
 }
 
-static int hfsplus_set_posix_acl(struct inode *inode,
-                                       int type,
-                                       struct posix_acl *acl)
+int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl,
+               int type)
 {
        int err;
        char *xattr_name;
        size_t size = 0;
        char *value = NULL;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
+       hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino);
 
        switch (type) {
        case ACL_TYPE_ACCESS:
@@ -115,7 +111,7 @@ end_set_acl:
 int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
 {
        int err = 0;
-       struct posix_acl *acl = NULL;
+       struct posix_acl *default_acl, *acl;
 
        hfs_dbg(ACL_MOD,
                "[%s]: ino %lu, dir->ino %lu\n",
@@ -124,151 +120,21 @@ int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir)
        if (S_ISLNK(inode->i_mode))
                return 0;
 
-       acl = hfsplus_get_posix_acl(dir, ACL_TYPE_DEFAULT);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-
-       if (acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       err = hfsplus_set_posix_acl(inode,
-                                                       ACL_TYPE_DEFAULT,
-                                                       acl);
-                       if (unlikely(err))
-                               goto init_acl_cleanup;
-               }
-
-               err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
-               if (unlikely(err < 0))
-                       return err;
-
-               if (err > 0)
-                       err = hfsplus_set_posix_acl(inode,
-                                                       ACL_TYPE_ACCESS,
-                                                       acl);
-       } else
-               inode->i_mode &= ~current_umask();
-
-init_acl_cleanup:
-       posix_acl_release(acl);
-       return err;
-}
-
-int hfsplus_posix_acl_chmod(struct inode *inode)
-{
-       int err;
-       struct posix_acl *acl;
-
-       hfs_dbg(ACL_MOD, "[%s]: ino %lu\n", __func__, inode->i_ino);
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       acl = hfsplus_get_posix_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-
-       err = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (unlikely(err))
+       err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (err)
                return err;
 
-       err = hfsplus_set_posix_acl(inode, ACL_TYPE_ACCESS, acl);
-       posix_acl_release(acl);
-       return err;
-}
-
-static int hfsplus_xattr_get_posix_acl(struct dentry *dentry,
-                                       const char *name,
-                                       void *buffer,
-                                       size_t size,
-                                       int type)
-{
-       int err = 0;
-       struct posix_acl *acl;
-
-       hfs_dbg(ACL_MOD,
-               "[%s]: ino %lu, buffer %p, size %zu, type %#x\n",
-               __func__, dentry->d_inode->i_ino, buffer, size, type);
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-
-       acl = hfsplus_get_posix_acl(dentry->d_inode, type);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (acl == NULL)
-               return -ENODATA;
-
-       err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-       posix_acl_release(acl);
-
-       return err;
-}
-
-static int hfsplus_xattr_set_posix_acl(struct dentry *dentry,
-                                       const char *name,
-                                       const void *value,
-                                       size_t size,
-                                       int flags,
-                                       int type)
-{
-       int err = 0;
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl = NULL;
-
-       hfs_dbg(ACL_MOD,
-               "[%s]: ino %lu, value %p, size %zu, flags %#x, type %#x\n",
-               __func__, inode->i_ino, value, size, flags, type);
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       if (value) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               else if (acl) {
-                       err = posix_acl_valid(acl);
-                       if (err)
-                               goto end_xattr_set_acl;
-               }
+       if (default_acl) {
+               err = hfsplus_set_posix_acl(inode, default_acl,
+                                           ACL_TYPE_DEFAULT);
+               posix_acl_release(default_acl);
        }
 
-       err = hfsplus_set_posix_acl(inode, type, acl);
-
-end_xattr_set_acl:
-       posix_acl_release(acl);
+       if (acl) {
+               if (!err)
+                       err = hfsplus_set_posix_acl(inode, acl,
+                                                   ACL_TYPE_ACCESS);
+               posix_acl_release(acl);
+       }
        return err;
 }
-
-static size_t hfsplus_xattr_list_posix_acl(struct dentry *dentry,
-                                               char *list,
-                                               size_t list_size,
-                                               const char *name,
-                                               size_t name_len,
-                                               int type)
-{
-       /*
-        * This method is not used.
-        * It is used hfsplus_listxattr() instead of generic_listxattr().
-        */
-       return -EOPNOTSUPP;
-}
-
-const struct xattr_handler hfsplus_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .list   = hfsplus_xattr_list_posix_acl,
-       .get    = hfsplus_xattr_get_posix_acl,
-       .set    = hfsplus_xattr_set_posix_acl,
-};
-
-const struct xattr_handler hfsplus_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = hfsplus_xattr_list_posix_acl,
-       .get    = hfsplus_xattr_get_posix_acl,
-       .set    = hfsplus_xattr_set_posix_acl,
-};
index 3c6136f98c737a8d0dc58f2a0cf41712e381ae92..0b4a5c9b93c44ad415f9378c3ec1e3914761c6ef 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "hfsplus_fs.h"
+#include <linux/posix_acl_xattr.h>
 #include "xattr.h"
 #include "acl.h"
 
@@ -15,8 +16,8 @@ const struct xattr_handler *hfsplus_xattr_handlers[] = {
        &hfsplus_xattr_user_handler,
        &hfsplus_xattr_trusted_handler,
 #ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
-       &hfsplus_xattr_acl_access_handler,
-       &hfsplus_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
        &hfsplus_xattr_security_handler,
        NULL
@@ -51,82 +52,6 @@ static inline int is_known_namespace(const char *name)
        return true;
 }
 
-static int can_set_system_xattr(struct inode *inode, const char *name,
-                               const void *value, size_t size)
-{
-#ifdef CONFIG_HFSPLUS_FS_POSIX_ACL
-       struct posix_acl *acl;
-       int err;
-
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       /*
-        * POSIX_ACL_XATTR_ACCESS is tied to i_mode
-        */
-       if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               if (acl) {
-                       err = posix_acl_equiv_mode(acl, &inode->i_mode);
-                       posix_acl_release(acl);
-                       if (err < 0)
-                               return err;
-                       mark_inode_dirty(inode);
-               }
-               /*
-                * We're changing the ACL.  Get rid of the cached one
-                */
-               forget_cached_acl(inode, ACL_TYPE_ACCESS);
-
-               return 0;
-       } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               posix_acl_release(acl);
-
-               /*
-                * We're changing the default ACL.  Get rid of the cached one
-                */
-               forget_cached_acl(inode, ACL_TYPE_DEFAULT);
-
-               return 0;
-       }
-#endif /* CONFIG_HFSPLUS_FS_POSIX_ACL */
-       return -EOPNOTSUPP;
-}
-
-static int can_set_xattr(struct inode *inode, const char *name,
-                               const void *value, size_t value_len)
-{
-       if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
-               return can_set_system_xattr(inode, name, value, value_len);
-
-       if (!strncmp(name, XATTR_MAC_OSX_PREFIX, XATTR_MAC_OSX_PREFIX_LEN)) {
-               /*
-                * This makes sure that we aren't trying to set an
-                * attribute in a different namespace by prefixing it
-                * with "osx."
-                */
-               if (is_known_namespace(name + XATTR_MAC_OSX_PREFIX_LEN))
-                       return -EOPNOTSUPP;
-
-               return 0;
-       }
-
-       /*
-        * Don't allow setting an attribute in an unknown namespace.
-        */
-       if (strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) &&
-           strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) &&
-           strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN))
-               return -EOPNOTSUPP;
-
-       return 0;
-}
-
 static void hfsplus_init_header_node(struct inode *attr_file,
                                        u32 clump_size,
                                        char *buf, u16 node_size)
@@ -349,10 +274,6 @@ int __hfsplus_setxattr(struct inode *inode, const char *name,
                                HFSPLUS_IS_RSRC(inode))
                return -EOPNOTSUPP;
 
-       err = can_set_xattr(inode, name, value, size);
-       if (err)
-               return err;
-
        if (strncmp(name, XATTR_MAC_OSX_PREFIX,
                                XATTR_MAC_OSX_PREFIX_LEN) == 0)
                name += XATTR_MAC_OSX_PREFIX_LEN;
@@ -840,10 +761,6 @@ int hfsplus_removexattr(struct dentry *dentry, const char *name)
        if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
                return -EOPNOTSUPP;
 
-       err = can_set_xattr(inode, name, NULL, 0);
-       if (err)
-               return err;
-
        if (strncmp(name, XATTR_MAC_OSX_PREFIX,
                                XATTR_MAC_OSX_PREFIX_LEN) == 0)
                name += XATTR_MAC_OSX_PREFIX_LEN;
@@ -940,6 +857,9 @@ static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name,
        if (len > HFSPLUS_ATTR_MAX_STRLEN)
                return -EOPNOTSUPP;
 
+       if (is_known_namespace(name))
+               return -EOPNOTSUPP;
+
        strcpy(xattr_name, XATTR_MAC_OSX_PREFIX);
        strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name);
 
index 841b5698c0fc4b5375c8d5e153fea62bdc931da9..9e214490c313f6b61204db43e7317f2aac086e5c 100644 (file)
@@ -14,8 +14,6 @@
 extern const struct xattr_handler hfsplus_xattr_osx_handler;
 extern const struct xattr_handler hfsplus_xattr_user_handler;
 extern const struct xattr_handler hfsplus_xattr_trusted_handler;
-extern const struct xattr_handler hfsplus_xattr_acl_access_handler;
-extern const struct xattr_handler hfsplus_xattr_acl_default_handler;
 extern const struct xattr_handler hfsplus_xattr_security_handler;
 
 extern const struct xattr_handler *hfsplus_xattr_handlers[];
index 223283c301116f3d8d88cb70cf30aa030a54c456..009ec0b5993da879846ba7a733864116684026ca 100644 (file)
@@ -178,10 +178,6 @@ struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
        char *value = NULL;
        int rc, xprefix;
 
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                xprefix = JFFS2_XPREFIX_ACL_ACCESS;
@@ -232,13 +228,10 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *a
        return rc;
 }
 
-static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
+int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
        int rc, xprefix;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                xprefix = JFFS2_XPREFIX_ACL_ACCESS;
@@ -277,30 +270,21 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
 
 int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, umode_t *i_mode)
 {
-       struct posix_acl *acl;
+       struct posix_acl *default_acl, *acl;
        int rc;
 
        cache_no_acl(inode);
 
-       if (S_ISLNK(*i_mode))
-               return 0;       /* Symlink always has no-ACL */
-
-       acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-
-       if (!acl) {
-               *i_mode &= ~current_umask();
-       } else {
-               if (S_ISDIR(*i_mode))
-                       set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
-
-               rc = posix_acl_create(&acl, GFP_KERNEL, i_mode);
-               if (rc < 0)
-                       return rc;
-               if (rc > 0)
-                       set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
+       rc = posix_acl_create(dir_i, i_mode, &default_acl, &acl);
+       if (rc)
+               return rc;
 
+       if (default_acl) {
+               set_cached_acl(inode, ACL_TYPE_DEFAULT, default_acl);
+               posix_acl_release(default_acl);
+       }
+       if (acl) {
+               set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
                posix_acl_release(acl);
        }
        return 0;
@@ -324,106 +308,3 @@ int jffs2_init_acl_post(struct inode *inode)
 
        return 0;
 }
-
-int jffs2_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
-       int rc;
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-       acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-       rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (rc)
-               return rc;
-       rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, acl);
-       posix_acl_release(acl);
-       return rc;
-}
-
-static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list,
-               size_t list_size, const char *name, size_t name_len, int type)
-{
-       const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS);
-
-       if (list && retlen <= list_size)
-               strcpy(list, POSIX_ACL_XATTR_ACCESS);
-       return retlen;
-}
-
-static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list,
-               size_t list_size, const char *name, size_t name_len, int type)
-{
-       const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT);
-
-       if (list && retlen <= list_size)
-               strcpy(list, POSIX_ACL_XATTR_DEFAULT);
-       return retlen;
-}
-
-static int jffs2_acl_getxattr(struct dentry *dentry, const char *name,
-               void *buffer, size_t size, int type)
-{
-       struct posix_acl *acl;
-       int rc;
-
-       if (name[0] != '\0')
-               return -EINVAL;
-
-       acl = jffs2_get_acl(dentry->d_inode, type);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (!acl)
-               return -ENODATA;
-       rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-       posix_acl_release(acl);
-
-       return rc;
-}
-
-static int jffs2_acl_setxattr(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags, int type)
-{
-       struct posix_acl *acl;
-       int rc;
-
-       if (name[0] != '\0')
-               return -EINVAL;
-       if (!inode_owner_or_capable(dentry->d_inode))
-               return -EPERM;
-
-       if (value) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               if (acl) {
-                       rc = posix_acl_valid(acl);
-                       if (rc)
-                               goto out;
-               }
-       } else {
-               acl = NULL;
-       }
-       rc = jffs2_set_acl(dentry->d_inode, type, acl);
- out:
-       posix_acl_release(acl);
-       return rc;
-}
-
-const struct xattr_handler jffs2_acl_access_xattr_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = jffs2_acl_access_listxattr,
-       .get    = jffs2_acl_getxattr,
-       .set    = jffs2_acl_setxattr,
-};
-
-const struct xattr_handler jffs2_acl_default_xattr_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = jffs2_acl_default_listxattr,
-       .get    = jffs2_acl_getxattr,
-       .set    = jffs2_acl_setxattr,
-};
index 9b477246f2a6ec1c0e0f0b9a34c870f44e6ba734..2e2b5745c3b75d42caea23256ccc4bfc6dacb039 100644 (file)
@@ -27,17 +27,14 @@ struct jffs2_acl_header {
 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
 
 struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
-extern int jffs2_acl_chmod(struct inode *);
+int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
 extern int jffs2_init_acl_post(struct inode *);
 
-extern const struct xattr_handler jffs2_acl_access_xattr_handler;
-extern const struct xattr_handler jffs2_acl_default_xattr_handler;
-
 #else
 
 #define jffs2_get_acl                          (NULL)
-#define jffs2_acl_chmod(inode)                 (0)
+#define jffs2_set_acl                          (NULL)
 #define jffs2_init_acl_pre(dir_i,inode,mode)   (0)
 #define jffs2_init_acl_post(inode)             (0)
 
index e3aac222472e1f06e9d998f46323b4d8be0e1071..938556025d643349b5166e54b5cfc55ea4767dbe 100644 (file)
@@ -59,6 +59,7 @@ const struct inode_operations jffs2_dir_inode_operations =
        .mknod =        jffs2_mknod,
        .rename =       jffs2_rename,
        .get_acl =      jffs2_get_acl,
+       .set_acl =      jffs2_set_acl,
        .setattr =      jffs2_setattr,
        .setxattr =     jffs2_setxattr,
        .getxattr =     jffs2_getxattr,
index 1506673c087e11ae820245baadc8ae74cb9f01b2..256cd19a3b78c006a1439f893b1b51a0341c938a 100644 (file)
@@ -66,6 +66,7 @@ const struct file_operations jffs2_file_operations =
 const struct inode_operations jffs2_file_inode_operations =
 {
        .get_acl =      jffs2_get_acl,
+       .set_acl =      jffs2_set_acl,
        .setattr =      jffs2_setattr,
        .setxattr =     jffs2_setxattr,
        .getxattr =     jffs2_getxattr,
index 09b3ed45572475feb68b117fcf5b420a1a5e4d8f..a69e426435ddc3d2d207701df7a5b06264c1c481 100644 (file)
@@ -190,15 +190,16 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
 
 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
 {
+       struct inode *inode = dentry->d_inode;
        int rc;
 
-       rc = inode_change_ok(dentry->d_inode, iattr);
+       rc = inode_change_ok(inode, iattr);
        if (rc)
                return rc;
 
-       rc = jffs2_do_setattr(dentry->d_inode, iattr);
+       rc = jffs2_do_setattr(inode, iattr);
        if (!rc && (iattr->ia_valid & ATTR_MODE))
-               rc = jffs2_acl_chmod(dentry->d_inode);
+               rc = posix_acl_chmod(inode, inode->i_mode);
 
        return rc;
 }
index 6e563332bb242e2d4214026fa4ff608bcd69cf94..c7c77b0dfccde2fe5dedb619500fb8f4f4a1f866 100644 (file)
@@ -22,7 +22,6 @@ const struct inode_operations jffs2_symlink_inode_operations =
 {
        .readlink =     generic_readlink,
        .follow_link =  jffs2_follow_link,
-       .get_acl =      jffs2_get_acl,
        .setattr =      jffs2_setattr,
        .setxattr =     jffs2_setxattr,
        .getxattr =     jffs2_getxattr,
index 3034e970eb9a130cea79d7d413aa2463070408ff..ad0f2e2a1700835d596e656b540ec0ac06cafd90 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/crc32.h>
 #include <linux/jffs2.h>
 #include <linux/xattr.h>
+#include <linux/posix_acl_xattr.h>
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
 /* -------- xdatum related functions ----------------
@@ -921,8 +922,8 @@ const struct xattr_handler *jffs2_xattr_handlers[] = {
        &jffs2_security_xattr_handler,
 #endif
 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
-       &jffs2_acl_access_xattr_handler,
-       &jffs2_acl_default_xattr_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
        &jffs2_trusted_xattr_handler,
        NULL
@@ -942,10 +943,10 @@ static const struct xattr_handler *xprefix_to_handler(int xprefix) {
 #endif
 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
        case JFFS2_XPREFIX_ACL_ACCESS:
-               ret = &jffs2_acl_access_xattr_handler;
+               ret = &posix_acl_access_xattr_handler;
                break;
        case JFFS2_XPREFIX_ACL_DEFAULT:
-               ret = &jffs2_acl_default_xattr_handler;
+               ret = &posix_acl_default_xattr_handler;
                break;
 #endif
        case JFFS2_XPREFIX_TRUSTED:
index d254d6d3599565fbca59621cf840d105d9cd4971..e973b85d6afd9f136bcae002cbe70432000e5a15 100644 (file)
@@ -72,7 +72,7 @@ struct posix_acl *jfs_get_acl(struct inode *inode, int type)
        return acl;
 }
 
-static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
+static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
                       struct posix_acl *acl)
 {
        char *ea_name;
@@ -80,21 +80,22 @@ static int jfs_set_acl(tid_t tid, struct inode *inode, int type,
        int size = 0;
        char *value = NULL;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       ea_name = POSIX_ACL_XATTR_ACCESS;
-                       break;
-               case ACL_TYPE_DEFAULT:
-                       ea_name = POSIX_ACL_XATTR_DEFAULT;
-                       if (!S_ISDIR(inode->i_mode))
-                               return acl ? -EACCES : 0;
-                       break;
-               default:
-                       return -EINVAL;
+       switch (type) {
+       case ACL_TYPE_ACCESS:
+               ea_name = POSIX_ACL_XATTR_ACCESS;
+               rc = posix_acl_equiv_mode(acl, &inode->i_mode);
+               if (rc < 0)
+                       return rc;
+               if (rc == 0)
+                       acl = NULL;
+               break;
+       case ACL_TYPE_DEFAULT:
+               ea_name = POSIX_ACL_XATTR_DEFAULT;
+               break;
+       default:
+               return -EINVAL;
        }
+
        if (acl) {
                size = posix_acl_xattr_size(acl->a_count);
                value = kmalloc(size, GFP_KERNEL);
@@ -114,65 +115,43 @@ out:
        return rc;
 }
 
+int jfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+       int rc;
+       tid_t tid;
+
+       tid = txBegin(inode->i_sb, 0);
+       mutex_lock(&JFS_IP(inode)->commit_mutex);
+       rc = __jfs_set_acl(tid, inode, type, acl);
+       if (!rc)
+               rc = txCommit(tid, 1, &inode, 0);
+       txEnd(tid);
+       mutex_unlock(&JFS_IP(inode)->commit_mutex);
+       return rc;
+}
+
 int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
 {
-       struct posix_acl *acl = NULL;
+       struct posix_acl *default_acl, *acl;
        int rc = 0;
 
-       if (S_ISLNK(inode->i_mode))
-               return 0;
+       rc = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (rc)
+               return rc;
 
-       acl = jfs_get_acl(dir, ACL_TYPE_DEFAULT);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
+       if (default_acl) {
+               rc = __jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, default_acl);
+               posix_acl_release(default_acl);
+       }
 
        if (acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl);
-                       if (rc)
-                               goto cleanup;
-               }
-               rc = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
-               if (rc < 0)
-                       goto cleanup; /* posix_acl_release(NULL) is no-op */
-               if (rc > 0)
-                       rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
-cleanup:
+               if (!rc)
+                       rc = __jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
                posix_acl_release(acl);
-       } else
-               inode->i_mode &= ~current_umask();
+       }
 
        JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) |
                               inode->i_mode;
 
        return rc;
 }
-
-int jfs_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
-       int rc;
-       tid_t tid;
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       acl = jfs_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-
-       rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (rc)
-               return rc;
-
-       tid = txBegin(inode->i_sb, 0);
-       mutex_lock(&JFS_IP(inode)->commit_mutex);
-       rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
-       if (!rc)
-               rc = txCommit(tid, 1, &inode, 0);
-       txEnd(tid);
-       mutex_unlock(&JFS_IP(inode)->commit_mutex);
-
-       posix_acl_release(acl);
-       return rc;
-}
index dd7442c5835864b0e04bdff5befbd0f020232bfb..794da944d5cd29c63d8db31040340e83d7079d87 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/posix_acl.h>
 #include <linux/quotaops.h>
 #include "jfs_incore.h"
 #include "jfs_inode.h"
@@ -131,7 +132,7 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
        mark_inode_dirty(inode);
 
        if (iattr->ia_valid & ATTR_MODE)
-               rc = jfs_acl_chmod(inode);
+               rc = posix_acl_chmod(inode, inode->i_mode);
        return rc;
 }
 
@@ -143,6 +144,7 @@ const struct inode_operations jfs_file_inode_operations = {
        .setattr        = jfs_setattr,
 #ifdef CONFIG_JFS_POSIX_ACL
        .get_acl        = jfs_get_acl,
+       .set_acl        = jfs_set_acl,
 #endif
 };
 
index ad84fe50ca9e897362caa12101d63a590b56073f..489f993b7b137060a9df603bffbab24ba75d4d66 100644 (file)
@@ -21,8 +21,8 @@
 #ifdef CONFIG_JFS_POSIX_ACL
 
 struct posix_acl *jfs_get_acl(struct inode *inode, int type);
+int jfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 int jfs_init_acl(tid_t, struct inode *, struct inode *);
-int jfs_acl_chmod(struct inode *inode);
 
 #else
 
@@ -32,10 +32,5 @@ static inline int jfs_init_acl(tid_t tid, struct inode *inode,
        return 0;
 }
 
-static inline int jfs_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
-
 #endif
 #endif         /* _H_JFS_ACL */
index e9e100fd7c09a90a7ba603e7f1282ae9ba15e164..e8d717dabca3eb5a2e3bcff902c34b8376b8450d 100644 (file)
@@ -61,6 +61,8 @@ extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
 extern int jfs_removexattr(struct dentry *, const char *);
 
+extern const struct xattr_handler *jfs_xattr_handlers[];
+
 #ifdef CONFIG_JFS_SECURITY
 extern int jfs_init_security(tid_t, struct inode *, struct inode *,
                             const struct qstr *);
index aa8a3370631bd8da9475394ef9f571ed90c620ff..d59c7defb1efea8bb46bea33ddffe2c384db390b 100644 (file)
@@ -1524,6 +1524,7 @@ const struct inode_operations jfs_dir_inode_operations = {
        .setattr        = jfs_setattr,
 #ifdef CONFIG_JFS_POSIX_ACL
        .get_acl        = jfs_get_acl,
+       .set_acl        = jfs_set_acl,
 #endif
 };
 
index 6669aa2042c30154e0ad318ff5d6d657a2b60f61..e2b7483444fd0dc7163cf1d4ab651917b824965e 100644 (file)
@@ -44,6 +44,7 @@
 #include "jfs_imap.h"
 #include "jfs_acl.h"
 #include "jfs_debug.h"
+#include "jfs_xattr.h"
 
 MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
 MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
@@ -522,6 +523,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
         */
        sb->s_op = &jfs_super_operations;
        sb->s_export_op = &jfs_export_operations;
+       sb->s_xattr = jfs_xattr_handlers;
 #ifdef CONFIG_QUOTA
        sb->dq_op = &dquot_operations;
        sb->s_qcop = &dquot_quotactl_ops;
index d3472f4cd5301e1c3ac48817755a0c62f8f6975c..5324e4e2b9924babb2675451ed074f4a279d2ad4 100644 (file)
@@ -665,82 +665,13 @@ static int ea_put(tid_t tid, struct inode *inode, struct ea_buffer *ea_buf,
        return 0;
 }
 
-/*
- * can_set_system_xattr
- *
- * This code is specific to the system.* namespace.  It contains policy
- * which doesn't belong in the main xattr codepath.
- */
-static int can_set_system_xattr(struct inode *inode, const char *name,
-                               const void *value, size_t value_len)
-{
-#ifdef CONFIG_JFS_POSIX_ACL
-       struct posix_acl *acl;
-       int rc;
-
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       /*
-        * POSIX_ACL_XATTR_ACCESS is tied to i_mode
-        */
-       if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, value_len);
-               if (IS_ERR(acl)) {
-                       rc = PTR_ERR(acl);
-                       printk(KERN_ERR "posix_acl_from_xattr returned %d\n",
-                              rc);
-                       return rc;
-               }
-               if (acl) {
-                       rc = posix_acl_equiv_mode(acl, &inode->i_mode);
-                       posix_acl_release(acl);
-                       if (rc < 0) {
-                               printk(KERN_ERR
-                                      "posix_acl_equiv_mode returned %d\n",
-                                      rc);
-                               return rc;
-                       }
-                       mark_inode_dirty(inode);
-               }
-               /*
-                * We're changing the ACL.  Get rid of the cached one
-                */
-               forget_cached_acl(inode, ACL_TYPE_ACCESS);
-
-               return 0;
-       } else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, value_len);
-               if (IS_ERR(acl)) {
-                       rc = PTR_ERR(acl);
-                       printk(KERN_ERR "posix_acl_from_xattr returned %d\n",
-                              rc);
-                       return rc;
-               }
-               posix_acl_release(acl);
-
-               /*
-                * We're changing the default ACL.  Get rid of the cached one
-                */
-               forget_cached_acl(inode, ACL_TYPE_DEFAULT);
-
-               return 0;
-       }
-#endif                 /* CONFIG_JFS_POSIX_ACL */
-       return -EOPNOTSUPP;
-}
-
 /*
  * Most of the permission checking is done by xattr_permission in the vfs.
- * The local file system is responsible for handling the system.* namespace.
  * We also need to verify that this is a namespace that we recognize.
  */
 static int can_set_xattr(struct inode *inode, const char *name,
                         const void *value, size_t value_len)
 {
-       if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
-               return can_set_system_xattr(inode, name, value, value_len);
-
        if (!strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN)) {
                /*
                 * This makes sure that we aren't trying to set an
@@ -748,7 +679,7 @@ static int can_set_xattr(struct inode *inode, const char *name,
                 * with "os2."
                 */
                if (is_known_namespace(name + XATTR_OS2_PREFIX_LEN))
-                               return -EOPNOTSUPP;
+                       return -EOPNOTSUPP;
                return 0;
        }
 
@@ -913,6 +844,14 @@ int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
        if ((rc = can_set_xattr(inode, name, value, value_len)))
                return rc;
 
+       /*
+        * If this is a request for a synthetic attribute in the system.*
+        * namespace use the generic infrastructure to resolve a handler
+        * for it via sb->s_xattr.
+        */
+       if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
+               return generic_setxattr(dentry, name, value, value_len, flags);
+
        if (value == NULL) {    /* empty EA, do not remove */
                value = "";
                value_len = 0;
@@ -986,6 +925,14 @@ ssize_t jfs_getxattr(struct dentry *dentry, const char *name, void *data,
 {
        int err;
 
+       /*
+        * If this is a request for a synthetic attribute in the system.*
+        * namespace use the generic infrastructure to resolve a handler
+        * for it via sb->s_xattr.
+        */
+       if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
+               return generic_getxattr(dentry, name, data, buf_size);
+
        if (strncmp(name, XATTR_OS2_PREFIX, XATTR_OS2_PREFIX_LEN) == 0) {
                /*
                 * skip past "os2." prefix
@@ -1077,6 +1024,14 @@ int jfs_removexattr(struct dentry *dentry, const char *name)
        if ((rc = can_set_xattr(inode, name, NULL, 0)))
                return rc;
 
+       /*
+        * If this is a request for a synthetic attribute in the system.*
+        * namespace use the generic infrastructure to resolve a handler
+        * for it via sb->s_xattr.
+        */
+       if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN))
+               return generic_removexattr(dentry, name);
+
        tid = txBegin(inode->i_sb, 0);
        mutex_lock(&ji->commit_mutex);
        rc = __jfs_setxattr(tid, dentry->d_inode, name, NULL, 0, XATTR_REPLACE);
@@ -1088,6 +1043,19 @@ int jfs_removexattr(struct dentry *dentry, const char *name)
        return rc;
 }
 
+/*
+ * List of handlers for synthetic system.* attributes.  All real ondisk
+ * attributes are handled directly.
+ */
+const struct xattr_handler *jfs_xattr_handlers[] = {
+#ifdef JFS_POSIX_ACL
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
+#endif
+       NULL,
+};
+
+
 #ifdef CONFIG_JFS_SECURITY
 static int jfs_initxattrs(struct inode *inode, const struct xattr *xattr_array,
                          void *fs_info)
index d64c594be6c47baf29a70ffe63671f307cba4b7e..a17458ca6f29e4dbf1f1a1b8bb9e97949b279d29 100644 (file)
@@ -74,7 +74,7 @@ static inline int mnt_has_parent(struct mount *mnt)
 static inline int is_mounted(struct vfsmount *mnt)
 {
        /* neither detached nor internal? */
-       return !IS_ERR_OR_NULL(real_mount(mnt));
+       return !IS_ERR_OR_NULL(real_mount(mnt)->mnt_ns);
 }
 
 extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *);
index 3531deebad3084104e6a9fca7116ba68890ad5af..bcb838e2e52f24593da609abba67dc5ab5336947 100644 (file)
@@ -235,27 +235,9 @@ static int check_acl(struct inode *inode, int mask)
                return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK);
        }
 
-       acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
-
-       /*
-        * A filesystem can force a ACL callback by just never filling the
-        * ACL cache. But normally you'd fill the cache either at inode
-        * instantiation time, or on the first ->get_acl call.
-        *
-        * If the filesystem doesn't have a get_acl() function at all, we'll
-        * just create the negative cache entry.
-        */
-       if (acl == ACL_NOT_CACHED) {
-               if (inode->i_op->get_acl) {
-                       acl = inode->i_op->get_acl(inode, ACL_TYPE_ACCESS);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               } else {
-                       set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);
-                       return -EAGAIN;
-               }
-       }
-
+       acl = get_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);
index 00ad1c2b217ded2338c0ac4154681f83963581ab..ecd11ba7f960f1b8c75743b6379ea6f27425462b 100644 (file)
@@ -1641,10 +1641,6 @@ struct inode *nfs_alloc_inode(struct super_block *sb)
                return NULL;
        nfsi->flags = 0UL;
        nfsi->cache_validity = 0UL;
-#ifdef CONFIG_NFS_V3_ACL
-       nfsi->acl_access = ERR_PTR(-EAGAIN);
-       nfsi->acl_default = ERR_PTR(-EAGAIN);
-#endif
 #if IS_ENABLED(CONFIG_NFS_V4)
        nfsi->nfs4_acl = NULL;
 #endif /* CONFIG_NFS_V4 */
index 4a1aafba6a20030532ba589ac9db021b10c21ceb..9a5ca03fa539fc5fb61ea4516b0ce0b6f4ae10ea 100644 (file)
 
 #define NFSDBG_FACILITY        NFSDBG_PROC
 
-ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size)
-{
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl;
-       int pos=0, len=0;
-
-#      define output(s) do {                                           \
-                       if (pos + sizeof(s) <= size) {                  \
-                               memcpy(buffer + pos, s, sizeof(s));     \
-                               pos += sizeof(s);                       \
-                       }                                               \
-                       len += sizeof(s);                               \
-               } while(0)
-
-       acl = nfs3_proc_getacl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (acl) {
-               output("system.posix_acl_access");
-               posix_acl_release(acl);
-       }
-
-       if (S_ISDIR(inode->i_mode)) {
-               acl = nfs3_proc_getacl(inode, ACL_TYPE_DEFAULT);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               if (acl) {
-                       output("system.posix_acl_default");
-                       posix_acl_release(acl);
-               }
-       }
-
-#      undef output
-
-       if (!buffer || len <= size)
-               return len;
-       return -ERANGE;
-}
-
-ssize_t nfs3_getxattr(struct dentry *dentry, const char *name,
-               void *buffer, size_t size)
-{
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl;
-       int type, error = 0;
-
-       if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0)
-               type = ACL_TYPE_ACCESS;
-       else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0)
-               type = ACL_TYPE_DEFAULT;
-       else
-               return -EOPNOTSUPP;
-
-       acl = nfs3_proc_getacl(inode, type);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       else if (acl) {
-               if (type == ACL_TYPE_ACCESS && acl->a_count == 0)
-                       error = -ENODATA;
-               else
-                       error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-               posix_acl_release(acl);
-       } else
-               error = -ENODATA;
-
-       return error;
-}
-
-int nfs3_setxattr(struct dentry *dentry, const char *name,
-            const void *value, size_t size, int flags)
-{
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl;
-       int type, error;
-
-       if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0)
-               type = ACL_TYPE_ACCESS;
-       else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0)
-               type = ACL_TYPE_DEFAULT;
-       else
-               return -EOPNOTSUPP;
-
-       acl = posix_acl_from_xattr(&init_user_ns, value, size);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       error = nfs3_proc_setacl(inode, type, acl);
-       posix_acl_release(acl);
-
-       return error;
-}
-
-int nfs3_removexattr(struct dentry *dentry, const char *name)
-{
-       struct inode *inode = dentry->d_inode;
-       int type;
-
-       if (strcmp(name, POSIX_ACL_XATTR_ACCESS) == 0)
-               type = ACL_TYPE_ACCESS;
-       else if (strcmp(name, POSIX_ACL_XATTR_DEFAULT) == 0)
-               type = ACL_TYPE_DEFAULT;
-       else
-               return -EOPNOTSUPP;
-
-       return nfs3_proc_setacl(inode, type, NULL);
-}
-
-static void __nfs3_forget_cached_acls(struct nfs_inode *nfsi)
-{
-       if (!IS_ERR(nfsi->acl_access)) {
-               posix_acl_release(nfsi->acl_access);
-               nfsi->acl_access = ERR_PTR(-EAGAIN);
-       }
-       if (!IS_ERR(nfsi->acl_default)) {
-               posix_acl_release(nfsi->acl_default);
-               nfsi->acl_default = ERR_PTR(-EAGAIN);
-       }
-}
-
-void nfs3_forget_cached_acls(struct inode *inode)
-{
-       dprintk("NFS: nfs3_forget_cached_acls(%s/%ld)\n", inode->i_sb->s_id,
-               inode->i_ino);
-       spin_lock(&inode->i_lock);
-       __nfs3_forget_cached_acls(NFS_I(inode));
-       spin_unlock(&inode->i_lock);
-}
-
-static struct posix_acl *nfs3_get_cached_acl(struct inode *inode, int type)
-{
-       struct nfs_inode *nfsi = NFS_I(inode);
-       struct posix_acl *acl = ERR_PTR(-EINVAL);
-
-       spin_lock(&inode->i_lock);
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       acl = nfsi->acl_access;
-                       break;
-
-               case ACL_TYPE_DEFAULT:
-                       acl = nfsi->acl_default;
-                       break;
-
-               default:
-                       goto out;
-       }
-       if (IS_ERR(acl))
-               acl = ERR_PTR(-EAGAIN);
-       else
-               acl = posix_acl_dup(acl);
-out:
-       spin_unlock(&inode->i_lock);
-       dprintk("NFS: nfs3_get_cached_acl(%s/%ld, %d) = %p\n", inode->i_sb->s_id,
-               inode->i_ino, type, acl);
-       return acl;
-}
-
-static void nfs3_cache_acls(struct inode *inode, struct posix_acl *acl,
-                   struct posix_acl *dfacl)
-{
-       struct nfs_inode *nfsi = NFS_I(inode);
-
-       dprintk("nfs3_cache_acls(%s/%ld, %p, %p)\n", inode->i_sb->s_id,
-               inode->i_ino, acl, dfacl);
-       spin_lock(&inode->i_lock);
-       __nfs3_forget_cached_acls(NFS_I(inode));
-       if (!IS_ERR(acl))
-               nfsi->acl_access = posix_acl_dup(acl);
-       if (!IS_ERR(dfacl))
-               nfsi->acl_default = posix_acl_dup(dfacl);
-       spin_unlock(&inode->i_lock);
-}
-
-struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
+struct posix_acl *nfs3_get_acl(struct inode *inode, int type)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct page *pages[NFSACL_MAXPAGES] = { };
@@ -198,7 +26,6 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
                .rpc_argp       = &args,
                .rpc_resp       = &res,
        };
-       struct posix_acl *acl;
        int status, count;
 
        if (!nfs_server_capable(inode, NFS_CAP_ACLS))
@@ -207,10 +34,6 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
        status = nfs_revalidate_inode(server, inode);
        if (status < 0)
                return ERR_PTR(status);
-       acl = nfs3_get_cached_acl(inode, type);
-       if (acl != ERR_PTR(-EAGAIN))
-               return acl;
-       acl = NULL;
 
        /*
         * Only get the access acl when explicitly requested: We don't
@@ -257,40 +80,41 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type)
        }
 
        if (res.acl_access != NULL) {
-               if (posix_acl_equiv_mode(res.acl_access, NULL) == 0) {
+               if (posix_acl_equiv_mode(res.acl_access, NULL) ||
+                   res.acl_access->a_count == 0) {
                        posix_acl_release(res.acl_access);
                        res.acl_access = NULL;
                }
        }
-       nfs3_cache_acls(inode,
-               (res.mask & NFS_ACL)   ? res.acl_access  : ERR_PTR(-EINVAL),
-               (res.mask & NFS_DFACL) ? res.acl_default : ERR_PTR(-EINVAL));
 
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       acl = res.acl_access;
-                       res.acl_access = NULL;
-                       break;
+       if (res.mask & NFS_ACL)
+               set_cached_acl(inode, ACL_TYPE_ACCESS, res.acl_access);
+       else
+               forget_cached_acl(inode, ACL_TYPE_ACCESS);
 
-               case ACL_TYPE_DEFAULT:
-                       acl = res.acl_default;
-                       res.acl_default = NULL;
+       if (res.mask & NFS_DFACL)
+               set_cached_acl(inode, ACL_TYPE_DEFAULT, res.acl_default);
+       else
+               forget_cached_acl(inode, ACL_TYPE_DEFAULT);
+
+       nfs_free_fattr(res.fattr);
+       if (type == ACL_TYPE_ACCESS) {
+               posix_acl_release(res.acl_default);
+               return res.acl_access;
+       } else {
+               posix_acl_release(res.acl_access);
+               return res.acl_default;
        }
 
 getout:
        posix_acl_release(res.acl_access);
        posix_acl_release(res.acl_default);
        nfs_free_fattr(res.fattr);
-
-       if (status != 0) {
-               posix_acl_release(acl);
-               acl = ERR_PTR(status);
-       }
-       return acl;
+       return ERR_PTR(status);
 }
 
-static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
-                 struct posix_acl *dfacl)
+int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
+               struct posix_acl *dfacl)
 {
        struct nfs_server *server = NFS_SERVER(inode);
        struct nfs_fattr *fattr;
@@ -353,7 +177,8 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
        switch (status) {
                case 0:
                        status = nfs_refresh_inode(inode, fattr);
-                       nfs3_cache_acls(inode, acl, dfacl);
+                       set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
+                       set_cached_acl(inode, ACL_TYPE_DEFAULT, dfacl);
                        break;
                case -EPFNOSUPPORT:
                case -EPROTONOSUPPORT:
@@ -373,33 +198,27 @@ out:
        return status;
 }
 
-int nfs3_proc_setacl(struct inode *inode, int type, struct posix_acl *acl)
+int nfs3_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
        struct posix_acl *alloc = NULL, *dfacl = NULL;
        int status;
 
        if (S_ISDIR(inode->i_mode)) {
                switch(type) {
-                       case ACL_TYPE_ACCESS:
-                               alloc = dfacl = nfs3_proc_getacl(inode,
-                                               ACL_TYPE_DEFAULT);
-                               if (IS_ERR(alloc))
-                                       goto fail;
-                               break;
-
-                       case ACL_TYPE_DEFAULT:
-                               dfacl = acl;
-                               alloc = acl = nfs3_proc_getacl(inode,
-                                               ACL_TYPE_ACCESS);
-                               if (IS_ERR(alloc))
-                                       goto fail;
-                               break;
-
-                       default:
-                               return -EINVAL;
+               case ACL_TYPE_ACCESS:
+                       alloc = dfacl = get_acl(inode, ACL_TYPE_DEFAULT);
+                       if (IS_ERR(alloc))
+                               goto fail;
+                       break;
+
+               case ACL_TYPE_DEFAULT:
+                       dfacl = acl;
+                       alloc = acl = get_acl(inode, ACL_TYPE_ACCESS);
+                       if (IS_ERR(alloc))
+                               goto fail;
+                       break;
                }
-       } else if (type != ACL_TYPE_ACCESS)
-                       return -EINVAL;
+       }
 
        if (acl == NULL) {
                alloc = acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
@@ -417,24 +236,24 @@ fail:
 int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode,
                umode_t mode)
 {
-       struct posix_acl *dfacl, *acl;
-       int error = 0;
+       struct posix_acl *default_acl, *acl;
+       int error;
 
-       dfacl = nfs3_proc_getacl(dir, ACL_TYPE_DEFAULT);
-       if (IS_ERR(dfacl)) {
-               error = PTR_ERR(dfacl);
+       error = posix_acl_create(dir, &mode, &default_acl, &acl);
+       if (error)
                return (error == -EOPNOTSUPP) ? 0 : error;
-       }
-       if (!dfacl)
-               return 0;
-       acl = posix_acl_dup(dfacl);
-       error = posix_acl_create(&acl, GFP_KERNEL, &mode);
-       if (error < 0)
-               goto out_release_dfacl;
-       error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ?
-                                                     dfacl : NULL);
-       posix_acl_release(acl);
-out_release_dfacl:
-       posix_acl_release(dfacl);
+
+       error = nfs3_proc_setacls(inode, acl, default_acl);
+
+       if (acl)
+               posix_acl_release(acl);
+       if (default_acl)
+               posix_acl_release(default_acl);
        return error;
 }
+
+const struct xattr_handler *nfs3_xattr_handlers[] = {
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
+       NULL,
+};
index 01b6f6a49d162ef0ea8720786e259fd5f66aa9d3..d2255d7054210ef1daf54396d804bf6a45109ace 100644 (file)
@@ -317,8 +317,8 @@ static int
 nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                 int flags)
 {
+       struct posix_acl *default_acl, *acl;
        struct nfs3_createdata *data;
-       umode_t mode = sattr->ia_mode;
        int status = -ENOMEM;
 
        dprintk("NFS call  create %pd\n", dentry);
@@ -340,7 +340,9 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                data->arg.create.verifier[1] = cpu_to_be32(current->pid);
        }
 
-       sattr->ia_mode &= ~current_umask();
+       status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
+       if (status)
+               goto out;
 
        for (;;) {
                status = nfs3_do_create(dir, dentry, data);
@@ -366,7 +368,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
        }
 
        if (status != 0)
-               goto out;
+               goto out_release_acls;
 
        /* When we created the file with exclusive semantics, make
         * sure we set the attributes afterwards. */
@@ -385,9 +387,14 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                nfs_post_op_update_inode(dentry->d_inode, data->res.fattr);
                dprintk("NFS reply setattr (post-create): %d\n", status);
                if (status != 0)
-                       goto out;
+                       goto out_release_acls;
        }
-       status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode);
+
+       status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl);
+
+out_release_acls:
+       posix_acl_release(acl);
+       posix_acl_release(default_acl);
 out:
        nfs3_free_createdata(data);
        dprintk("NFS reply create: %d\n", status);
@@ -572,18 +579,20 @@ out:
 static int
 nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
 {
+       struct posix_acl *default_acl, *acl;
        struct nfs3_createdata *data;
-       umode_t mode = sattr->ia_mode;
        int status = -ENOMEM;
 
        dprintk("NFS call  mkdir %pd\n", dentry);
 
-       sattr->ia_mode &= ~current_umask();
-
        data = nfs3_alloc_createdata();
        if (data == NULL)
                goto out;
 
+       status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
+       if (status)
+               goto out;
+
        data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR];
        data->arg.mkdir.fh = NFS_FH(dir);
        data->arg.mkdir.name = dentry->d_name.name;
@@ -592,9 +601,13 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
 
        status = nfs3_do_create(dir, dentry, data);
        if (status != 0)
-               goto out;
+               goto out_release_acls;
 
-       status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode);
+       status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl);
+
+out_release_acls:
+       posix_acl_release(acl);
+       posix_acl_release(default_acl);
 out:
        nfs3_free_createdata(data);
        dprintk("NFS reply mkdir: %d\n", status);
@@ -691,19 +704,21 @@ static int
 nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
                dev_t rdev)
 {
+       struct posix_acl *default_acl, *acl;
        struct nfs3_createdata *data;
-       umode_t mode = sattr->ia_mode;
        int status = -ENOMEM;
 
        dprintk("NFS call  mknod %pd %u:%u\n", dentry,
                        MAJOR(rdev), MINOR(rdev));
 
-       sattr->ia_mode &= ~current_umask();
-
        data = nfs3_alloc_createdata();
        if (data == NULL)
                goto out;
 
+       status = posix_acl_create(dir, &sattr->ia_mode, &default_acl, &acl);
+       if (status)
+               goto out;
+
        data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD];
        data->arg.mknod.fh = NFS_FH(dir);
        data->arg.mknod.name = dentry->d_name.name;
@@ -731,8 +746,13 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
 
        status = nfs3_do_create(dir, dentry, data);
        if (status != 0)
-               goto out;
-       status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode);
+               goto out_release_acls;
+
+       status = nfs3_proc_setacls(dentry->d_inode, acl, default_acl);
+
+out_release_acls:
+       posix_acl_release(acl);
+       posix_acl_release(default_acl);
 out:
        nfs3_free_createdata(data);
        dprintk("NFS reply mknod: %d\n", status);
@@ -904,20 +924,28 @@ static const struct inode_operations nfs3_dir_inode_operations = {
        .permission     = nfs_permission,
        .getattr        = nfs_getattr,
        .setattr        = nfs_setattr,
-       .listxattr      = nfs3_listxattr,
-       .getxattr       = nfs3_getxattr,
-       .setxattr       = nfs3_setxattr,
-       .removexattr    = nfs3_removexattr,
+       .listxattr      = generic_listxattr,
+       .getxattr       = generic_getxattr,
+       .setxattr       = generic_setxattr,
+       .removexattr    = generic_removexattr,
+#ifdef CONFIG_NFS_V3_ACL
+       .get_acl        = nfs3_get_acl,
+       .set_acl        = nfs3_set_acl,
+#endif
 };
 
 static const struct inode_operations nfs3_file_inode_operations = {
        .permission     = nfs_permission,
        .getattr        = nfs_getattr,
        .setattr        = nfs_setattr,
-       .listxattr      = nfs3_listxattr,
-       .getxattr       = nfs3_getxattr,
-       .setxattr       = nfs3_setxattr,
-       .removexattr    = nfs3_removexattr,
+       .listxattr      = generic_listxattr,
+       .getxattr       = generic_getxattr,
+       .setxattr       = generic_setxattr,
+       .removexattr    = generic_removexattr,
+#ifdef CONFIG_NFS_V3_ACL
+       .get_acl        = nfs3_get_acl,
+       .set_acl        = nfs3_set_acl,
+#endif
 };
 
 const struct nfs_rpc_ops nfs_v3_clientops = {
@@ -965,7 +993,7 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
        .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,
        .commit_done    = nfs3_commit_done,
        .lock           = nfs3_proc_lock,
-       .clear_acl_cache = nfs3_forget_cached_acls,
+       .clear_acl_cache = forget_all_cached_acls,
        .close_context  = nfs_close_context,
        .have_delegation = nfs3_have_delegation,
        .return_delegation = nfs3_return_delegation,
index cc471c7252300060c4dae042f77c0190762961f5..d6a98949af191e5e79e8cf74adb26f2b8f3cc462 100644 (file)
@@ -12,6 +12,9 @@ static struct nfs_subversion nfs_v3 = {
        .rpc_vers = &nfs_version3,
        .rpc_ops  = &nfs_v3_clientops,
        .sops     = &nfs_sops,
+#ifdef CONFIG_NFS_V3_ACL
+       .xattr    = nfs3_xattr_handlers,
+#endif
 };
 
 static int __init init_nfs_v3(void)
index 8b186a4955cc8c1cd5c84e3aadc2397370ea1086..8b68218e2c1c25c188f7585966dd9f694807e096 100644 (file)
@@ -35,7 +35,9 @@
 #ifndef LINUX_NFS4_ACL_H
 #define LINUX_NFS4_ACL_H
 
-#include <linux/posix_acl.h>
+struct nfs4_acl;
+struct svc_fh;
+struct svc_rqst;
 
 /* Maximum ACL we'll accept from client; chosen (somewhat arbitrarily) to
  * fit in a page: */
@@ -45,13 +47,9 @@ struct nfs4_acl *nfs4_acl_new(int);
 int nfs4_acl_get_whotype(char *, u32);
 int nfs4_acl_write_who(int who, char *p);
 
-#define NFS4_ACL_TYPE_DEFAULT  0x01
-#define NFS4_ACL_DIR           0x02
-#define NFS4_ACL_OWNER         0x04
-
-struct nfs4_acl *nfs4_acl_posix_to_nfsv4(struct posix_acl *,
-                               struct posix_acl *, unsigned int flags);
-int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *, struct posix_acl **,
-                               struct posix_acl **, unsigned int flags);
+int nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
+               struct nfs4_acl **acl);
+__be32 nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
+               struct nfs4_acl *acl);
 
 #endif /* LINUX_NFS4_ACL_H */
index 95d76dc6c5da5bf313c4778eaa8220eb91ac1665..11c1fba293124f0eba92a066262ab60f7bd9c600 100644 (file)
@@ -30,8 +30,9 @@ nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
 static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
                struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
 {
-       svc_fh *fh;
        struct posix_acl *acl;
+       struct inode *inode;
+       svc_fh *fh;
        __be32 nfserr = 0;
 
        dprintk("nfsd: GETACL(2acl)   %s\n", SVCFH_fmt(&argp->fh));
@@ -41,6 +42,8 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
        if (nfserr)
                RETURN_STATUS(nfserr);
 
+       inode = fh->fh_dentry->d_inode;
+
        if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
                RETURN_STATUS(nfserr_inval);
        resp->mask = argp->mask;
@@ -50,21 +53,13 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
                goto fail;
 
        if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
-               acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS);
+               acl = get_acl(inode, ACL_TYPE_ACCESS);
                if (IS_ERR(acl)) {
-                       int err = PTR_ERR(acl);
-
-                       if (err == -ENODATA || err == -EOPNOTSUPP)
-                               acl = NULL;
-                       else {
-                               nfserr = nfserrno(err);
-                               goto fail;
-                       }
+                       nfserr = nfserrno(PTR_ERR(acl));
+                       goto fail;
                }
                if (acl == NULL) {
                        /* Solaris returns the inode's minimum ACL. */
-
-                       struct inode *inode = fh->fh_dentry->d_inode;
                        acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
                }
                resp->acl_access = acl;
@@ -72,17 +67,10 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
        if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
                /* Check how Solaris handles requests for the Default ACL
                   of a non-directory! */
-
-               acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT);
+               acl = get_acl(inode, ACL_TYPE_DEFAULT);
                if (IS_ERR(acl)) {
-                       int err = PTR_ERR(acl);
-
-                       if (err == -ENODATA || err == -EOPNOTSUPP)
-                               acl = NULL;
-                       else {
-                               nfserr = nfserrno(err);
-                               goto fail;
-                       }
+                       nfserr = nfserrno(PTR_ERR(acl));
+                       goto fail;
                }
                resp->acl_default = acl;
        }
@@ -103,31 +91,51 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
                struct nfsd3_setaclargs *argp,
                struct nfsd_attrstat *resp)
 {
+       struct inode *inode;
        svc_fh *fh;
        __be32 nfserr = 0;
+       int error;
 
        dprintk("nfsd: SETACL(2acl)   %s\n", SVCFH_fmt(&argp->fh));
 
        fh = fh_copy(&resp->fh, &argp->fh);
        nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
+       if (nfserr)
+               goto out;
 
-       if (!nfserr) {
-               nfserr = nfserrno( nfsd_set_posix_acl(
-                       fh, ACL_TYPE_ACCESS, argp->acl_access) );
-       }
-       if (!nfserr) {
-               nfserr = nfserrno( nfsd_set_posix_acl(
-                       fh, ACL_TYPE_DEFAULT, argp->acl_default) );
-       }
-       if (!nfserr) {
-               nfserr = fh_getattr(fh, &resp->stat);
+       inode = fh->fh_dentry->d_inode;
+       if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
+               error = -EOPNOTSUPP;
+               goto out_errno;
        }
 
+       error = fh_want_write(fh);
+       if (error)
+               goto out_errno;
+
+       error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
+       if (error)
+               goto out_drop_write;
+       error = inode->i_op->set_acl(inode, argp->acl_default,
+                                    ACL_TYPE_DEFAULT);
+       if (error)
+               goto out_drop_write;
+
+       fh_drop_write(fh);
+
+       nfserr = fh_getattr(fh, &resp->stat);
+
+out:
        /* argp->acl_{access,default} may have been allocated in
           nfssvc_decode_setaclargs. */
        posix_acl_release(argp->acl_access);
        posix_acl_release(argp->acl_default);
        return nfserr;
+out_drop_write:
+       fh_drop_write(fh);
+out_errno:
+       nfserr = nfserrno(error);
+       goto out;
 }
 
 /*
index 9cbc1a841f87b39d47e81f40cf1e8eac6161a3d2..adc5f1b1dc2677eda3eae5ee895e6df915d4f5cd 100644 (file)
@@ -29,8 +29,9 @@ nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
 static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
                struct nfsd3_getaclargs *argp, struct nfsd3_getaclres *resp)
 {
-       svc_fh *fh;
        struct posix_acl *acl;
+       struct inode *inode;
+       svc_fh *fh;
        __be32 nfserr = 0;
 
        fh = fh_copy(&resp->fh, &argp->fh);
@@ -38,26 +39,20 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
        if (nfserr)
                RETURN_STATUS(nfserr);
 
+       inode = fh->fh_dentry->d_inode;
+
        if (argp->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
                RETURN_STATUS(nfserr_inval);
        resp->mask = argp->mask;
 
        if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
-               acl = nfsd_get_posix_acl(fh, ACL_TYPE_ACCESS);
+               acl = get_acl(inode, ACL_TYPE_ACCESS);
                if (IS_ERR(acl)) {
-                       int err = PTR_ERR(acl);
-
-                       if (err == -ENODATA || err == -EOPNOTSUPP)
-                               acl = NULL;
-                       else {
-                               nfserr = nfserrno(err);
-                               goto fail;
-                       }
+                       nfserr = nfserrno(PTR_ERR(acl));
+                       goto fail;
                }
                if (acl == NULL) {
                        /* Solaris returns the inode's minimum ACL. */
-
-                       struct inode *inode = fh->fh_dentry->d_inode;
                        acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
                }
                resp->acl_access = acl;
@@ -65,17 +60,10 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
        if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
                /* Check how Solaris handles requests for the Default ACL
                   of a non-directory! */
-
-               acl = nfsd_get_posix_acl(fh, ACL_TYPE_DEFAULT);
+               acl = get_acl(inode, ACL_TYPE_DEFAULT);
                if (IS_ERR(acl)) {
-                       int err = PTR_ERR(acl);
-
-                       if (err == -ENODATA || err == -EOPNOTSUPP)
-                               acl = NULL;
-                       else {
-                               nfserr = nfserrno(err);
-                               goto fail;
-                       }
+                       nfserr = nfserrno(PTR_ERR(acl));
+                       goto fail;
                }
                resp->acl_default = acl;
        }
@@ -96,21 +84,37 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,
                struct nfsd3_setaclargs *argp,
                struct nfsd3_attrstat *resp)
 {
+       struct inode *inode;
        svc_fh *fh;
        __be32 nfserr = 0;
+       int error;
 
        fh = fh_copy(&resp->fh, &argp->fh);
        nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
+       if (nfserr)
+               goto out;
 
-       if (!nfserr) {
-               nfserr = nfserrno( nfsd_set_posix_acl(
-                       fh, ACL_TYPE_ACCESS, argp->acl_access) );
-       }
-       if (!nfserr) {
-               nfserr = nfserrno( nfsd_set_posix_acl(
-                       fh, ACL_TYPE_DEFAULT, argp->acl_default) );
+       inode = fh->fh_dentry->d_inode;
+       if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
+               error = -EOPNOTSUPP;
+               goto out_errno;
        }
 
+       error = fh_want_write(fh);
+       if (error)
+               goto out_errno;
+
+       error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
+       if (error)
+               goto out_drop_write;
+       error = inode->i_op->set_acl(inode, argp->acl_default,
+                                    ACL_TYPE_DEFAULT);
+
+out_drop_write:
+       fh_drop_write(fh);
+out_errno:
+       nfserr = nfserrno(error);
+out:
        /* argp->acl_{access,default} may have been allocated in
           nfs3svc_decode_setaclargs. */
        posix_acl_release(argp->acl_access);
index 8a50b3c18093b0bc3a6bd04bc80d7767ef8b7ae7..649ad7cf22044bb10bd6cb64527cba7295226a97 100644 (file)
 #include <linux/slab.h>
 #include <linux/nfs_fs.h>
 #include <linux/export.h>
+#include "nfsfh.h"
 #include "acl.h"
+#include "vfs.h"
 
+#define NFS4_ACL_TYPE_DEFAULT  0x01
+#define NFS4_ACL_DIR           0x02
+#define NFS4_ACL_OWNER         0x04
 
 /* mode bit translations: */
 #define NFS4_READ_MODE (NFS4_ACE_READ_DATA)
@@ -130,36 +135,50 @@ static short ace2type(struct nfs4_ace *);
 static void _posix_to_nfsv4_one(struct posix_acl *, struct nfs4_acl *,
                                unsigned int);
 
-struct nfs4_acl *
-nfs4_acl_posix_to_nfsv4(struct posix_acl *pacl, struct posix_acl *dpacl,
-                       unsigned int flags)
+int
+nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
+               struct nfs4_acl **acl)
 {
-       struct nfs4_acl *acl;
+       struct inode *inode = dentry->d_inode;
+       int error = 0;
+       struct posix_acl *pacl = NULL, *dpacl = NULL;
+       unsigned int flags = 0;
        int size = 0;
 
-       if (pacl) {
-               if (posix_acl_valid(pacl) < 0)
-                       return ERR_PTR(-EINVAL);
-               size += 2*pacl->a_count;
+       pacl = get_acl(inode, ACL_TYPE_ACCESS);
+       if (!pacl) {
+               pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
+               if (IS_ERR(pacl))
+                       return PTR_ERR(pacl);
+               /* allocate for worst case: one (deny, allow) pair each: */
+               size += 2 * pacl->a_count;
        }
-       if (dpacl) {
-               if (posix_acl_valid(dpacl) < 0)
-                       return ERR_PTR(-EINVAL);
-               size += 2*dpacl->a_count;
+
+       if (S_ISDIR(inode->i_mode)) {
+               flags = NFS4_ACL_DIR;
+               dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
+               if (dpacl)
+                       size += 2 * dpacl->a_count;
+       } else {
+               dpacl = NULL;
        }
 
-       /* Allocate for worst case: one (deny, allow) pair each: */
-       acl = nfs4_acl_new(size);
-       if (acl == NULL)
-               return ERR_PTR(-ENOMEM);
+       *acl = nfs4_acl_new(size);
+       if (*acl == NULL) {
+               error = -ENOMEM;
+               goto out;
+       }
 
        if (pacl)
-               _posix_to_nfsv4_one(pacl, acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
+               _posix_to_nfsv4_one(pacl, *acl, flags & ~NFS4_ACL_TYPE_DEFAULT);
 
        if (dpacl)
-               _posix_to_nfsv4_one(dpacl, acl, flags | NFS4_ACL_TYPE_DEFAULT);
+               _posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);
 
-       return acl;
+ out:
+       posix_acl_release(pacl);
+       posix_acl_release(dpacl);
+       return error;
 }
 
 struct posix_acl_summary {
@@ -719,8 +738,9 @@ static void process_one_v4_ace(struct posix_acl_state *state,
        }
 }
 
-int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl, struct posix_acl **pacl,
-                           struct posix_acl **dpacl, unsigned int flags)
+static int nfs4_acl_nfsv4_to_posix(struct nfs4_acl *acl,
+               struct posix_acl **pacl, struct posix_acl **dpacl,
+               unsigned int flags)
 {
        struct posix_acl_state effective_acl_state, default_acl_state;
        struct nfs4_ace *ace;
@@ -780,6 +800,57 @@ out_estate:
        return ret;
 }
 
+__be32
+nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
+               struct nfs4_acl *acl)
+{
+       __be32 error;
+       int host_error;
+       struct dentry *dentry;
+       struct inode *inode;
+       struct posix_acl *pacl = NULL, *dpacl = NULL;
+       unsigned int flags = 0;
+
+       /* Get inode */
+       error = fh_verify(rqstp, fhp, 0, NFSD_MAY_SATTR);
+       if (error)
+               return error;
+
+       dentry = fhp->fh_dentry;
+       inode = dentry->d_inode;
+
+       if (!inode->i_op->set_acl || !IS_POSIXACL(inode))
+               return nfserr_attrnotsupp;
+
+       if (S_ISDIR(inode->i_mode))
+               flags = NFS4_ACL_DIR;
+
+       host_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);
+       if (host_error == -EINVAL)
+               return nfserr_attrnotsupp;
+       if (host_error < 0)
+               goto out_nfserr;
+
+       host_error = inode->i_op->set_acl(inode, pacl, ACL_TYPE_ACCESS);
+       if (host_error < 0)
+               goto out_release;
+
+       if (S_ISDIR(inode->i_mode)) {
+               host_error = inode->i_op->set_acl(inode, dpacl,
+                                                 ACL_TYPE_DEFAULT);
+       }
+
+out_release:
+       posix_acl_release(pacl);
+       posix_acl_release(dpacl);
+out_nfserr:
+       if (host_error == -EOPNOTSUPP)
+               return nfserr_attrnotsupp;
+       else
+               return nfserrno(host_error);
+}
+
+
 static short
 ace2type(struct nfs4_ace *ace)
 {
@@ -798,9 +869,6 @@ ace2type(struct nfs4_ace *ace)
        return -1;
 }
 
-EXPORT_SYMBOL(nfs4_acl_posix_to_nfsv4);
-EXPORT_SYMBOL(nfs4_acl_nfsv4_to_posix);
-
 struct nfs4_acl *
 nfs4_acl_new(int n)
 {
@@ -862,7 +930,3 @@ nfs4_acl_write_who(int who, char *p)
        BUG();
        return -1;
 }
-
-EXPORT_SYMBOL(nfs4_acl_new);
-EXPORT_SYMBOL(nfs4_acl_get_whotype);
-EXPORT_SYMBOL(nfs4_acl_write_who);
index 419572f33b72dafaf04a770fb53e29e250e5f42b..825b8a99b99b42aaf1675518ea979a77b67c1955 100644 (file)
@@ -41,6 +41,7 @@
 #include "vfs.h"
 #include "current_stateid.h"
 #include "netns.h"
+#include "acl.h"
 
 #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
 #include <linux/security.h>
index 7eea63cada1d4a3ea5f9dd95401f83714689fcb0..1426eb66c8c699cf4104bde226986dda77ccc4c8 100644 (file)
@@ -468,158 +468,7 @@ out:
        return err;
 }
 
-#if defined(CONFIG_NFSD_V2_ACL) || \
-    defined(CONFIG_NFSD_V3_ACL) || \
-    defined(CONFIG_NFSD_V4)
-static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf)
-{
-       ssize_t buflen;
-       ssize_t ret;
-
-       buflen = vfs_getxattr(dentry, key, NULL, 0);
-       if (buflen <= 0)
-               return buflen;
-
-       *buf = kmalloc(buflen, GFP_KERNEL);
-       if (!*buf)
-               return -ENOMEM;
-
-       ret = vfs_getxattr(dentry, key, *buf, buflen);
-       if (ret < 0)
-               kfree(*buf);
-       return ret;
-}
-#endif
-
 #if defined(CONFIG_NFSD_V4)
-static int
-set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key)
-{
-       int len;
-       size_t buflen;
-       char *buf = NULL;
-       int error = 0;
-
-       buflen = posix_acl_xattr_size(pacl->a_count);
-       buf = kmalloc(buflen, GFP_KERNEL);
-       error = -ENOMEM;
-       if (buf == NULL)
-               goto out;
-
-       len = posix_acl_to_xattr(&init_user_ns, pacl, buf, buflen);
-       if (len < 0) {
-               error = len;
-               goto out;
-       }
-
-       error = vfs_setxattr(dentry, key, buf, len, 0);
-out:
-       kfree(buf);
-       return error;
-}
-
-__be32
-nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
-    struct nfs4_acl *acl)
-{
-       __be32 error;
-       int host_error;
-       struct dentry *dentry;
-       struct inode *inode;
-       struct posix_acl *pacl = NULL, *dpacl = NULL;
-       unsigned int flags = 0;
-
-       /* Get inode */
-       error = fh_verify(rqstp, fhp, 0, NFSD_MAY_SATTR);
-       if (error)
-               return error;
-
-       dentry = fhp->fh_dentry;
-       inode = dentry->d_inode;
-       if (S_ISDIR(inode->i_mode))
-               flags = NFS4_ACL_DIR;
-
-       host_error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);
-       if (host_error == -EINVAL) {
-               return nfserr_attrnotsupp;
-       } else if (host_error < 0)
-               goto out_nfserr;
-
-       host_error = set_nfsv4_acl_one(dentry, pacl, POSIX_ACL_XATTR_ACCESS);
-       if (host_error < 0)
-               goto out_release;
-
-       if (S_ISDIR(inode->i_mode))
-               host_error = set_nfsv4_acl_one(dentry, dpacl, POSIX_ACL_XATTR_DEFAULT);
-
-out_release:
-       posix_acl_release(pacl);
-       posix_acl_release(dpacl);
-out_nfserr:
-       if (host_error == -EOPNOTSUPP)
-               return nfserr_attrnotsupp;
-       else
-               return nfserrno(host_error);
-}
-
-static struct posix_acl *
-_get_posix_acl(struct dentry *dentry, char *key)
-{
-       void *buf = NULL;
-       struct posix_acl *pacl = NULL;
-       int buflen;
-
-       buflen = nfsd_getxattr(dentry, key, &buf);
-       if (!buflen)
-               buflen = -ENODATA;
-       if (buflen <= 0)
-               return ERR_PTR(buflen);
-
-       pacl = posix_acl_from_xattr(&init_user_ns, buf, buflen);
-       kfree(buf);
-       return pacl;
-}
-
-int
-nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry, struct nfs4_acl **acl)
-{
-       struct inode *inode = dentry->d_inode;
-       int error = 0;
-       struct posix_acl *pacl = NULL, *dpacl = NULL;
-       unsigned int flags = 0;
-
-       pacl = _get_posix_acl(dentry, POSIX_ACL_XATTR_ACCESS);
-       if (IS_ERR(pacl) && PTR_ERR(pacl) == -ENODATA)
-               pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
-       if (IS_ERR(pacl)) {
-               error = PTR_ERR(pacl);
-               pacl = NULL;
-               goto out;
-       }
-
-       if (S_ISDIR(inode->i_mode)) {
-               dpacl = _get_posix_acl(dentry, POSIX_ACL_XATTR_DEFAULT);
-               if (IS_ERR(dpacl) && PTR_ERR(dpacl) == -ENODATA)
-                       dpacl = NULL;
-               else if (IS_ERR(dpacl)) {
-                       error = PTR_ERR(dpacl);
-                       dpacl = NULL;
-                       goto out;
-               }
-               flags = NFS4_ACL_DIR;
-       }
-
-       *acl = nfs4_acl_posix_to_nfsv4(pacl, dpacl, flags);
-       if (IS_ERR(*acl)) {
-               error = PTR_ERR(*acl);
-               *acl = NULL;
-       }
- out:
-       posix_acl_release(pacl);
-       posix_acl_release(dpacl);
-       return error;
-}
-
 /*
  * NFS junction information is stored in an extended attribute.
  */
@@ -2284,93 +2133,3 @@ out_nomem:
        nfsd_racache_shutdown();
        return -ENOMEM;
 }
-
-#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
-struct posix_acl *
-nfsd_get_posix_acl(struct svc_fh *fhp, int type)
-{
-       struct inode *inode = fhp->fh_dentry->d_inode;
-       char *name;
-       void *value = NULL;
-       ssize_t size;
-       struct posix_acl *acl;
-
-       if (!IS_POSIXACL(inode))
-               return ERR_PTR(-EOPNOTSUPP);
-
-       switch (type) {
-       case ACL_TYPE_ACCESS:
-               name = POSIX_ACL_XATTR_ACCESS;
-               break;
-       case ACL_TYPE_DEFAULT:
-               name = POSIX_ACL_XATTR_DEFAULT;
-               break;
-       default:
-               return ERR_PTR(-EOPNOTSUPP);
-       }
-
-       size = nfsd_getxattr(fhp->fh_dentry, name, &value);
-       if (size < 0)
-               return ERR_PTR(size);
-
-       acl = posix_acl_from_xattr(&init_user_ns, value, size);
-       kfree(value);
-       return acl;
-}
-
-int
-nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl)
-{
-       struct inode *inode = fhp->fh_dentry->d_inode;
-       char *name;
-       void *value = NULL;
-       size_t size;
-       int error;
-
-       if (!IS_POSIXACL(inode) ||
-           !inode->i_op->setxattr || !inode->i_op->removexattr)
-               return -EOPNOTSUPP;
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       name = POSIX_ACL_XATTR_ACCESS;
-                       break;
-               case ACL_TYPE_DEFAULT:
-                       name = POSIX_ACL_XATTR_DEFAULT;
-                       break;
-               default:
-                       return -EOPNOTSUPP;
-       }
-
-       if (acl && acl->a_count) {
-               size = posix_acl_xattr_size(acl->a_count);
-               value = kmalloc(size, GFP_KERNEL);
-               if (!value)
-                       return -ENOMEM;
-               error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
-               if (error < 0)
-                       goto getout;
-               size = error;
-       } else
-               size = 0;
-
-       error = fh_want_write(fhp);
-       if (error)
-               goto getout;
-       if (size)
-               error = vfs_setxattr(fhp->fh_dentry, name, value, size, 0);
-       else {
-               if (!S_ISDIR(inode->i_mode) && type == ACL_TYPE_DEFAULT)
-                       error = 0;
-               else {
-                       error = vfs_removexattr(fhp->fh_dentry, name);
-                       if (error == -ENODATA)
-                               error = 0;
-               }
-       }
-       fh_drop_write(fhp);
-
-getout:
-       kfree(value);
-       return error;
-}
-#endif  /* defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) */
index a4be2e3896704047f1aae87ac924990fb2d0f834..1bc1d440a1a5677899a7d85d6b5926bb2f3f7900 100644 (file)
@@ -52,9 +52,6 @@ __be32                nfsd_setattr(struct svc_rqst *, struct svc_fh *,
                                struct iattr *, int, time_t);
 int nfsd_mountpoint(struct dentry *, struct svc_export *);
 #ifdef CONFIG_NFSD_V4
-__be32          nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
-                    struct nfs4_acl *);
-int             nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
 __be32          nfsd4_set_nfs4_label(struct svc_rqst *, struct svc_fh *,
                    struct xdr_netobj *);
 #endif /* CONFIG_NFSD_V4 */
@@ -101,11 +98,6 @@ __be32              nfsd_statfs(struct svc_rqst *, struct svc_fh *,
 __be32         nfsd_permission(struct svc_rqst *, struct svc_export *,
                                struct dentry *, int);
 
-#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
-struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int);
-int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
-#endif
-
 static inline int fh_want_write(struct svc_fh *fh)
 {
        int ret = mnt_want_write(fh->fh_export->ex_path.mnt);
index 634a8b717b02199ee310180ba35c9f8947a5e897..266c2d7d50bdaed476be1a44fc0a12f3ac8b9625 100644 (file)
@@ -583,7 +583,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macceltic(void)
index 979e6265ac5e823d355ca9171d8a8debe6195347..9789c6057551a3c16a7de3d9b5cf7302ade3a85f 100644 (file)
@@ -513,7 +513,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_maccenteuro(void)
index dd3f675911ee3716a9a835f5fd428db3d723cd8f..bb19e7a07d436496b5ad2f4833dfb1da7c50f588 100644 (file)
@@ -583,7 +583,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_maccroatian(void)
index 1112c84dd8bb7183d5fec826cea8c06e866d0ee8..2a7dea36acba0e13d706a255868ce82af88dbd51 100644 (file)
@@ -478,7 +478,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_maccyrillic(void)
index 2de9158409c85ec468619e5f93289c5e133af66b..77b001653588076ea42a71a254bd2c42aa0e279d 100644 (file)
@@ -548,7 +548,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macgaelic(void)
index a863100828028f5f9d98a62f1dbacb1c62fa4ca0..1eccf499e2ebc5bb2aff772b17a834fec615d802 100644 (file)
@@ -478,7 +478,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macgreek(void)
index babe2998d5ced2d0a1a8d237edb4fe5a2cd25604..cbd0875c6d6948b3a7ada49d75c909c69da347ba 100644 (file)
@@ -583,7 +583,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_maciceland(void)
index 312364f010dcc7e5a8af3d95f9763c54f37f85d2..fba8357aaf03899d3929902070f8e2c01e91b541 100644 (file)
@@ -513,7 +513,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macinuit(void)
index 53ce0809cbd28eec842fab86b808c19b91c5dcc7..b6a98a5208cd6196b48b7d703c1a4a6ad953201e 100644 (file)
@@ -618,7 +618,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macroman(void)
index add6f7a0c6663c6ddf251bf749fc13812548d181..25547f023638453396876470e74cd66ba2b34ce1 100644 (file)
@@ -583,7 +583,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macromanian(void)
index dffa96d5de00243d29940c68dd613666d7fad25c..b5454bc7b7fa390b34f758d0ef49a54c9ece70ad 100644 (file)
@@ -583,7 +583,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_macturkish(void)
index 7020e940f74e9dbcb4f7a420d67391fa6532f779..a2620650d5e45f6d6a9e4113fbae7fcf29a5e25d 100644 (file)
@@ -148,7 +148,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_ascii(void)
index fea6bd5831dce3d84868316c424266c1232949fd..52ccd34b1e792370597b77f7d228c4d79bf96600 100644 (file)
@@ -232,13 +232,14 @@ int utf16s_to_utf8s(const wchar_t *pwcs, int inlen, enum utf16_endian endian,
 }
 EXPORT_SYMBOL(utf16s_to_utf8s);
 
-int register_nls(struct nls_table * nls)
+int __register_nls(struct nls_table *nls, struct module *owner)
 {
        struct nls_table ** tmp = &tables;
 
        if (nls->next)
                return -EBUSY;
 
+       nls->owner = owner;
        spin_lock(&nls_lock);
        while (*tmp) {
                if (nls == *tmp) {
@@ -252,6 +253,7 @@ int register_nls(struct nls_table * nls)
        spin_unlock(&nls_lock);
        return 0;       
 }
+EXPORT_SYMBOL(__register_nls);
 
 int unregister_nls(struct nls_table * nls)
 {
@@ -538,7 +540,6 @@ struct nls_table *load_nls_default(void)
                return &default_table;
 }
 
-EXPORT_SYMBOL(register_nls);
 EXPORT_SYMBOL(unregister_nls);
 EXPORT_SYMBOL(unload_nls);
 EXPORT_SYMBOL(load_nls);
index c8471fe78e4e5893dade5b391b2d60dda9197bc6..ace3e19d3407671f36eaa5a43aaa27f341028e3c 100644 (file)
@@ -329,7 +329,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp1250(void)
index 1939b46e772f42a6c5ba0377bd6b8c1939030aa9..9273ddfd08a1eec6f2801101897150a46e947c48 100644 (file)
@@ -283,7 +283,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp1251(void)
index 8120ae2e091a78ebe3ee240c0bf35133ceff9a54..1caf5dfed85b7ec9c06688cfd97282ad6b807e36 100644 (file)
@@ -365,7 +365,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp1255(void)
index ff37a4628ce48e5c9e86d4febdeea81565dec65b..7ddb830da3fdb78a9384b026060f6633a32d4e21 100644 (file)
@@ -369,7 +369,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp437(void)
index f5576b8be1b92bb3e43f6a01226f5acae3e641e2..c593f683a0cd2139c68d82b7dd7bd8baffc36e01 100644 (file)
@@ -332,7 +332,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp737(void)
index 4905635d1c00986735d49df059cb0f2efab5b1c0..554c863745f2b6e12ae31afee3935b6fce825c1c 100644 (file)
@@ -301,7 +301,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp775(void)
index fe5bdad50e2b39ac4783653e8666b1c2be9a92de..56cccd14b40be93a1a49abe57aedfb472c2d9259 100644 (file)
@@ -297,7 +297,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp850(void)
index ceb1c0166dd8988909cfee453b79d94ab30213ff..7cdc05ac1d402e8d5a5eca44ec74eb06483abe45 100644 (file)
@@ -319,7 +319,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp852(void)
index cc7f5fb2e0c24849f401b47018270609d29ee5ab..7426eea05663731dd90b25b96902c31214a633ec 100644 (file)
@@ -281,7 +281,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp855(void)
index e418e198e8d866586e8317f7327dfdfc924c8188..098309733ebd1406316b7c7fb9dcd86f6a88b04c 100644 (file)
@@ -283,7 +283,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp857(void)
index a86c97d1aa3484747df369573918cbf01aa97a88..84224478e731a5f9f4e3c566cf78464479dfad3b 100644 (file)
@@ -346,7 +346,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp860(void)
index bd920227acdfd0869b450c8d0b58105cf9ae5037..dc873e4be092a233698a0b9fb5e45361af1cf64d 100644 (file)
@@ -369,7 +369,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp861(void)
index e9b68eb3daf04d21cb39ed60ab1d4b6120bbf24d..d5263e3c5566cf51f2d0892f2d57e735b62f8b52 100644 (file)
@@ -403,7 +403,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp862(void)
index f8a9b07ab4e2f64cc80d247b567250d90b034fea..051c9832e36a96e19da30441a95ce5688071d35a 100644 (file)
@@ -363,7 +363,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp863(void)
index 8d31f435fc6f9a31f662d929d6870402766688af..97eb1273b2f7456b10c172ab5e229b745f1e7f01 100644 (file)
@@ -389,7 +389,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp864(void)
index 4bd902fe3ec94065d05f3ab36515efac885f3e13..11121422852513544cba0d316668cdfc08225f4a 100644 (file)
@@ -369,7 +369,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp865(void)
index bdc7cb391398828330db1cfedb8c47d7174f3d3b..ffdcbc3fc38d71f2b4e258b660c3eb32c2a387f7 100644 (file)
@@ -287,7 +287,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp866(void)
index 9f283a2b151a2c2f7004ecdfceae58b5f3c53a06..3b5a345893543fb2702023c6796a72216efbdfd8 100644 (file)
@@ -297,7 +297,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp869(void)
index 0b3c4886f8c03d2927ecd9a16a13d964f5cb97e4..8dfaa10710fa7165c4b6261b0b0081a4f37357cf 100644 (file)
@@ -256,7 +256,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp874(void)
index 0ffed6f1cebb6cb8d9c5618cc4876c6f053457d3..67b7398e84832bcacd334a65e60cda21f0a045b4 100644 (file)
@@ -7914,7 +7914,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp932(void)
index 82770301bc3da82849a2118db40aaeb1e4b92d7c..c96546cfec9fd81b5c726121501ba7e4c1640690 100644 (file)
@@ -11092,7 +11092,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp936(void)
index 8a7a2fe85c65a7ca551f6417e0a3d181d9aa7e46..199171e97aa4a014ae0bdaecbf05759bad99b76b 100644 (file)
@@ -13927,7 +13927,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp949(void)
index ef2536829aa589a393d1b5d9528d1e28ab2ac47e..8e14187082098216c78d7bb9b39d269dd544eec5 100644 (file)
@@ -9463,7 +9463,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_cp950(void)
index 7424929a278b0088ba92772ffb1b3a7644864906..162b3f160353c6ab076644079c861a2b4f1fd736 100644 (file)
@@ -553,7 +553,6 @@ static struct nls_table table = {
        .charset        = "euc-jp",
        .uni2char       = uni2char,
        .char2uni       = char2uni,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_euc_jp(void)
index 7b951bb5849cb52e48a30dc8c3f3187949c581bb..69ac020d43b1ce0dc7fc640476faee082a91b6fc 100644 (file)
@@ -239,7 +239,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_1(void)
index c4d52ea9f0921a6530bc96de8e02529643856f9e..afb3f8f275f079df23746a779bcf0223fbba81b8 100644 (file)
@@ -267,7 +267,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_13(void)
index dc02600c7fe16828d3bb4688652bd46be363e485..046370f0b6f0ca1284aa70cadcc041fd1386be87 100644 (file)
@@ -323,7 +323,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_14(void)
index 3c7dfc832ef1309fb095d445a33ad529ebdd3a11..7e34a841a056727cd647784ef1eeca625fd3ea7e 100644 (file)
@@ -289,7 +289,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_15(void)
index a2d2197e4c7740e5ea808e196945b8806e74fbc8..7dd5711817414d2bc03564d28ca2249d15bcd0bf 100644 (file)
@@ -290,7 +290,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_2(void)
index a61e0daa3a860a6472e52b29f1b640b599f9b0a4..740b75ec44936919b7458f89e34f02fd83d914e4 100644 (file)
@@ -290,7 +290,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_3(void)
index e8ff555483b673526845585366b71ba573b27d04..8826021e32f59a2cf6323ecbbd2d8f4da1aa27ad 100644 (file)
@@ -290,7 +290,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_4(void)
index 4721e89301249c2e7e765ac19efdabee4cb9baec..7c04057a1ad82c44cc9903abbac1ddb6336086d8 100644 (file)
@@ -254,7 +254,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_5(void)
index 01a517d6d306a18fe7d48b811529a00a59c5eb39..d4a881400d74951308788241b1d7240c81d02c7a 100644 (file)
@@ -245,7 +245,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_6(void)
index 2d27b93ef19e152bd4415e6e9f62e8bcc2472394..37b75d825a754ec2690a62cf7f0a2ee2d28058ec 100644 (file)
@@ -299,7 +299,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_7(void)
index 694bf070c72102535c122499bfd0e88bb6adacf7..557b98250d3790b89a3883f9cb8a6cecbe201eaf 100644 (file)
@@ -254,7 +254,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_iso8859_9(void)
index 43875310540dd83d3cf354013fdc0b91bbf35140..811f232fccfba77f79627f26aa338553d1cf3a6e 100644 (file)
@@ -305,7 +305,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_koi8_r(void)
index e7bc1d75c78c4e9a79a373707559ab51f091d456..a80a741a8676dc5a6ead28c9a584169050fc3c79 100644 (file)
@@ -55,7 +55,6 @@ static struct nls_table table = {
        .charset        = "koi8-ru",
        .uni2char       = uni2char,
        .char2uni       = char2uni,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_koi8_ru(void)
index 8c9f0292b5ae88318249c53708b31ae600dafa81..7e029e4c188a241ef37de1e2e419bf61dbf8eba3 100644 (file)
@@ -312,7 +312,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = charset2lower,
        .charset2upper  = charset2upper,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_koi8_u(void)
index 0d60a44acacd42b7eee10349a672a9ec9a74240a..afcfbc4a14dbf82c6d8b171477d8f5e0eb0dc00f 100644 (file)
@@ -46,7 +46,6 @@ static struct nls_table table = {
        .char2uni       = char2uni,
        .charset2lower  = identity,     /* no conversion */
        .charset2upper  = identity,
-       .owner          = THIS_MODULE,
 };
 
 static int __init init_nls_utf8(void)
index b4f788e0ca318955ab797f2350f8dffa320a53cb..555f4cddefe3a913d7c1d05fba89a1ea36fdd3c1 100644 (file)
@@ -160,36 +160,6 @@ static struct posix_acl *ocfs2_get_acl_nolock(struct inode *inode,
        return acl;
 }
 
-
-/*
- * Get posix acl.
- */
-static struct posix_acl *ocfs2_get_acl(struct inode *inode, int type)
-{
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-       struct buffer_head *di_bh = NULL;
-       struct posix_acl *acl;
-       int ret;
-
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return NULL;
-
-       ret = ocfs2_inode_lock(inode, &di_bh, 0);
-       if (ret < 0) {
-               mlog_errno(ret);
-               acl = ERR_PTR(ret);
-               return acl;
-       }
-
-       acl = ocfs2_get_acl_nolock(inode, type, di_bh);
-
-       ocfs2_inode_unlock(inode, 0);
-
-       brelse(di_bh);
-
-       return acl;
-}
-
 /*
  * Helper function to set i_mode in memory and disk. Some call paths
  * will not have di_bh or a journal handle to pass, in which case it
@@ -250,7 +220,7 @@ out:
 /*
  * Set the access or default ACL of an inode.
  */
-static int ocfs2_set_acl(handle_t *handle,
+int ocfs2_set_acl(handle_t *handle,
                         struct inode *inode,
                         struct buffer_head *di_bh,
                         int type,
@@ -313,6 +283,11 @@ static int ocfs2_set_acl(handle_t *handle,
        return ret;
 }
 
+int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+       return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
+}
+
 struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
 {
        struct ocfs2_super *osb;
@@ -334,200 +309,3 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type)
 
        return acl;
 }
-
-int ocfs2_acl_chmod(struct inode *inode)
-{
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-       struct posix_acl *acl;
-       int ret;
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return 0;
-
-       acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-       ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (ret)
-               return ret;
-       ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
-                           acl, NULL, NULL);
-       posix_acl_release(acl);
-       return ret;
-}
-
-/*
- * Initialize the ACLs of a new inode. If parent directory has default ACL,
- * then clone to new inode. Called from ocfs2_mknod.
- */
-int ocfs2_init_acl(handle_t *handle,
-                  struct inode *inode,
-                  struct inode *dir,
-                  struct buffer_head *di_bh,
-                  struct buffer_head *dir_bh,
-                  struct ocfs2_alloc_context *meta_ac,
-                  struct ocfs2_alloc_context *data_ac)
-{
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-       struct posix_acl *acl = NULL;
-       int ret = 0, ret2;
-       umode_t mode;
-
-       if (!S_ISLNK(inode->i_mode)) {
-               if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
-                       acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT,
-                                                  dir_bh);
-                       if (IS_ERR(acl))
-                               return PTR_ERR(acl);
-               }
-               if (!acl) {
-                       mode = inode->i_mode & ~current_umask();
-                       ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
-                       if (ret) {
-                               mlog_errno(ret);
-                               goto cleanup;
-                       }
-               }
-       }
-       if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
-               if (S_ISDIR(inode->i_mode)) {
-                       ret = ocfs2_set_acl(handle, inode, di_bh,
-                                           ACL_TYPE_DEFAULT, acl,
-                                           meta_ac, data_ac);
-                       if (ret)
-                               goto cleanup;
-               }
-               mode = inode->i_mode;
-               ret = posix_acl_create(&acl, GFP_NOFS, &mode);
-               if (ret < 0)
-                       return ret;
-
-               ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
-               if (ret2) {
-                       mlog_errno(ret2);
-                       ret = ret2;
-                       goto cleanup;
-               }
-               if (ret > 0) {
-                       ret = ocfs2_set_acl(handle, inode,
-                                           di_bh, ACL_TYPE_ACCESS,
-                                           acl, meta_ac, data_ac);
-               }
-       }
-cleanup:
-       posix_acl_release(acl);
-       return ret;
-}
-
-static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry,
-                                         char *list,
-                                         size_t list_len,
-                                         const char *name,
-                                         size_t name_len,
-                                         int type)
-{
-       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
-       const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
-
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return 0;
-
-       if (list && size <= list_len)
-               memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
-       return size;
-}
-
-static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry,
-                                          char *list,
-                                          size_t list_len,
-                                          const char *name,
-                                          size_t name_len,
-                                          int type)
-{
-       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
-       const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
-
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return 0;
-
-       if (list && size <= list_len)
-               memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
-       return size;
-}
-
-static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name,
-               void *buffer, size_t size, int type)
-{
-       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
-       struct posix_acl *acl;
-       int ret;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return -EOPNOTSUPP;
-
-       acl = ocfs2_get_acl(dentry->d_inode, type);
-       if (IS_ERR(acl))
-               return PTR_ERR(acl);
-       if (acl == NULL)
-               return -ENODATA;
-       ret = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
-       posix_acl_release(acl);
-
-       return ret;
-}
-
-static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags, int type)
-{
-       struct inode *inode = dentry->d_inode;
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
-       struct posix_acl *acl;
-       int ret = 0;
-
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return -EOPNOTSUPP;
-
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       if (value) {
-               acl = posix_acl_from_xattr(&init_user_ns, value, size);
-               if (IS_ERR(acl))
-                       return PTR_ERR(acl);
-               else if (acl) {
-                       ret = posix_acl_valid(acl);
-                       if (ret)
-                               goto cleanup;
-               }
-       } else
-               acl = NULL;
-
-       ret = ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL);
-
-cleanup:
-       posix_acl_release(acl);
-       return ret;
-}
-
-const struct xattr_handler ocfs2_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .list   = ocfs2_xattr_list_acl_access,
-       .get    = ocfs2_xattr_get_acl,
-       .set    = ocfs2_xattr_set_acl,
-};
-
-const struct xattr_handler ocfs2_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .list   = ocfs2_xattr_list_acl_default,
-       .get    = ocfs2_xattr_get_acl,
-       .set    = ocfs2_xattr_set_acl,
-};
index 071fbd380f2f52889fe4ddc459df3bf603d7629e..3fce68d086251a6e26ea9805361e3a1ccb351d46 100644 (file)
@@ -27,10 +27,13 @@ struct ocfs2_acl_entry {
 };
 
 struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type);
-extern int ocfs2_acl_chmod(struct inode *);
-extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
-                         struct buffer_head *, struct buffer_head *,
-                         struct ocfs2_alloc_context *,
-                         struct ocfs2_alloc_context *);
+int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type);
+int ocfs2_set_acl(handle_t *handle,
+                        struct inode *inode,
+                        struct buffer_head *di_bh,
+                        int type,
+                        struct posix_acl *acl,
+                        struct ocfs2_alloc_context *meta_ac,
+                        struct ocfs2_alloc_context *data_ac);
 
 #endif /* OCFS2_ACL_H */
index f42eecef64781ecac5af385adbb9a91b19f02e51..d77d71ead8d12071a52b1f0f63c66f1077c93f84 100644 (file)
@@ -1236,7 +1236,7 @@ bail:
                dqput(transfer_to[qtype]);
 
        if (!status && attr->ia_valid & ATTR_MODE) {
-               status = ocfs2_acl_chmod(inode);
+               status = posix_acl_chmod(inode, inode->i_mode);
                if (status < 0)
                        mlog_errno(status);
        }
@@ -2662,6 +2662,7 @@ const struct inode_operations ocfs2_file_iops = {
        .removexattr    = generic_removexattr,
        .fiemap         = ocfs2_fiemap,
        .get_acl        = ocfs2_iop_get_acl,
+       .set_acl        = ocfs2_iop_set_acl,
 };
 
 const struct inode_operations ocfs2_special_file_iops = {
@@ -2669,6 +2670,7 @@ const struct inode_operations ocfs2_special_file_iops = {
        .getattr        = ocfs2_getattr,
        .permission     = ocfs2_permission,
        .get_acl        = ocfs2_iop_get_acl,
+       .set_acl        = ocfs2_iop_set_acl,
 };
 
 /*
index 41513a4e98e462b0da59fe29787f0352eb7b2eaf..f4d609be940086794ff8e64b1ed7cd832ba517f5 100644 (file)
@@ -230,6 +230,7 @@ static int ocfs2_mknod(struct inode *dir,
        struct ocfs2_dir_lookup_result lookup = { NULL, };
        sigset_t oldset;
        int did_block_signals = 0;
+       struct posix_acl *default_acl = NULL, *acl = NULL;
 
        trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name,
                          (unsigned long long)OCFS2_I(dir)->ip_blkno,
@@ -331,6 +332,12 @@ static int ocfs2_mknod(struct inode *dir,
                goto leave;
        }
 
+       status = posix_acl_create(dir, &mode, &default_acl, &acl);
+       if (status) {
+               mlog_errno(status);
+               goto leave;
+       }
+
        handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb,
                                                            S_ISDIR(mode),
                                                            xattr_credits));
@@ -379,8 +386,17 @@ static int ocfs2_mknod(struct inode *dir,
                inc_nlink(dir);
        }
 
-       status = ocfs2_init_acl(handle, inode, dir, new_fe_bh, parent_fe_bh,
-                               meta_ac, data_ac);
+       if (default_acl) {
+               status = ocfs2_set_acl(handle, inode, new_fe_bh,
+                                      ACL_TYPE_DEFAULT, default_acl,
+                                      meta_ac, data_ac);
+       }
+       if (!status && acl) {
+               status = ocfs2_set_acl(handle, inode, new_fe_bh,
+                                      ACL_TYPE_ACCESS, acl,
+                                      meta_ac, data_ac);
+       }
+
        if (status < 0) {
                mlog_errno(status);
                goto leave;
@@ -419,6 +435,10 @@ static int ocfs2_mknod(struct inode *dir,
        d_instantiate(dentry, inode);
        status = 0;
 leave:
+       if (default_acl)
+               posix_acl_release(default_acl);
+       if (acl)
+               posix_acl_release(acl);
        if (status < 0 && did_quota_inode)
                dquot_free_inode(inode);
        if (handle)
@@ -2504,4 +2524,5 @@ const struct inode_operations ocfs2_dir_iops = {
        .removexattr    = generic_removexattr,
        .fiemap         = ocfs2_fiemap,
        .get_acl        = ocfs2_iop_get_acl,
+       .set_acl        = ocfs2_iop_set_acl,
 };
index 55767e1ba72492431dcb3ae9fe204526d93f28d2..6ba4bcbc479601bcad6a98ba7a73ccc80dc40710 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/quotaops.h>
 #include <linux/namei.h>
 #include <linux/mount.h>
+#include <linux/posix_acl.h>
 
 struct ocfs2_cow_context {
        struct inode *inode;
@@ -4268,11 +4269,20 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
        struct inode *inode = old_dentry->d_inode;
        struct buffer_head *old_bh = NULL;
        struct inode *new_orphan_inode = NULL;
+       struct posix_acl *default_acl, *acl;
+       umode_t mode;
 
        if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)))
                return -EOPNOTSUPP;
 
-       error = ocfs2_create_inode_in_orphan(dir, inode->i_mode,
+       mode = inode->i_mode;
+       error = posix_acl_create(dir, &mode, &default_acl, &acl);
+       if (error) {
+               mlog_errno(error);
+               goto out;
+       }
+
+       error = ocfs2_create_inode_in_orphan(dir, mode,
                                             &new_orphan_inode);
        if (error) {
                mlog_errno(error);
@@ -4303,11 +4313,16 @@ static int ocfs2_reflink(struct dentry *old_dentry, struct inode *dir,
        /* If the security isn't preserved, we need to re-initialize them. */
        if (!preserve) {
                error = ocfs2_init_security_and_acl(dir, new_orphan_inode,
-                                                   &new_dentry->d_name);
+                                                   &new_dentry->d_name,
+                                                   default_acl, acl);
                if (error)
                        mlog_errno(error);
        }
 out:
+       if (default_acl)
+               posix_acl_release(default_acl);
+       if (acl)
+               posix_acl_release(acl);
        if (!error) {
                error = ocfs2_mv_orphaned_inode_to_new(dir, new_orphan_inode,
                                                       new_dentry);
index f0a1326d9bba89812f5ae736938ca3cfbee1284d..185fa3b7f962a482f06f9926cca946185672c7d6 100644 (file)
@@ -99,8 +99,8 @@ static struct ocfs2_xattr_def_value_root def_xv = {
 
 const struct xattr_handler *ocfs2_xattr_handlers[] = {
        &ocfs2_xattr_user_handler,
-       &ocfs2_xattr_acl_access_handler,
-       &ocfs2_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
        &ocfs2_xattr_trusted_handler,
        &ocfs2_xattr_security_handler,
        NULL
@@ -109,9 +109,9 @@ const struct xattr_handler *ocfs2_xattr_handlers[] = {
 static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
        [OCFS2_XATTR_INDEX_USER]        = &ocfs2_xattr_user_handler,
        [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS]
-                                       = &ocfs2_xattr_acl_access_handler,
+                                       = &posix_acl_access_xattr_handler,
        [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT]
-                                       = &ocfs2_xattr_acl_default_handler,
+                                       = &posix_acl_default_xattr_handler,
        [OCFS2_XATTR_INDEX_TRUSTED]     = &ocfs2_xattr_trusted_handler,
        [OCFS2_XATTR_INDEX_SECURITY]    = &ocfs2_xattr_security_handler,
 };
@@ -7190,10 +7190,12 @@ out:
  */
 int ocfs2_init_security_and_acl(struct inode *dir,
                                struct inode *inode,
-                               const struct qstr *qstr)
+                               const struct qstr *qstr,
+                               struct posix_acl *default_acl,
+                               struct posix_acl *acl)
 {
-       int ret = 0;
        struct buffer_head *dir_bh = NULL;
+       int ret = 0;
 
        ret = ocfs2_init_security_get(inode, dir, qstr, NULL);
        if (ret) {
@@ -7207,9 +7209,10 @@ int ocfs2_init_security_and_acl(struct inode *dir,
                goto leave;
        }
 
-       ret = ocfs2_init_acl(NULL, inode, dir, NULL, dir_bh, NULL, NULL);
-       if (ret)
-               mlog_errno(ret);
+       if (!ret && default_acl)
+               ret = ocfs2_iop_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+       if (!ret && acl)
+               ret = ocfs2_iop_set_acl(inode, acl, ACL_TYPE_ACCESS);
 
        ocfs2_inode_unlock(dir, 0);
        brelse(dir_bh);
index 19f134e896a9a8bdd69a387015819e4ebc3c2705..f10d5b93c366c8a7d12ddc1c90766ea88ed3dc56 100644 (file)
@@ -40,8 +40,6 @@ struct ocfs2_security_xattr_info {
 extern const struct xattr_handler ocfs2_xattr_user_handler;
 extern const struct xattr_handler ocfs2_xattr_trusted_handler;
 extern const struct xattr_handler ocfs2_xattr_security_handler;
-extern const struct xattr_handler ocfs2_xattr_acl_access_handler;
-extern const struct xattr_handler ocfs2_xattr_acl_default_handler;
 extern const struct xattr_handler *ocfs2_xattr_handlers[];
 
 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
@@ -96,5 +94,7 @@ int ocfs2_reflink_xattrs(struct inode *old_inode,
                         bool preserve_security);
 int ocfs2_init_security_and_acl(struct inode *dir,
                                struct inode *inode,
-                               const struct qstr *qstr);
+                               const struct qstr *qstr,
+                               struct posix_acl *default_acl,
+                               struct posix_acl *acl);
 #endif /* OCFS2_XATTR_H */
index 551e61ba15b6047c909594968163eaf26c8cb605..38bae5a0ea257ebc414aef89727f3a652d904c96 100644 (file)
@@ -1,10 +1,8 @@
 /*
- * linux/fs/posix_acl.c
+ * Copyright (C) 2002,2003 by Andreas Gruenbacher <a.gruenbacher@computer.org>
  *
- *  Copyright (C) 2002 by Andreas Gruenbacher <a.gruenbacher@computer.org>
- *
- *  Fixes from William Schumacher incorporated on 15 March 2001.
- *     (Reported by Charles Bertsch, <CBertsch@microtest.com>).
+ * Fixes from William Schumacher incorporated on 15 March 2001.
+ *    (Reported by Charles Bertsch, <CBertsch@microtest.com>).
  */
 
 /*
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/posix_acl.h>
+#include <linux/posix_acl_xattr.h>
+#include <linux/xattr.h>
 #include <linux/export.h>
-
-#include <linux/errno.h>
+#include <linux/user_namespace.h>
 
 struct posix_acl **acl_by_type(struct inode *inode, int type)
 {
@@ -97,6 +96,33 @@ void forget_all_cached_acls(struct inode *inode)
 }
 EXPORT_SYMBOL(forget_all_cached_acls);
 
+struct posix_acl *get_acl(struct inode *inode, int type)
+{
+       struct posix_acl *acl;
+
+       acl = get_cached_acl(inode, type);
+       if (acl != ACL_NOT_CACHED)
+               return acl;
+
+       if (!IS_POSIXACL(inode))
+               return NULL;
+
+       /*
+        * A filesystem can force a ACL callback by just never filling the
+        * ACL cache. But normally you'd fill the cache either at inode
+        * instantiation time, or on the first ->get_acl call.
+        *
+        * If the filesystem doesn't have a get_acl() function at all, we'll
+        * just create the negative cache entry.
+        */
+       if (!inode->i_op->get_acl) {
+               set_cached_acl(inode, type, NULL);
+               return NULL;
+       }
+       return inode->i_op->get_acl(inode, type);
+}
+EXPORT_SYMBOL(get_acl);
+
 /*
  * Init a fresh posix_acl
  */
@@ -402,7 +428,7 @@ static int posix_acl_create_masq(struct posix_acl *acl, umode_t *mode_p)
 /*
  * Modify the ACL for the chmod syscall.
  */
-static int posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode)
+static int __posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode)
 {
        struct posix_acl_entry *group_obj = NULL, *mask_obj = NULL;
        struct posix_acl_entry *pa, *pe;
@@ -448,7 +474,7 @@ static int posix_acl_chmod_masq(struct posix_acl *acl, umode_t mode)
 }
 
 int
-posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
+__posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
 {
        struct posix_acl *clone = posix_acl_clone(*acl, gfp);
        int err = -ENOMEM;
@@ -463,15 +489,15 @@ posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
        *acl = clone;
        return err;
 }
-EXPORT_SYMBOL(posix_acl_create);
+EXPORT_SYMBOL(__posix_acl_create);
 
 int
-posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
+__posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
 {
        struct posix_acl *clone = posix_acl_clone(*acl, gfp);
        int err = -ENOMEM;
        if (clone) {
-               err = posix_acl_chmod_masq(clone, mode);
+               err = __posix_acl_chmod_masq(clone, mode);
                if (err) {
                        posix_acl_release(clone);
                        clone = NULL;
@@ -481,4 +507,382 @@ posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
        *acl = clone;
        return err;
 }
+EXPORT_SYMBOL(__posix_acl_chmod);
+
+int
+posix_acl_chmod(struct inode *inode, umode_t mode)
+{
+       struct posix_acl *acl;
+       int ret = 0;
+
+       if (!IS_POSIXACL(inode))
+               return 0;
+       if (!inode->i_op->set_acl)
+               return -EOPNOTSUPP;
+
+       acl = get_acl(inode, ACL_TYPE_ACCESS);
+       if (IS_ERR_OR_NULL(acl))
+               return PTR_ERR(acl);
+
+       ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode);
+       if (ret)
+               return ret;
+       ret = inode->i_op->set_acl(inode, acl, ACL_TYPE_ACCESS);
+       posix_acl_release(acl);
+       return ret;
+}
 EXPORT_SYMBOL(posix_acl_chmod);
+
+int
+posix_acl_create(struct inode *dir, umode_t *mode,
+               struct posix_acl **default_acl, struct posix_acl **acl)
+{
+       struct posix_acl *p;
+       int ret;
+
+       if (S_ISLNK(*mode) || !IS_POSIXACL(dir))
+               goto no_acl;
+
+       p = get_acl(dir, ACL_TYPE_DEFAULT);
+       if (IS_ERR(p))
+               return PTR_ERR(p);
+
+       if (!p) {
+               *mode &= ~current_umask();
+               goto no_acl;
+       }
+
+       *acl = posix_acl_clone(p, GFP_NOFS);
+       if (!*acl)
+               return -ENOMEM;
+
+       ret = posix_acl_create_masq(*acl, mode);
+       if (ret < 0) {
+               posix_acl_release(*acl);
+               return -ENOMEM;
+       }
+
+       if (ret == 0) {
+               posix_acl_release(*acl);
+               *acl = NULL;
+       }
+
+       if (!S_ISDIR(*mode)) {
+               posix_acl_release(p);
+               *default_acl = NULL;
+       } else {
+               *default_acl = p;
+       }
+       return 0;
+
+no_acl:
+       *default_acl = NULL;
+       *acl = NULL;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(posix_acl_create);
+
+/*
+ * Fix up the uids and gids in posix acl extended attributes in place.
+ */
+static void posix_acl_fix_xattr_userns(
+       struct user_namespace *to, struct user_namespace *from,
+       void *value, size_t size)
+{
+       posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
+       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
+       int count;
+       kuid_t uid;
+       kgid_t gid;
+
+       if (!value)
+               return;
+       if (size < sizeof(posix_acl_xattr_header))
+               return;
+       if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
+               return;
+
+       count = posix_acl_xattr_count(size);
+       if (count < 0)
+               return;
+       if (count == 0)
+               return;
+
+       for (end = entry + count; entry != end; entry++) {
+               switch(le16_to_cpu(entry->e_tag)) {
+               case ACL_USER:
+                       uid = make_kuid(from, le32_to_cpu(entry->e_id));
+                       entry->e_id = cpu_to_le32(from_kuid(to, uid));
+                       break;
+               case ACL_GROUP:
+                       gid = make_kgid(from, le32_to_cpu(entry->e_id));
+                       entry->e_id = cpu_to_le32(from_kgid(to, gid));
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+void posix_acl_fix_xattr_from_user(void *value, size_t size)
+{
+       struct user_namespace *user_ns = current_user_ns();
+       if (user_ns == &init_user_ns)
+               return;
+       posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
+}
+
+void posix_acl_fix_xattr_to_user(void *value, size_t size)
+{
+       struct user_namespace *user_ns = current_user_ns();
+       if (user_ns == &init_user_ns)
+               return;
+       posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
+}
+
+/*
+ * Convert from extended attribute to in-memory representation.
+ */
+struct posix_acl *
+posix_acl_from_xattr(struct user_namespace *user_ns,
+                    const void *value, size_t size)
+{
+       posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
+       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
+       int count;
+       struct posix_acl *acl;
+       struct posix_acl_entry *acl_e;
+
+       if (!value)
+               return NULL;
+       if (size < sizeof(posix_acl_xattr_header))
+                return ERR_PTR(-EINVAL);
+       if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
+               return ERR_PTR(-EOPNOTSUPP);
+
+       count = posix_acl_xattr_count(size);
+       if (count < 0)
+               return ERR_PTR(-EINVAL);
+       if (count == 0)
+               return NULL;
+       
+       acl = posix_acl_alloc(count, GFP_NOFS);
+       if (!acl)
+               return ERR_PTR(-ENOMEM);
+       acl_e = acl->a_entries;
+       
+       for (end = entry + count; entry != end; acl_e++, entry++) {
+               acl_e->e_tag  = le16_to_cpu(entry->e_tag);
+               acl_e->e_perm = le16_to_cpu(entry->e_perm);
+
+               switch(acl_e->e_tag) {
+                       case ACL_USER_OBJ:
+                       case ACL_GROUP_OBJ:
+                       case ACL_MASK:
+                       case ACL_OTHER:
+                               break;
+
+                       case ACL_USER:
+                               acl_e->e_uid =
+                                       make_kuid(user_ns,
+                                                 le32_to_cpu(entry->e_id));
+                               if (!uid_valid(acl_e->e_uid))
+                                       goto fail;
+                               break;
+                       case ACL_GROUP:
+                               acl_e->e_gid =
+                                       make_kgid(user_ns,
+                                                 le32_to_cpu(entry->e_id));
+                               if (!gid_valid(acl_e->e_gid))
+                                       goto fail;
+                               break;
+
+                       default:
+                               goto fail;
+               }
+       }
+       return acl;
+
+fail:
+       posix_acl_release(acl);
+       return ERR_PTR(-EINVAL);
+}
+EXPORT_SYMBOL (posix_acl_from_xattr);
+
+/*
+ * Convert from in-memory to extended attribute representation.
+ */
+int
+posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
+                  void *buffer, size_t size)
+{
+       posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer;
+       posix_acl_xattr_entry *ext_entry = ext_acl->a_entries;
+       int real_size, n;
+
+       real_size = posix_acl_xattr_size(acl->a_count);
+       if (!buffer)
+               return real_size;
+       if (real_size > size)
+               return -ERANGE;
+       
+       ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
+
+       for (n=0; n < acl->a_count; n++, ext_entry++) {
+               const struct posix_acl_entry *acl_e = &acl->a_entries[n];
+               ext_entry->e_tag  = cpu_to_le16(acl_e->e_tag);
+               ext_entry->e_perm = cpu_to_le16(acl_e->e_perm);
+               switch(acl_e->e_tag) {
+               case ACL_USER:
+                       ext_entry->e_id =
+                               cpu_to_le32(from_kuid(user_ns, acl_e->e_uid));
+                       break;
+               case ACL_GROUP:
+                       ext_entry->e_id =
+                               cpu_to_le32(from_kgid(user_ns, acl_e->e_gid));
+                       break;
+               default:
+                       ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID);
+                       break;
+               }
+       }
+       return real_size;
+}
+EXPORT_SYMBOL (posix_acl_to_xattr);
+
+static int
+posix_acl_xattr_get(struct dentry *dentry, const char *name,
+               void *value, size_t size, int type)
+{
+       struct posix_acl *acl;
+       int error;
+
+       if (!IS_POSIXACL(dentry->d_inode))
+               return -EOPNOTSUPP;
+       if (S_ISLNK(dentry->d_inode->i_mode))
+               return -EOPNOTSUPP;
+
+       acl = 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, value, size);
+       posix_acl_release(acl);
+
+       return error;
+}
+
+static int
+posix_acl_xattr_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
+{
+       struct inode *inode = dentry->d_inode;
+       struct posix_acl *acl = NULL;
+       int ret;
+
+       if (!IS_POSIXACL(inode))
+               return -EOPNOTSUPP;
+       if (!inode->i_op->set_acl)
+               return -EOPNOTSUPP;
+
+       if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
+               return value ? -EACCES : 0;
+       if (!inode_owner_or_capable(inode))
+               return -EPERM;
+
+       if (value) {
+               acl = posix_acl_from_xattr(&init_user_ns, value, size);
+               if (IS_ERR(acl))
+                       return PTR_ERR(acl);
+
+               if (acl) {
+                       ret = posix_acl_valid(acl);
+                       if (ret)
+                               goto out;
+               }
+       }
+
+       ret = inode->i_op->set_acl(inode, acl, type);
+out:
+       posix_acl_release(acl);
+       return ret;
+}
+
+static size_t
+posix_acl_xattr_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
+{
+       const char *xname;
+       size_t size;
+
+       if (!IS_POSIXACL(dentry->d_inode))
+               return -EOPNOTSUPP;
+       if (S_ISLNK(dentry->d_inode->i_mode))
+               return -EOPNOTSUPP;
+
+       if (type == ACL_TYPE_ACCESS)
+               xname = POSIX_ACL_XATTR_ACCESS;
+       else
+               xname = POSIX_ACL_XATTR_DEFAULT;
+
+       size = strlen(xname) + 1;
+       if (list && size <= list_size)
+               memcpy(list, xname, size);
+       return size;
+}
+
+const struct xattr_handler posix_acl_access_xattr_handler = {
+       .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags = ACL_TYPE_ACCESS,
+       .list = posix_acl_xattr_list,
+       .get = posix_acl_xattr_get,
+       .set = posix_acl_xattr_set,
+};
+EXPORT_SYMBOL_GPL(posix_acl_access_xattr_handler);
+
+const struct xattr_handler posix_acl_default_xattr_handler = {
+       .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags = ACL_TYPE_DEFAULT,
+       .list = posix_acl_xattr_list,
+       .get = posix_acl_xattr_get,
+       .set = posix_acl_xattr_set,
+};
+EXPORT_SYMBOL_GPL(posix_acl_default_xattr_handler);
+
+int simple_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+       int error;
+
+       if (type == ACL_TYPE_ACCESS) {
+               error = posix_acl_equiv_mode(acl, &inode->i_mode);
+               if (error < 0)
+                       return 0;
+               if (error == 0)
+                       acl = NULL;
+       }
+
+       inode->i_ctime = CURRENT_TIME;
+       set_cached_acl(inode, type, acl);
+       return 0;
+}
+
+int simple_acl_create(struct inode *dir, struct inode *inode)
+{
+       struct posix_acl *default_acl, *acl;
+       int error;
+
+       error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+       if (error)
+               return error;
+
+       set_cached_acl(inode, ACL_TYPE_DEFAULT, default_acl);
+       set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
+
+       if (default_acl)
+               posix_acl_release(default_acl);
+       if (acl)
+               posix_acl_release(acl);
+       return 0;
+}
index 2e8caa62da78a71cc1ee46ce49634aab9408a779..89558810381c497389c184856d30efd0a2ce9717 100644 (file)
@@ -27,7 +27,6 @@
 
 static const struct super_operations qnx4_sops;
 
-static void qnx4_put_super(struct super_block *sb);
 static struct inode *qnx4_alloc_inode(struct super_block *sb);
 static void qnx4_destroy_inode(struct inode *inode);
 static int qnx4_remount(struct super_block *sb, int *flags, char *data);
@@ -37,7 +36,6 @@ static const struct super_operations qnx4_sops =
 {
        .alloc_inode    = qnx4_alloc_inode,
        .destroy_inode  = qnx4_destroy_inode,
-       .put_super      = qnx4_put_super,
        .statfs         = qnx4_statfs,
        .remount_fs     = qnx4_remount,
 };
@@ -148,18 +146,19 @@ static int qnx4_statfs(struct dentry *dentry, struct kstatfs *buf)
  * it really _is_ a qnx4 filesystem, and to check the size
  * of the directory entry.
  */
-static const char *qnx4_checkroot(struct super_block *sb)
+static const char *qnx4_checkroot(struct super_block *sb,
+                                 struct qnx4_super_block *s)
 {
        struct buffer_head *bh;
        struct qnx4_inode_entry *rootdir;
        int rd, rl;
        int i, j;
 
-       if (*(qnx4_sb(sb)->sb->RootDir.di_fname) != '/')
+       if (s->RootDir.di_fname[0] != '/' || s->RootDir.di_fname[1] != '\0')
                return "no qnx4 filesystem (no root dir).";
        QNX4DEBUG((KERN_NOTICE "QNX4 filesystem found on dev %s.\n", sb->s_id));
-       rd = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_blk) - 1;
-       rl = le32_to_cpu(qnx4_sb(sb)->sb->RootDir.di_first_xtnt.xtnt_size);
+       rd = le32_to_cpu(s->RootDir.di_first_xtnt.xtnt_blk) - 1;
+       rl = le32_to_cpu(s->RootDir.di_first_xtnt.xtnt_size);
        for (j = 0; j < rl; j++) {
                bh = sb_bread(sb, rd + j);      /* root dir, first block */
                if (bh == NULL)
@@ -189,7 +188,6 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
        struct inode *root;
        const char *errmsg;
        struct qnx4_sb_info *qs;
-       int ret = -EINVAL;
 
        qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL);
        if (!qs)
@@ -198,67 +196,50 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
 
        sb_set_blocksize(s, QNX4_BLOCK_SIZE);
 
+       s->s_op = &qnx4_sops;
+       s->s_magic = QNX4_SUPER_MAGIC;
+       s->s_flags |= MS_RDONLY;        /* Yup, read-only yet */
+
        /* Check the superblock signature. Since the qnx4 code is
           dangerous, we should leave as quickly as possible
           if we don't belong here... */
        bh = sb_bread(s, 1);
        if (!bh) {
                printk(KERN_ERR "qnx4: unable to read the superblock\n");
-               goto outnobh;
+               return -EINVAL;
        }
-       if ( le32_to_cpup((__le32*) bh->b_data) != QNX4_SUPER_MAGIC ) {
-               if (!silent)
-                       printk(KERN_ERR "qnx4: wrong fsid in superblock.\n");
-               goto out;
-       }
-       s->s_op = &qnx4_sops;
-       s->s_magic = QNX4_SUPER_MAGIC;
-       s->s_flags |= MS_RDONLY;        /* Yup, read-only yet */
-       qnx4_sb(s)->sb_buf = bh;
-       qnx4_sb(s)->sb = (struct qnx4_super_block *) bh->b_data;
-
 
        /* check before allocating dentries, inodes, .. */
-       errmsg = qnx4_checkroot(s);
+       errmsg = qnx4_checkroot(s, (struct qnx4_super_block *) bh->b_data);
+       brelse(bh);
        if (errmsg != NULL) {
                if (!silent)
                        printk(KERN_ERR "qnx4: %s\n", errmsg);
-               goto out;
+               return -EINVAL;
        }
 
        /* does root not have inode number QNX4_ROOT_INO ?? */
        root = qnx4_iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK);
        if (IS_ERR(root)) {
                printk(KERN_ERR "qnx4: get inode failed\n");
-               ret = PTR_ERR(root);
-               goto outb;
+               return PTR_ERR(root);
        }
 
-       ret = -ENOMEM;
        s->s_root = d_make_root(root);
        if (s->s_root == NULL)
-               goto outb;
+               return -ENOMEM;
 
-       brelse(bh);
        return 0;
-
-      outb:
-       kfree(qs->BitMap);
-      out:
-       brelse(bh);
-      outnobh:
-       kfree(qs);
-       s->s_fs_info = NULL;
-       return ret;
 }
 
-static void qnx4_put_super(struct super_block *sb)
+static void qnx4_kill_sb(struct super_block *sb)
 {
        struct qnx4_sb_info *qs = qnx4_sb(sb);
-       kfree( qs->BitMap );
-       kfree( qs );
-       sb->s_fs_info = NULL;
-       return;
+       kill_block_super(sb);
+       if (qs) {
+               kfree(qs->BitMap);
+               kfree(qs);
+       }
 }
 
 static int qnx4_readpage(struct file *file, struct page *page)
@@ -409,7 +390,7 @@ static struct file_system_type qnx4_fs_type = {
        .owner          = THIS_MODULE,
        .name           = "qnx4",
        .mount          = qnx4_mount,
-       .kill_sb        = kill_block_super,
+       .kill_sb        = qnx4_kill_sb,
        .fs_flags       = FS_REQUIRES_DEV,
 };
 MODULE_ALIAS_FS("qnx4");
index 34e2d329c97e057f330d83f835fd111f931607be..c9b1be2c164dd9339b94cddd2a9d21ad2abd7577 100644 (file)
@@ -10,8 +10,6 @@
 #endif
 
 struct qnx4_sb_info {
-       struct buffer_head      *sb_buf;        /* superblock buffer */
-       struct qnx4_super_block *sb;            /* our superblock */
        unsigned int            Version;        /* may be useful */
        struct qnx4_inode_entry *BitMap;        /* useful */
 };
index f096b80e73d8145dc35bcdb36f008d29a61f07d9..4a211f5b34b81f00dc123c251a3adc7aff9dcf93 100644 (file)
@@ -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)
 {
index dcaafcfc23b007c845f490a4f293cc485c324b51..ed58d843d57856ac3cdc87288465d0d5156708e9 100644 (file)
@@ -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,
 };
index dc5236f6de1be129e44caf8f78f16d010d7ad7fb..e825f8b63e6b7433c125e040117de525a2d0cf31 100644 (file)
@@ -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,
 };
index a958444a75fc310627d56de6a37e28a15a99273a..02b0b7d0f7d532e0ed0238161118ae627f5d9b7c 100644 (file)
@@ -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 = '!';
index dfb617b2bad2ae1ada39a9ff36684793cfed51f1..8d06adf899488a53e13e97b5d2973ca536e430b0 100644 (file)
@@ -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)
index 3ead145dadc406646f742f519befe3ef9a2db6b9..2c803353f8ac4f70099f7cef6a590c46556c21d6 100644 (file)
@@ -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;
        }
 
index 8a9e2dcfe004919da6fe48e4c292c7ddfeef8476..5cdfbd638b5c929382d844d358105619301eed48 100644 (file)
@@ -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
 };
index 06c04f73da6529d012ee0c8b0d364cef939709ea..a6ce532402dc7ec9851e18fe572c3ad1faf14a2a 100644 (file)
 #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;
-
-       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;
+       int size = acl ? posix_acl_xattr_size(acl->a_count) : 0;
+
 
        /* 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;
-}
-
-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;
+       return posix_acl_chmod(inode, inode->i_mode);
 }
-
-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,
-};
diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
deleted file mode 100644 (file)
index 9fbea87..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * linux/fs/xattr_acl.c
- *
- * Almost all from linux/fs/ext2/acl.c:
- * Copyright (C) 2001 by Andreas Gruenbacher, <a.gruenbacher@computer.org>
- */
-
-#include <linux/export.h>
-#include <linux/fs.h>
-#include <linux/posix_acl_xattr.h>
-#include <linux/gfp.h>
-#include <linux/user_namespace.h>
-
-/*
- * Fix up the uids and gids in posix acl extended attributes in place.
- */
-static void posix_acl_fix_xattr_userns(
-       struct user_namespace *to, struct user_namespace *from,
-       void *value, size_t size)
-{
-       posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
-       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
-       int count;
-       kuid_t uid;
-       kgid_t gid;
-
-       if (!value)
-               return;
-       if (size < sizeof(posix_acl_xattr_header))
-               return;
-       if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
-               return;
-
-       count = posix_acl_xattr_count(size);
-       if (count < 0)
-               return;
-       if (count == 0)
-               return;
-
-       for (end = entry + count; entry != end; entry++) {
-               switch(le16_to_cpu(entry->e_tag)) {
-               case ACL_USER:
-                       uid = make_kuid(from, le32_to_cpu(entry->e_id));
-                       entry->e_id = cpu_to_le32(from_kuid(to, uid));
-                       break;
-               case ACL_GROUP:
-                       gid = make_kgid(from, le32_to_cpu(entry->e_id));
-                       entry->e_id = cpu_to_le32(from_kgid(to, gid));
-                       break;
-               default:
-                       break;
-               }
-       }
-}
-
-void posix_acl_fix_xattr_from_user(void *value, size_t size)
-{
-       struct user_namespace *user_ns = current_user_ns();
-       if (user_ns == &init_user_ns)
-               return;
-       posix_acl_fix_xattr_userns(&init_user_ns, user_ns, value, size);
-}
-
-void posix_acl_fix_xattr_to_user(void *value, size_t size)
-{
-       struct user_namespace *user_ns = current_user_ns();
-       if (user_ns == &init_user_ns)
-               return;
-       posix_acl_fix_xattr_userns(user_ns, &init_user_ns, value, size);
-}
-
-/*
- * Convert from extended attribute to in-memory representation.
- */
-struct posix_acl *
-posix_acl_from_xattr(struct user_namespace *user_ns,
-                    const void *value, size_t size)
-{
-       posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
-       posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
-       int count;
-       struct posix_acl *acl;
-       struct posix_acl_entry *acl_e;
-
-       if (!value)
-               return NULL;
-       if (size < sizeof(posix_acl_xattr_header))
-                return ERR_PTR(-EINVAL);
-       if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION))
-               return ERR_PTR(-EOPNOTSUPP);
-
-       count = posix_acl_xattr_count(size);
-       if (count < 0)
-               return ERR_PTR(-EINVAL);
-       if (count == 0)
-               return NULL;
-       
-       acl = posix_acl_alloc(count, GFP_NOFS);
-       if (!acl)
-               return ERR_PTR(-ENOMEM);
-       acl_e = acl->a_entries;
-       
-       for (end = entry + count; entry != end; acl_e++, entry++) {
-               acl_e->e_tag  = le16_to_cpu(entry->e_tag);
-               acl_e->e_perm = le16_to_cpu(entry->e_perm);
-
-               switch(acl_e->e_tag) {
-                       case ACL_USER_OBJ:
-                       case ACL_GROUP_OBJ:
-                       case ACL_MASK:
-                       case ACL_OTHER:
-                               break;
-
-                       case ACL_USER:
-                               acl_e->e_uid =
-                                       make_kuid(user_ns,
-                                                 le32_to_cpu(entry->e_id));
-                               if (!uid_valid(acl_e->e_uid))
-                                       goto fail;
-                               break;
-                       case ACL_GROUP:
-                               acl_e->e_gid =
-                                       make_kgid(user_ns,
-                                                 le32_to_cpu(entry->e_id));
-                               if (!gid_valid(acl_e->e_gid))
-                                       goto fail;
-                               break;
-
-                       default:
-                               goto fail;
-               }
-       }
-       return acl;
-
-fail:
-       posix_acl_release(acl);
-       return ERR_PTR(-EINVAL);
-}
-EXPORT_SYMBOL (posix_acl_from_xattr);
-
-/*
- * Convert from in-memory to extended attribute representation.
- */
-int
-posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
-                  void *buffer, size_t size)
-{
-       posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer;
-       posix_acl_xattr_entry *ext_entry = ext_acl->a_entries;
-       int real_size, n;
-
-       real_size = posix_acl_xattr_size(acl->a_count);
-       if (!buffer)
-               return real_size;
-       if (real_size > size)
-               return -ERANGE;
-       
-       ext_acl->a_version = cpu_to_le32(POSIX_ACL_XATTR_VERSION);
-
-       for (n=0; n < acl->a_count; n++, ext_entry++) {
-               const struct posix_acl_entry *acl_e = &acl->a_entries[n];
-               ext_entry->e_tag  = cpu_to_le16(acl_e->e_tag);
-               ext_entry->e_perm = cpu_to_le16(acl_e->e_perm);
-               switch(acl_e->e_tag) {
-               case ACL_USER:
-                       ext_entry->e_id =
-                               cpu_to_le32(from_kuid(user_ns, acl_e->e_uid));
-                       break;
-               case ACL_GROUP:
-                       ext_entry->e_id =
-                               cpu_to_le32(from_kgid(user_ns, acl_e->e_gid));
-                       break;
-               default:
-                       ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID);
-                       break;
-               }
-       }
-       return real_size;
-}
-EXPORT_SYMBOL (posix_acl_to_xattr);
index 370eb3e121d1b2f292c65ddabd660ad08ae65537..0ecec1896f25439f198c53c93bc058ff3bff9c89 100644 (file)
@@ -124,16 +124,12 @@ struct posix_acl *
 xfs_get_acl(struct inode *inode, int type)
 {
        struct xfs_inode *ip = XFS_I(inode);
-       struct posix_acl *acl;
+       struct posix_acl *acl = NULL;
        struct xfs_acl *xfs_acl;
        unsigned char *ea_name;
        int error;
        int len;
 
-       acl = get_cached_acl(inode, type);
-       if (acl != ACL_NOT_CACHED)
-               return acl;
-
        trace_xfs_get_acl(ip);
 
        switch (type) {
@@ -164,10 +160,8 @@ xfs_get_acl(struct inode *inode, int type)
                 * cache entry, for any other error assume it is transient and
                 * leave the cache entry as ACL_NOT_CACHED.
                 */
-               if (error == -ENOATTR) {
-                       acl = NULL;
+               if (error == -ENOATTR)
                        goto out_update_cache;
-               }
                goto out;
        }
 
@@ -183,15 +177,12 @@ out:
 }
 
 STATIC int
-xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
+__xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
 {
        struct xfs_inode *ip = XFS_I(inode);
        unsigned char *ea_name;
        int error;
 
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                ea_name = SGI_ACL_FILE;
@@ -282,131 +273,23 @@ posix_acl_default_exists(struct inode *inode)
        return xfs_acl_exists(inode, SGI_ACL_DEFAULT);
 }
 
-/*
- * No need for i_mutex because the inode is not yet exposed to the VFS.
- */
 int
-xfs_inherit_acl(struct inode *inode, struct posix_acl *acl)
+xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
 {
-       umode_t mode = inode->i_mode;
-       int error = 0, inherit = 0;
-
-       if (S_ISDIR(inode->i_mode)) {
-               error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, acl);
-               if (error)
-                       goto out;
-       }
-
-       error = posix_acl_create(&acl, GFP_KERNEL, &mode);
-       if (error < 0)
-               return error;
-
-       /*
-        * If posix_acl_create returns a positive value we need to
-        * inherit a permission that can't be represented using the Unix
-        * mode bits and we actually need to set an ACL.
-        */
-       if (error > 0)
-               inherit = 1;
-
-       error = xfs_set_mode(inode, mode);
-       if (error)
-               goto out;
-
-       if (inherit)
-               error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
-
-out:
-       posix_acl_release(acl);
-       return error;
-}
-
-int
-xfs_acl_chmod(struct inode *inode)
-{
-       struct posix_acl *acl;
-       int error;
-
-       if (S_ISLNK(inode->i_mode))
-               return -EOPNOTSUPP;
-
-       acl = xfs_get_acl(inode, ACL_TYPE_ACCESS);
-       if (IS_ERR(acl) || !acl)
-               return PTR_ERR(acl);
-
-       error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
-       if (error)
-               return error;
-
-       error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
-       posix_acl_release(acl);
-       return error;
-}
-
-static int
-xfs_xattr_acl_get(struct dentry *dentry, const char *name,
-               void *value, size_t size, int type)
-{
-       struct posix_acl *acl;
-       int error;
-
-       acl = xfs_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, value, size);
-       posix_acl_release(acl);
-
-       return error;
-}
-
-static int
-xfs_xattr_acl_set(struct dentry *dentry, const char *name,
-               const void *value, size_t size, int flags, int type)
-{
-       struct inode *inode = dentry->d_inode;
-       struct posix_acl *acl = NULL;
        int error = 0;
 
-       if (flags & XATTR_CREATE)
-               return -EINVAL;
-       if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
-               return value ? -EACCES : 0;
-       if (!inode_owner_or_capable(inode))
-               return -EPERM;
-
-       if (!value)
+       if (!acl)
                goto set_acl;
 
-       acl = posix_acl_from_xattr(&init_user_ns, value, size);
-       if (!acl) {
-               /*
-                * acl_set_file(3) may request that we set default ACLs with
-                * zero length -- defend (gracefully) against that here.
-                */
-               goto out;
-       }
-       if (IS_ERR(acl)) {
-               error = PTR_ERR(acl);
-               goto out;
-       }
-
-       error = posix_acl_valid(acl);
-       if (error)
-               goto out_release;
-
        error = -EINVAL;
        if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode->i_sb)))
-               goto out_release;
+               return error;
 
        if (type == ACL_TYPE_ACCESS) {
                umode_t mode = inode->i_mode;
                error = posix_acl_equiv_mode(acl, &mode);
 
                if (error <= 0) {
-                       posix_acl_release(acl);
                        acl = NULL;
 
                        if (error < 0)
@@ -415,27 +298,9 @@ xfs_xattr_acl_set(struct dentry *dentry, const char *name,
 
                error = xfs_set_mode(inode, mode);
                if (error)
-                       goto out_release;
+                       return error;
        }
 
  set_acl:
-       error = xfs_set_acl(inode, type, acl);
- out_release:
-       posix_acl_release(acl);
- out:
-       return error;
+       return __xfs_set_acl(inode, type, acl);
 }
-
-const struct xattr_handler xfs_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .flags  = ACL_TYPE_ACCESS,
-       .get    = xfs_xattr_acl_get,
-       .set    = xfs_xattr_acl_set,
-};
-
-const struct xattr_handler xfs_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .flags  = ACL_TYPE_DEFAULT,
-       .get    = xfs_xattr_acl_get,
-       .set    = xfs_xattr_acl_set,
-};
index 4016a567b83cc2e00d46b5f4629bfc83785a7dff..5dc163744511b7c4de1f93e1dd33080d8becd062 100644 (file)
@@ -60,20 +60,15 @@ struct xfs_acl {
 
 #ifdef CONFIG_XFS_POSIX_ACL
 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type);
-extern int xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl);
-extern int xfs_acl_chmod(struct inode *inode);
+extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int posix_acl_access_exists(struct inode *inode);
 extern int posix_acl_default_exists(struct inode *inode);
-
-extern const struct xattr_handler xfs_xattr_acl_access_handler;
-extern const struct xattr_handler xfs_xattr_acl_default_handler;
 #else
 static inline struct posix_acl *xfs_get_acl(struct inode *inode, int type)
 {
        return NULL;
 }
-# define xfs_inherit_acl(inode, default_acl)           0
-# define xfs_acl_chmod(inode)                          0
+# define xfs_set_acl                                   NULL
 # define posix_acl_access_exists(inode)                        0
 # define posix_acl_default_exists(inode)               0
 #endif /* CONFIG_XFS_POSIX_ACL */
index 0ce1d759156e48ae092d566d30e713d7e597f29c..f35d5c953ff953dcde133c4b55568d1920db3589 100644 (file)
@@ -123,7 +123,7 @@ xfs_vn_mknod(
 {
        struct inode    *inode;
        struct xfs_inode *ip = NULL;
-       struct posix_acl *default_acl = NULL;
+       struct posix_acl *default_acl, *acl;
        struct xfs_name name;
        int             error;
 
@@ -139,14 +139,9 @@ xfs_vn_mknod(
                rdev = 0;
        }
 
-       if (IS_POSIXACL(dir)) {
-               default_acl = xfs_get_acl(dir, ACL_TYPE_DEFAULT);
-               if (IS_ERR(default_acl))
-                       return PTR_ERR(default_acl);
-
-               if (!default_acl)
-                       mode &= ~current_umask();
-       }
+       error = posix_acl_create(dir, &mode, &default_acl, &acl);
+       if (error)
+               return error;
 
        xfs_dentry_to_name(&name, dentry, mode);
        error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip);
@@ -159,22 +154,30 @@ xfs_vn_mknod(
        if (unlikely(error))
                goto out_cleanup_inode;
 
+#ifdef CONFIG_XFS_POSIX_ACL
        if (default_acl) {
-               error = -xfs_inherit_acl(inode, default_acl);
-               default_acl = NULL;
-               if (unlikely(error))
+               error = xfs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+               if (error)
                        goto out_cleanup_inode;
        }
-
+       if (acl) {
+               error = xfs_set_acl(inode, acl, ACL_TYPE_ACCESS);
+               if (error)
+                       goto out_cleanup_inode;
+       }
+#endif
 
        d_instantiate(dentry, inode);
+ out_free_acl:
+       if (default_acl)
+               posix_acl_release(default_acl);
+       if (acl)
+               posix_acl_release(acl);
        return -error;
 
  out_cleanup_inode:
        xfs_cleanup_inode(dir, inode, dentry);
- out_free_acl:
-       posix_acl_release(default_acl);
-       return -error;
+       goto out_free_acl;
 }
 
 STATIC int
@@ -391,18 +394,6 @@ xfs_vn_follow_link(
        return NULL;
 }
 
-STATIC void
-xfs_vn_put_link(
-       struct dentry   *dentry,
-       struct nameidata *nd,
-       void            *p)
-{
-       char            *s = nd_get_link(nd);
-
-       if (!IS_ERR(s))
-               kfree(s);
-}
-
 STATIC int
 xfs_vn_getattr(
        struct vfsmount         *mnt,
@@ -688,7 +679,7 @@ xfs_setattr_nonsize(
         *           Posix ACL code seems to care about this issue either.
         */
        if ((mask & ATTR_MODE) && !(flags & XFS_ATTR_NOACL)) {
-               error = -xfs_acl_chmod(inode);
+               error = -posix_acl_chmod(inode, inode->i_mode);
                if (error)
                        return XFS_ERROR(error);
        }
@@ -1045,6 +1036,7 @@ xfs_vn_fiemap(
 
 static const struct inode_operations xfs_inode_operations = {
        .get_acl                = xfs_get_acl,
+       .set_acl                = xfs_set_acl,
        .getattr                = xfs_vn_getattr,
        .setattr                = xfs_vn_setattr,
        .setxattr               = generic_setxattr,
@@ -1072,6 +1064,7 @@ static const struct inode_operations xfs_dir_inode_operations = {
        .mknod                  = xfs_vn_mknod,
        .rename                 = xfs_vn_rename,
        .get_acl                = xfs_get_acl,
+       .set_acl                = xfs_set_acl,
        .getattr                = xfs_vn_getattr,
        .setattr                = xfs_vn_setattr,
        .setxattr               = generic_setxattr,
@@ -1098,6 +1091,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
        .mknod                  = xfs_vn_mknod,
        .rename                 = xfs_vn_rename,
        .get_acl                = xfs_get_acl,
+       .set_acl                = xfs_set_acl,
        .getattr                = xfs_vn_getattr,
        .setattr                = xfs_vn_setattr,
        .setxattr               = generic_setxattr,
@@ -1110,8 +1104,7 @@ static const struct inode_operations xfs_dir_ci_inode_operations = {
 static const struct inode_operations xfs_symlink_inode_operations = {
        .readlink               = generic_readlink,
        .follow_link            = xfs_vn_follow_link,
-       .put_link               = xfs_vn_put_link,
-       .get_acl                = xfs_get_acl,
+       .put_link               = kfree_put_link,
        .getattr                = xfs_vn_getattr,
        .setattr                = xfs_vn_setattr,
        .setxattr               = generic_setxattr,
index d2c5057b5cc4b4b701d05478e045cbf02a3ed408..1c34e4335920021d5829c5507be2f2c6c6bf60e1 100644 (file)
@@ -30,7 +30,7 @@ extern void xfs_setup_inode(struct xfs_inode *);
 /*
  * Internal setattr interfaces.
  */
-#define XFS_ATTR_NOACL         0x01    /* Don't call xfs_acl_chmod */
+#define XFS_ATTR_NOACL         0x01    /* Don't call posix_acl_chmod */
 
 extern int xfs_setattr_nonsize(struct xfs_inode *ip, struct iattr *vap,
                               int flags);
index 9d479073ba415d6b482fbecbf160b6b99e4e859c..78ed92a46fdd3323c9bada9a35257f839285c630 100644 (file)
@@ -102,8 +102,8 @@ const struct xattr_handler *xfs_xattr_handlers[] = {
        &xfs_xattr_trusted_handler,
        &xfs_xattr_security_handler,
 #ifdef CONFIG_XFS_POSIX_ACL
-       &xfs_xattr_acl_access_handler,
-       &xfs_xattr_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
        NULL
 };
diff --git a/include/linux/cramfs_fs_sb.h b/include/linux/cramfs_fs_sb.h
deleted file mode 100644 (file)
index 8390693..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _CRAMFS_FS_SB
-#define _CRAMFS_FS_SB
-
-/*
- * cramfs super-block data in memory
- */
-struct cramfs_sb_info {
-                       unsigned long magic;
-                       unsigned long size;
-                       unsigned long blocks;
-                       unsigned long files;
-                       unsigned long flags;
-};
-
-static inline struct cramfs_sb_info *CRAMFS_SB(struct super_block *sb)
-{
-       return sb->s_fs_info;
-}
-
-#endif
index 085197bd88120e945235e3d843360ce99364a274..70e8e21c0a303a3db8b7a59ff3b6f511cf225c46 100644 (file)
@@ -59,29 +59,36 @@ struct files_struct {
        struct file __rcu * fd_array[NR_OPEN_DEFAULT];
 };
 
-#define rcu_dereference_check_fdtable(files, fdtfd) \
-       (rcu_dereference_check((fdtfd), \
-                              lockdep_is_held(&(files)->file_lock) || \
-                              atomic_read(&(files)->count) == 1 || \
-                              rcu_my_thread_group_empty()))
-
-#define files_fdtable(files) \
-               (rcu_dereference_check_fdtable((files), (files)->fdt))
-
 struct file_operations;
 struct vfsmount;
 struct dentry;
 
 extern void __init files_defer_init(void);
 
-static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd)
+#define rcu_dereference_check_fdtable(files, fdtfd) \
+       rcu_dereference_check((fdtfd), lockdep_is_held(&(files)->file_lock))
+
+#define files_fdtable(files) \
+       rcu_dereference_check_fdtable((files), (files)->fdt)
+
+/*
+ * The caller must ensure that fd table isn't shared or hold rcu or file lock
+ */
+static inline struct file *__fcheck_files(struct files_struct *files, unsigned int fd)
 {
-       struct file * file = NULL;
-       struct fdtable *fdt = files_fdtable(files);
+       struct fdtable *fdt = rcu_dereference_raw(files->fdt);
 
        if (fd < fdt->max_fds)
-               file = rcu_dereference_check_fdtable(files, fdt->fd[fd]);
-       return file;
+               return rcu_dereference_raw(fdt->fd[fd]);
+       return NULL;
+}
+
+static inline struct file *fcheck_files(struct files_struct *files, unsigned int fd)
+{
+       rcu_lockdep_assert(rcu_read_lock_held() ||
+                          lockdep_is_held(&files->file_lock),
+                          "suspicious rcu_dereference_check() usage");
+       return __fcheck_files(files, fd);
 }
 
 /*
index 121f11f001c06f1cdcdeb6533234d76626a2915b..09f553c59813a2b2f88991ab0ab854880e07e574 100644 (file)
@@ -1580,6 +1580,7 @@ struct inode_operations {
                           struct file *, unsigned open_flag,
                           umode_t create_mode, int *opened);
        int (*tmpfile) (struct inode *, struct dentry *, umode_t);
+       int (*set_acl)(struct inode *, struct posix_acl *, int);
 } ____cacheline_aligned;
 
 ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
diff --git a/include/linux/generic_acl.h b/include/linux/generic_acl.h
deleted file mode 100644 (file)
index b6d6575..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LINUX_GENERIC_ACL_H
-#define LINUX_GENERIC_ACL_H
-
-#include <linux/xattr.h>
-
-struct inode;
-
-extern const struct xattr_handler generic_acl_access_handler;
-extern const struct xattr_handler generic_acl_default_handler;
-
-int generic_acl_init(struct inode *, struct inode *);
-int generic_acl_chmod(struct inode *);
-
-#endif /* LINUX_GENERIC_ACL_H */
index 48997374eaf04eac0d52b8bf8d60c61c35944df3..2b00625952a7c618c34c30bc7f145a231194ed89 100644 (file)
@@ -154,10 +154,6 @@ struct nfs_inode {
        struct rb_root          access_cache;
        struct list_head        access_cache_entry_lru;
        struct list_head        access_cache_inode_lru;
-#ifdef CONFIG_NFS_V3_ACL
-       struct posix_acl        *acl_access;
-       struct posix_acl        *acl_default;
-#endif
 
        /*
         * This is the cookie verifier used for NFSv3 readdir
@@ -564,23 +560,17 @@ extern int  nfs_readpage_async(struct nfs_open_context *, struct inode *,
  * linux/fs/nfs3proc.c
  */
 #ifdef CONFIG_NFS_V3_ACL
-extern struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type);
-extern int nfs3_proc_setacl(struct inode *inode, int type,
-                           struct posix_acl *acl);
-extern int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode,
-               umode_t mode);
-extern void nfs3_forget_cached_acls(struct inode *inode);
+extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type);
+extern int nfs3_set_acl(struct inode *inode, struct posix_acl *acl, int type);
+extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
+               struct posix_acl *dfacl);
+extern const struct xattr_handler *nfs3_xattr_handlers[];
 #else
-static inline int nfs3_proc_set_default_acl(struct inode *dir,
-                                           struct inode *inode,
-                                           umode_t mode)
+static inline int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
+               struct posix_acl *dfacl)
 {
        return 0;
 }
-
-static inline void nfs3_forget_cached_acls(struct inode *inode)
-{
-}
 #endif /* CONFIG_NFS_V3_ACL */
 
 /*
index 5dc635f8d79e09a4a6976c3e536cbfb506b16689..520681b6820817b6f08cb304503bf75b8f8f564f 100644 (file)
@@ -44,11 +44,12 @@ enum utf16_endian {
 };
 
 /* nls_base.c */
-extern int register_nls(struct nls_table *);
+extern int __register_nls(struct nls_table *, struct module *);
 extern int unregister_nls(struct nls_table *);
 extern struct nls_table *load_nls(char *);
 extern void unload_nls(struct nls_table *);
 extern struct nls_table *load_nls_default(void);
+#define register_nls(nls) __register_nls((nls), THIS_MODULE)
 
 extern int utf8_to_utf32(const u8 *s, int len, unicode_t *pu);
 extern int utf32_to_utf8(unicode_t u, u8 *s, int maxlen);
index 833099bf8090a24f5be28f6b074c918d5d677119..3e96a6a7610338ff8ddd825a21ddc9bc5fe52e8b 100644 (file)
@@ -85,12 +85,20 @@ extern int posix_acl_valid(const struct posix_acl *);
 extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
 extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
 extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
-extern int posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
-extern int posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
+extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
+extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
 
 extern struct posix_acl *get_posix_acl(struct inode *, int);
 extern int set_posix_acl(struct inode *, int, struct posix_acl *);
 
+#ifdef CONFIG_FS_POSIX_ACL
+extern int posix_acl_chmod(struct inode *, umode_t);
+extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
+               struct posix_acl **);
+
+extern int simple_set_acl(struct inode *, struct posix_acl *, int);
+extern int simple_acl_create(struct inode *, struct inode *);
+
 struct posix_acl **acl_by_type(struct inode *inode, int type);
 struct posix_acl *get_cached_acl(struct inode *inode, int type);
 struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
@@ -100,10 +108,37 @@ void forget_all_cached_acls(struct inode *inode);
 
 static inline void cache_no_acl(struct inode *inode)
 {
-#ifdef CONFIG_FS_POSIX_ACL
        inode->i_acl = NULL;
        inode->i_default_acl = NULL;
-#endif
 }
+#else
+static inline int posix_acl_chmod(struct inode *inode, umode_t mode)
+{
+       return 0;
+}
+
+#define simple_set_acl         NULL
+
+static inline int simple_acl_create(struct inode *dir, struct inode *inode)
+{
+       return 0;
+}
+static inline void cache_no_acl(struct inode *inode)
+{
+}
+
+static inline int posix_acl_create(struct inode *inode, umode_t *mode,
+               struct posix_acl **default_acl, struct posix_acl **acl)
+{
+       *default_acl = *acl = NULL;
+       return 0;
+}
+
+static inline void forget_all_cached_acls(struct inode *inode)
+{
+}
+#endif /* CONFIG_FS_POSIX_ACL */
+
+struct posix_acl *get_acl(struct inode *inode, int type);
 
 #endif  /* __LINUX_POSIX_ACL_H */
index ad93ad0f1db0b0afe072d587a6fd1507f2e35d84..6f14ee2958220b03afcb8c41a8fc2cdcad9ea940 100644 (file)
@@ -69,4 +69,7 @@ struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
 int posix_acl_to_xattr(struct user_namespace *user_ns,
                       const struct posix_acl *acl, void *buffer, size_t size);
 
+extern const struct xattr_handler posix_acl_access_xattr_handler;
+extern const struct xattr_handler posix_acl_default_xattr_handler;
+
 #endif /* _POSIX_ACL_XATTR_H */
index 3e355c688618e66391d535de3e183bf9c9ec8cba..72bf3a01a4ee67ac8908212c3de3897d383a2161 100644 (file)
@@ -449,8 +449,6 @@ static inline int rcu_read_lock_sched_held(void)
 
 #ifdef CONFIG_PROVE_RCU
 
-int rcu_my_thread_group_empty(void);
-
 /**
  * rcu_lockdep_assert - emit lockdep splat if specified condition not met
  * @c: condition to check
index 7c098ac9068a582af317596908390ad74011040e..a8227022e3a02210afaab0cc628729f80ca07af8 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/minix_fs.h>
 #include <linux/ext2_fs.h>
 #include <linux/romfs_fs.h>
-#include <linux/cramfs_fs.h>
+#include <uapi/linux/cramfs_fs.h>
 #include <linux/initrd.h>
 #include <linux/string.h>
 #include <linux/slab.h>
index 802365ccd591826a60e08009a3927c9bed8c69bf..c54609faf233ba21a49835d32a9132eb56853f14 100644 (file)
@@ -200,17 +200,6 @@ void wait_rcu_gp(call_rcu_func_t crf)
 }
 EXPORT_SYMBOL_GPL(wait_rcu_gp);
 
-#ifdef CONFIG_PROVE_RCU
-/*
- * wrapper function to avoid #include problems.
- */
-int rcu_my_thread_group_empty(void)
-{
-       return thread_group_empty(current);
-}
-EXPORT_SYMBOL_GPL(rcu_my_thread_group_empty);
-#endif /* #ifdef CONFIG_PROVE_RCU */
-
 #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD
 static inline void debug_init_rcu_head(struct rcu_head *head)
 {
index 7a7f3e0db7384515b6e266029ef930e5c775ec0d..d56d3c145b9f26d3210ec8ad17430be6c46af2a9 100644 (file)
@@ -1428,30 +1428,28 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
                if (!count)
                        goto out; /* skip atime */
                size = i_size_read(inode);
-               if (pos < size) {
-                       retval = filemap_write_and_wait_range(mapping, pos,
+               retval = filemap_write_and_wait_range(mapping, pos,
                                        pos + iov_length(iov, nr_segs) - 1);
-                       if (!retval) {
-                               retval = mapping->a_ops->direct_IO(READ, iocb,
-                                                       iov, pos, nr_segs);
-                       }
-                       if (retval > 0) {
-                               *ppos = pos + retval;
-                               count -= retval;
-                       }
+               if (!retval) {
+                       retval = mapping->a_ops->direct_IO(READ, iocb,
+                                                          iov, pos, nr_segs);
+               }
+               if (retval > 0) {
+                       *ppos = pos + retval;
+                       count -= retval;
+               }
 
-                       /*
-                        * Btrfs can have a short DIO read if we encounter
-                        * compressed extents, so if there was an error, or if
-                        * we've already read everything we wanted to, or if
-                        * there was a short read because we hit EOF, go ahead
-                        * and return.  Otherwise fallthrough to buffered io for
-                        * the rest of the read.
-                        */
-                       if (retval < 0 || !count || *ppos >= size) {
-                               file_accessed(filp);
-                               goto out;
-                       }
+               /*
+                * Btrfs can have a short DIO read if we encounter
+                * compressed extents, so if there was an error, or if
+                * we've already read everything we wanted to, or if
+                * there was a short read because we hit EOF, go ahead
+                * and return.  Otherwise fallthrough to buffered io for
+                * the rest of the read.
+                */
+               if (retval < 0 || !count || *ppos >= size) {
+                       file_accessed(filp);
+                       goto out;
                }
        }
 
index 8156f95ec0cfc638d93e8f6175e107384c83d7dd..1f18c9d0d93ea270ab01054b2febbdd6a7eb6f56 100644 (file)
@@ -45,7 +45,7 @@ static struct vfsmount *shm_mnt;
 #include <linux/xattr.h>
 #include <linux/exportfs.h>
 #include <linux/posix_acl.h>
-#include <linux/generic_acl.h>
+#include <linux/posix_acl_xattr.h>
 #include <linux/mman.h>
 #include <linux/string.h>
 #include <linux/slab.h>
@@ -620,10 +620,8 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
        }
 
        setattr_copy(inode, attr);
-#ifdef CONFIG_TMPFS_POSIX_ACL
        if (attr->ia_valid & ATTR_MODE)
-               error = generic_acl_chmod(inode);
-#endif
+               error = posix_acl_chmod(inode, inode->i_mode);
        return error;
 }
 
@@ -1937,22 +1935,14 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
 
        inode = shmem_get_inode(dir->i_sb, dir, mode, dev, VM_NORESERVE);
        if (inode) {
-#ifdef CONFIG_TMPFS_POSIX_ACL
-               error = generic_acl_init(inode, dir);
-               if (error) {
-                       iput(inode);
-                       return error;
-               }
-#endif
+               error = simple_acl_create(dir, inode);
+               if (error)
+                       goto out_iput;
                error = security_inode_init_security(inode, dir,
                                                     &dentry->d_name,
                                                     shmem_initxattrs, NULL);
-               if (error) {
-                       if (error != -EOPNOTSUPP) {
-                               iput(inode);
-                               return error;
-                       }
-               }
+               if (error && error != -EOPNOTSUPP)
+                       goto out_iput;
 
                error = 0;
                dir->i_size += BOGO_DIRENT_SIZE;
@@ -1961,6 +1951,9 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
                dget(dentry); /* Extra count - pin the dentry in core */
        }
        return error;
+out_iput:
+       iput(inode);
+       return error;
 }
 
 static int
@@ -1974,24 +1967,17 @@ shmem_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
                error = security_inode_init_security(inode, dir,
                                                     NULL,
                                                     shmem_initxattrs, NULL);
-               if (error) {
-                       if (error != -EOPNOTSUPP) {
-                               iput(inode);
-                               return error;
-                       }
-               }
-#ifdef CONFIG_TMPFS_POSIX_ACL
-               error = generic_acl_init(inode, dir);
-               if (error) {
-                       iput(inode);
-                       return error;
-               }
-#else
-               error = 0;
-#endif
+               if (error && error != -EOPNOTSUPP)
+                       goto out_iput;
+               error = simple_acl_create(dir, inode);
+               if (error)
+                       goto out_iput;
                d_tmpfile(dentry, inode);
        }
        return error;
+out_iput:
+       iput(inode);
+       return error;
 }
 
 static int shmem_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
@@ -2223,8 +2209,8 @@ static int shmem_initxattrs(struct inode *inode,
 
 static const struct xattr_handler *shmem_xattr_handlers[] = {
 #ifdef CONFIG_TMPFS_POSIX_ACL
-       &generic_acl_access_handler,
-       &generic_acl_default_handler,
+       &posix_acl_access_xattr_handler,
+       &posix_acl_default_xattr_handler,
 #endif
        NULL
 };
@@ -2740,6 +2726,7 @@ static const struct inode_operations shmem_inode_operations = {
        .getxattr       = shmem_getxattr,
        .listxattr      = shmem_listxattr,
        .removexattr    = shmem_removexattr,
+       .set_acl        = simple_set_acl,
 #endif
 };
 
@@ -2764,6 +2751,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
 #endif
 #ifdef CONFIG_TMPFS_POSIX_ACL
        .setattr        = shmem_setattr,
+       .set_acl        = simple_set_acl,
 #endif
 };
 
@@ -2776,6 +2764,7 @@ static const struct inode_operations shmem_special_inode_operations = {
 #endif
 #ifdef CONFIG_TMPFS_POSIX_ACL
        .setattr        = shmem_setattr,
+       .set_acl        = simple_set_acl,
 #endif
 };