diff options
-rw-r--r-- | fs/btrfs/xattr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 7f332e270894..b4fa5f4b6ad1 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -45,9 +45,12 @@ ssize_t __btrfs_getxattr(struct inode *inode, const char *name, | |||
45 | /* lookup the xattr by name */ | 45 | /* lookup the xattr by name */ |
46 | di = btrfs_lookup_xattr(NULL, root, path, inode->i_ino, name, | 46 | di = btrfs_lookup_xattr(NULL, root, path, inode->i_ino, name, |
47 | strlen(name), 0); | 47 | strlen(name), 0); |
48 | if (!di || IS_ERR(di)) { | 48 | if (!di) { |
49 | ret = -ENODATA; | 49 | ret = -ENODATA; |
50 | goto out; | 50 | goto out; |
51 | } else if (IS_ERR(di)) { | ||
52 | ret = PTR_ERR(di); | ||
53 | goto out; | ||
51 | } | 54 | } |
52 | 55 | ||
53 | leaf = path->nodes[0]; | 56 | leaf = path->nodes[0]; |
@@ -62,6 +65,14 @@ ssize_t __btrfs_getxattr(struct inode *inode, const char *name, | |||
62 | ret = -ERANGE; | 65 | ret = -ERANGE; |
63 | goto out; | 66 | goto out; |
64 | } | 67 | } |
68 | |||
69 | /* | ||
70 | * The way things are packed into the leaf is like this | ||
71 | * |struct btrfs_dir_item|name|data| | ||
72 | * where name is the xattr name, so security.foo, and data is the | ||
73 | * content of the xattr. data_ptr points to the location in memory | ||
74 | * where the data starts in the in memory leaf | ||
75 | */ | ||
65 | data_ptr = (unsigned long)((char *)(di + 1) + | 76 | data_ptr = (unsigned long)((char *)(di + 1) + |
66 | btrfs_dir_name_len(leaf, di)); | 77 | btrfs_dir_name_len(leaf, di)); |
67 | read_extent_buffer(leaf, buffer, data_ptr, | 78 | read_extent_buffer(leaf, buffer, data_ptr, |
@@ -176,7 +187,6 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
176 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 187 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
177 | if (ret < 0) | 188 | if (ret < 0) |
178 | goto err; | 189 | goto err; |
179 | ret = 0; | ||
180 | advance = 0; | 190 | advance = 0; |
181 | while (1) { | 191 | while (1) { |
182 | leaf = path->nodes[0]; | 192 | leaf = path->nodes[0]; |