[syslinux:pathbased] ext2: a zero block number is actually legit
syslinux-bot for H. Peter Anvin
hpa at zytor.com
Tue Feb 16 14:12:03 PST 2010
Commit-ID: cb2bde2a1f8b71fe043b57fc60579a358b4b9a13
Gitweb: http://syslinux.zytor.com/commit/cb2bde2a1f8b71fe043b57fc60579a358b4b9a13
Author: H. Peter Anvin <hpa at zytor.com>
AuthorDate: Tue, 16 Feb 2010 13:57:30 -0800
Committer: H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 16 Feb 2010 13:57:30 -0800
ext2: a zero block number is actually legit
It may not happen in normal operation, but a zero block value is legit
and means an all-zero block. For anything which uses the cache, we
have dealt with that by always keeping a zero block in the cache.
Signed-off-by: H. Peter Anvin <hpa at zytor.com>
---
core/fs/ext2/ext2.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index bc75824..5254340 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -184,8 +184,7 @@ ext2_find_entry(struct fs_info *fs, struct inode *inode, const char *dname)
size_t dname_len = strlen(dname);
while (i < inode->size) {
- if (!(block = ext2_bmap(inode, index++)))
- return NULL;
+ block = ext2_bmap(inode, index++);
data = get_cache(fs->fs_dev, block);
offset = 0;
maxoffset = min(BLOCK_SIZE(fs), i-inode->size);
@@ -323,8 +322,10 @@ static struct dirent * ext2_readdir(struct file *file)
block_t index = file->offset >> fs->block_shift;
block_t block;
- if (!(block = ext2_bmap(inode, index)))
- return NULL;
+ if (file->offset >= inode->size)
+ return NULL; /* End of file */
+
+ block = ext2_bmap(inode, index);
data = get_cache(fs->fs_dev, block);
de = (const struct ext2_dir_entry *)
More information about the Syslinux-commits
mailing list