From ec9d6dd3203e8a4d548c0b6c943033ab5518a423 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 27 May 2008 07:00:48 -0400 Subject: [PATCH] Wire ext2fs_bmap2() to use ext2fs_extent_set_bmap() This commit enables read/write access via the ext2fs_bmap2() interface for extent-based inodes. Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/bmap.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index ceb352ec6..e56a99acb 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -160,13 +160,14 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, struct ext2fs_extent extent; unsigned int offset; - if (bmap_flags & BMAP_SET) { - retval = EXT2_ET_EXTENT_NOT_SUPPORTED; - goto done; - } retval = ext2fs_extent_open(fs, ino, &handle); if (retval) goto done; + if (bmap_flags & BMAP_SET) { + retval = ext2fs_extent_set_bmap(handle, block, + *phys_blk, 0); + goto done; + } retval = ext2fs_extent_goto(handle, block); if (retval) { /* If the extent is not found, return phys_blk = 0 */ @@ -183,6 +184,17 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, if (ret_flags && extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT) *ret_flags |= BMAP_RET_UNINIT; } + if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) { + retval = ext2fs_alloc_block(fs, b, block_buf, &b); + if (retval) + goto done; + retval = ext2fs_extent_set_bmap(handle, block, + (blk64_t) b, 0); + if (retval) + goto done; + blocks_alloc++; + *phys_blk = b; + } retval = 0; goto done; } -- 2.47.2