[PATCH] ROMFS 0 byte file read error

From: Chris Fester
Date: Wed Jul 30 2008 - 12:11:11 EST


I've verified that the git tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

also has the zero byte file problem for romfs. This patch
fixes the problem. Avoids calling romfs_copyfrom when in
the 0 size case.

Thanks!
Chris Fester

Signed-off-by: Chris Fester <cfester@xxxxxxx>
---

diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 8e51a2a..5d24113 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -430,10 +430,10 @@ romfs_readpage(struct file *file, struct page * page)

/* 32 bit warning -- but not for us :) */
offset = page_offset(page);
- if (offset < i_size_read(inode)) {
+ if (offset <= i_size_read(inode)) {
avail = inode->i_size-offset;
readlen = min_t(unsigned long, avail, PAGE_SIZE);
- if (romfs_copyfrom(inode, buf, ROMFS_I(inode)->i_dataoffset+offset, readlen) == readlen) {
+ if (!readlen || romfs_copyfrom(inode, buf, ROMFS_I(inode)->i_dataoffset+offset, readlen) == readlen) {
if (readlen < PAGE_SIZE) {
memset(buf + readlen,0,PAGE_SIZE-readlen);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/