Btrfs: Fix compile on 2.6.22 kernel
authorYan <yanzheng@21cn.com>
Thu, 17 Jan 2008 16:59:51 +0000 (11:59 -0500)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:03:59 +0000 (11:03 -0400)
This patch fixes compile error on kernel-2.6.22

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/acl.c
fs/btrfs/inode.c

index b4f85ebe1bd6fa154746bc6cf1277b3fa1e3c811..27bb841fafebbc2364405fdc25af8b2e8dc97d46 100644 (file)
 #include <linux/posix_acl_xattr.h>
 #include "ctree.h"
 #include "xattr.h"
+#ifndef is_owner_or_cap
+#define is_owner_or_cap(inode) \
+       ((current->fsuid == (inode)->i_uid) || capable(CAP_FOWNER))
+#endif
+
 static int btrfs_xattr_set_acl(struct inode *inode, int type,
                               const void *value, size_t size)
 {
index c1ac0bcbb462b59fde84551a0ba13046d8be4035..51fc06dc4a5df65ed4ef7f7f7e838f5862cc89a9 100644 (file)
@@ -2322,15 +2322,16 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen)
                ret = -ENOMEM;
                goto fail_unlock;
        }
-       pending_snapshot->name = kstrndup(name, namelen, GFP_NOFS);
+       pending_snapshot->name = kmalloc(namelen + 1, GFP_NOFS);
        if (!pending_snapshot->name) {
                ret = -ENOMEM;
                kfree(pending_snapshot);
                goto fail_unlock;
        }
+       memcpy(pending_snapshot->name, name, namelen);
+       pending_snapshot->name[namelen] = '\0';
        trans = btrfs_start_transaction(root, 1);
        BUG_ON(!trans);
-
        pending_snapshot->root = root;
        list_add(&pending_snapshot->list,
                 &trans->transaction->pending_snapshots);