summaryrefslogtreecommitdiff
path: root/e2fsck/pass2.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2014-07-26 14:34:56 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-07-26 14:34:56 -0400
commit97c607b1a25e1f4e83bf246c76b679d91470f5dc (patch)
treeb542ac7ef606e7e60e2d2133755956808db9c774 /e2fsck/pass2.c
parenta30a4e93f3fd51d81687de82ab96e57a3694d71c (diff)
downloade2fsprogs-97c607b1a25e1f4e83bf246c76b679d91470f5dc.tar.gz
libext2fs: provide a function to set inode size
Provide an API to set i_size in an inode and take care of all required feature flag modifications. Refactor the code to use this new function. [ Moved the function to lib/ext2fs/blk_num.c, which is the rest of these sorts of functions live, and renamed it to be ext2fs_inode_size_set() instead of ext2fs_inode_set_size() to be consistent with the other functions in in blk_num.c -- tytso ] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck/pass2.c')
-rw-r--r--e2fsck/pass2.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 517adaa9..2f57af61 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -1466,8 +1466,15 @@ static int allocate_dir_block(e2fsck_t ctx,
*/
e2fsck_read_inode(ctx, db->ino, &inode, "allocate_dir_block");
ext2fs_iblk_add_blocks(fs, &inode, 1);
- if (inode.i_size < (db->blockcnt+1) * fs->blocksize)
- inode.i_size = (db->blockcnt+1) * fs->blocksize;
+ if (EXT2_I_SIZE(&inode) < (db->blockcnt+1) * fs->blocksize) {
+ pctx->errcode = ext2fs_inode_size_set(fs, &inode,
+ (db->blockcnt+1) * fs->blocksize);
+ if (pctx->errcode) {
+ pctx->str = "ext2fs_inode_size_set";
+ fix_problem(ctx, PR_2_ALLOC_DIRBOCK, pctx);
+ return 1;
+ }
+ }
e2fsck_write_inode(ctx, db->ino, &inode, "allocate_dir_block");
/*