diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2013-10-07 09:51:20 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2013-10-07 09:51:20 -0400 |
commit | 4ee4ad80dcceb42b1e5cfd2d4067a38b99b9fa95 (patch) | |
tree | 8bbee855ed4e8714e9b35c55e0473dc918962c0e /lib | |
parent | 5d494038eede1bb538441dedf4207529629154b3 (diff) | |
download | android_external_e2fsprogs-4ee4ad80dcceb42b1e5cfd2d4067a38b99b9fa95.tar.gz android_external_e2fsprogs-4ee4ad80dcceb42b1e5cfd2d4067a38b99b9fa95.tar.bz2 android_external_e2fsprogs-4ee4ad80dcceb42b1e5cfd2d4067a38b99b9fa95.zip |
libext2fs: allow callers to punch a single block
The range of blocks to punch is treated as an inclusive range on both
ends, i.e. if start=1 and end=2, both blocks 1 and 2 are punched out.
Thus, start == end means that the caller wishes to punch a single
block. Remove the check that prevents us from punching a single
block.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ext2fs/ext2fs.h | 4 | ||||
-rw-r--r-- | lib/ext2fs/punch.c | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 326d5c11..e3920d0b 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1308,6 +1308,10 @@ extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, char *mtpt, int mtlen); /* punch.c */ +/* + * NOTE: This function removes from an inode the blocks "start", "end", and + * every block in between. + */ extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, char *block_buf, blk64_t start, diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c index 11c76687..aac19422 100644 --- a/lib/ext2fs/punch.c +++ b/lib/ext2fs/punch.c @@ -315,9 +315,6 @@ extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino, if (start > end) return EINVAL; - if (start == end) - return 0; - /* Read inode structure if necessary */ if (!inode) { retval = ext2fs_read_inode(fs, ino, &inode_buf); @@ -332,7 +329,7 @@ extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino, if (start > ~0U) return 0; - count = ((end - start) < ~0U) ? (end - start) : ~0U; + count = ((end - start + 1) < ~0U) ? (end - start + 1) : ~0U; retval = ext2fs_punch_ind(fs, inode, block_buf, (blk_t) start, count); } |