mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Fester <cfester@wms.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Matt Waddel <matt.waddel@freescale.com>,
	Greg Ungerer <gerg@snapgear.com>
Subject: [PATCH] ROMFS 0 byte file read error
Date: Wed, 30 Jul 2008 11:10:52 -0500	[thread overview]
Message-ID: <20080730161051.GA3133@kaboom.dhcp.chi.wms.com> (raw)

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@wms.com>
---

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);
                        }


             reply	other threads:[~2008-07-30 16:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-30 16:10 Chris Fester [this message]
2008-07-30 18:06 ` Linus Torvalds
2008-07-30 21:25   ` Chris Fester

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080730161051.GA3133@kaboom.dhcp.chi.wms.com \
    --to=cfester@wms.com \
    --cc=gerg@snapgear.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.waddel@freescale.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®