]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: update i_size in ext2fs_file_write()
authorNiu Yawei <yawei.niu@gmail.com>
Tue, 8 Oct 2013 03:30:10 +0000 (11:30 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 8 Oct 2013 15:36:52 +0000 (11:36 -0400)
ext2fs_file_write() needs to update i_size on successful write,
otherwise, ext2fs_file_read() in same open/close cycle will not
be able to read the just written data.

This fixes a bug which results in the the problem of quotacheck
triggered on 'tune2fs -O quota' failed to write back multiple
users/groups accounting information.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/fileio.c

index e6bc60a4a261fb9c319cabfc5031fef9cb340f56..059bda2dc47ba517b6b2c194677a01a532e68fc4 100644 (file)
@@ -307,6 +307,15 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf,
        }
 
 fail:
+       /* Update inode size */
+       if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos) {
+               errcode_t       rc;
+
+               rc = ext2fs_file_set_size2(file, file->pos);
+               if (retval == 0)
+                       retval = rc;
+       }
+
        if (written)
                *written = count;
        return retval;