Skip to contentSkip to conversation

ROMFS error reading 0 byte files

PATCH Chris Fester 1 participant 1 message Jul 25, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

I've been poking around at a problem I've been having with the latest kernels and romfs. The symptom is getting an Input/output error when reading a zero length file:

# find . -size 0
./usr/lib/gconv/gconv-modules.cache
# cat ./usr/lib/gconv/gconv-modules.cache 
cat: ./usr/lib/gconv/gconv-modules.cache: Input/output error

The problem seems to have occurred somewhere between 2.6.22 and 2.6.23. Not much changed in the romfs code then, but the mm/filemap.c had a bit of changes. Personally I saw this problem with Debian Lenny kernels 2.6.24 and 2.6.25. Looking at the kernel.org source I suspect the problem is still in 2.6.26.

I'm not a filesystem or mm expert, but I would like to get a good solution going... if it means I get more familiar with mm and filesystems then so be it. :)

Matt Waddel proposed this patch back in November of 2007 on the uclinux-dev mail list:

fs/romfs/inode.c +0 -0
index dae7945..ed04d73 100644
@@ -430,7 +430,7 @@ 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) {

I mailed Matt recently and he's been using this patch for a while now with no failures.

I'm not sure if this patch is the best solution. I was looking at cramfs's inode.c:cramfs_readpage, and it looks like it's structured a little more optimally in the 0 length case.

For reference to the original discussion, see the uclinux-dev mail list:
http://mailman.uclinux.org/pipermail/uclinux-dev/2007-December/044836.html

Since the maintainer for romfs seems to have moved on, could someone with vfs knowledge please direct me on what I should do next? The company I work for uses romfs extensively in their products. So far they've been lucky because the newest kernel being used is 2.6.18. But there's rumblings to upgrade to a newer kernel, and I'd like to be prepared with a good solid fix in mainline rather than patching.

Thanks in advance for any help!
Chris Fester