Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2
[safe/jmp/linux-2.6] / fs / reiserfs / xattr_security.c
index 4d3c20e..7271a47 100644 (file)
@@ -3,41 +3,43 @@
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/xattr.h>
+#include <linux/slab.h>
 #include <linux/reiserfs_xattr.h>
 #include <linux/security.h>
 #include <asm/uaccess.h>
 
 static int
-security_get(struct inode *inode, const char *name, void *buffer, size_t size)
+security_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
+               int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
                return -EINVAL;
 
-       if (IS_PRIVATE(inode))
+       if (IS_PRIVATE(dentry->d_inode))
                return -EPERM;
 
-       return reiserfs_xattr_get(inode, name, buffer, size);
+       return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
 }
 
 static int
-security_set(struct inode *inode, const char *name, const void *buffer,
-            size_t size, int flags)
+security_set(struct dentry *dentry, const char *name, const void *buffer,
+            size_t size, int flags, int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
                return -EINVAL;
 
-       if (IS_PRIVATE(inode))
+       if (IS_PRIVATE(dentry->d_inode))
                return -EPERM;
 
-       return reiserfs_xattr_set(inode, name, buffer, size, flags);
+       return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
 }
 
-static size_t security_list(struct inode *inode, char *list, size_t list_len,
-                           const char *name, size_t namelen)
+static size_t security_list(struct dentry *dentry, char *list, size_t list_len,
+                           const char *name, size_t namelen, int handler_flags)
 {
        const size_t len = namelen + 1;
 
-       if (IS_PRIVATE(inode))
+       if (IS_PRIVATE(dentry->d_inode))
                return 0;
 
        if (list && len <= list_len) {
@@ -55,8 +57,16 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
                           struct reiserfs_security_handle *sec)
 {
        int blocks = 0;
-       int error = security_inode_init_security(inode, dir, &sec->name,
-                                                &sec->value, &sec->length);
+       int error;
+
+       sec->name = NULL;
+
+       /* Don't add selinux attributes on xattrs - they'll never get used */
+       if (IS_PRIVATE(dir))
+               return 0;
+
+       error = security_inode_init_security(inode, dir, &sec->name,
+                                            &sec->value, &sec->length);
        if (error) {
                if (error == -EOPNOTSUPP)
                        error = 0;
@@ -67,7 +77,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
                return error;
        }
 
-       if (sec->length) {
+       if (sec->length && reiserfs_xattrs_initialized(inode->i_sb)) {
                blocks = reiserfs_xattr_jcreate_nblocks(inode) +
                         reiserfs_xattr_nblocks(inode, sec->length);
                /* We don't want to count the directories twice if we have