From: Darrick J. Wong Date: Sun, 10 Aug 2014 22:31:04 +0000 (-0400) Subject: libext2fs: don't fail inline data operations if there's no EA X-Git-Tag: v1.43-WIP-2015-05-18~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=996999a1a45e1d36ff0e24925ee02fca87ad8283;p=thirdparty%2Fe2fsprogs.git libext2fs: don't fail inline data operations if there's no EA 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 Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 5732ca6f2..fc191f5ba 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -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, diff --git a/lib/ext2fs/inline_data.c b/lib/ext2fs/inline_data.c index b9bda50d8..3ba04ae84 100644 --- a/lib/ext2fs/inline_data.c +++ b/lib/ext2fs/inline_data.c @@ -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); } diff --git a/tests/d_xattr_edits/expect b/tests/d_xattr_edits/expect index 10e30c1f8..44ce5e4e1 100644 --- a/tests/d_xattr_edits/expect +++ b/tests/d_xattr_edits/expect @@ -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: