aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2009-01-21 10:49:16 -0500
committerChris Mason <chris.mason@oracle.com>2009-01-21 10:49:16 -0500
commit070604040b86511cc2df0f25f98e26c5529bd928 (patch)
treebb51306dee575e10d758117e9b2e951073fa154b /fs/btrfs
parenteb1eb04fdfbd9e1c9c40d072ab1b82fe593eeb0f (diff)
Btrfs: cleanup xattr code
Andrew's review of the xattr code revealed some minor issues that this patch addresses. Just an error return fix, got rid of a useless statement and commented one of the trickier parts of __btrfs_getxattr. Signed-off-by: Josef Bacik <jbacik@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/xattr.c14
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];