]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: don't fail inline data operations if there's no EA
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 10 Aug 2014 22:31:04 +0000 (18:31 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 10 Aug 2014 22:31:04 +0000 (18:31 -0400)
Fix up the rest of the inline data code not to complain if there's no
EA, since it's possible that there's no EA because we're in the
process of creating an inline data file.  Also, don't return an error
code when removing a nonexistent EA, because there's no reason to.

Furthermore, if we write less than 60 bytes of inline data, remove the
EA to avoid wasting space.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ext_attr.c
lib/ext2fs/inline_data.c
tests/d_xattr_edits/expect

index 5732ca6f21b12e0695483401d6ef244a2f4f468d..fc191f5ba10ec4a51dbd6c539b7ae0128253faed 100644 (file)
@@ -1020,7 +1020,8 @@ errcode_t ext2fs_xattr_remove(struct ext2_xattr_handle *handle,
                }
        }
 
-       return EXT2_ET_EA_KEY_NOT_FOUND;
+       /* no key found, success! */
+       return 0;
 }
 
 errcode_t ext2fs_xattrs_open(ext2_filsys fs, ext2_ino_t ino,
index b9bda50d8aa6ecc8ef235dd2385352b00e700e69..3ba04ae84ac4c1af08d5d6228f763a7c93f06e77 100644 (file)
@@ -70,7 +70,11 @@ static errcode_t ext2fs_inline_data_ea_get(struct ext2_inline_data *data)
 
        retval = ext2fs_xattr_get(handle, "system.data",
                                  (void **)&data->ea_data, &data->ea_size);
-       if (retval)
+       if (retval == EXT2_ET_EA_KEY_NOT_FOUND) {
+               data->ea_size = 0;
+               data->ea_data = NULL;
+               retval = 0;
+       } else if (retval)
                goto err;
 
 err:
@@ -557,6 +561,9 @@ errcode_t ext2fs_inline_data_set(ext2_filsys fs, ext2_ino_t ino,
        }
 
        if (size <= EXT4_MIN_INLINE_DATA_SIZE) {
+               retval = ext2fs_inline_data_ea_remove(fs, ino);
+               if (retval)
+                       return retval;
                memcpy((void *)inode->i_block, buf, size);
                return ext2fs_write_inode(fs, ino, inode);
        }
index 10e30c1f81a9f8903cd539b970ee8f2980b3ea92..44ce5e4e1e4554915bcc0de27dd0e435a4f9b9cc 100644 (file)
@@ -19,7 +19,6 @@ Exit status is 0
 ea_rm / user.moo
 Exit status is 0
 ea_rm / nosuchea
-ea_rm: Extended attribute key not found while removing extended attribute
 Exit status is 0
 ea_list /
 Extended attributes: