From: Sunil Mushran <sunil.mushran@oracle.com>
To: josef@redhat.com, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-ext4@vger.kernel.org, viro@ZenIV.linux.org.uk, o
Subject: [PATCH] fs: Fix default SEEK_DATA and SEEK_HOLE implementation
Date: Wed, 18 May 2011 19:44:43 -0700 [thread overview]
Message-ID: <1305773084-19296-2-git-send-email-sunil.mushran@oracle.com> (raw)
In-Reply-To: <1305773084-19296-1-git-send-email-sunil.mushran@oracle.com>
In the default SEEK_DATA implementation, as the entire file is treated as data,
all supplied offsets less than the size of the file are valid.
For empty files, SEEK_DATA and SEEK_HOLE returns -ENXIO irrespective of the
input offset.
Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>
---
fs/read_write.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index af9cc51..4b991e9 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -66,11 +66,10 @@ generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
break;
case SEEK_DATA:
/*
- * In the generic case the entire file is data, so data only
- * starts at position 0 provided the file has an i_size,
- * otherwise it's an empty file and will always be ENXIO.
+ * In the generic case the entire file is data. So all offsets
+ * less than the file size are valid.
*/
- if (offset != 0 || inode->i_size == 0)
+ if (inode->i_size == 0 || offset >= inode->i_size)
return -ENXIO;
break;
case SEEK_HOLE:
@@ -78,7 +77,7 @@ generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
* There is a virtual hole at the end of the file, so as long as
* offset isn't i_size or larger, return i_size.
*/
- if (offset >= inode->i_size)
+ if (inode->i_size == 0 || offset >= inode->i_size)
return -ENXIO;
offset = inode->i_size;
break;
--
1.7.4.1
next prev parent reply other threads:[~2011-05-19 2:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-19 2:44 SEEK_DATA/HOLE on ocfs2 - v2 Sunil Mushran
2011-05-19 2:44 ` Sunil Mushran [this message]
2011-05-19 2:44 ` [PATCH] ocfs2: Implement llseek() Sunil Mushran
2011-05-19 9:13 ` Tristan Ye
2011-05-19 17:45 ` [Ocfs2-devel] " Sunil Mushran
2011-05-19 11:05 ` Christoph Hellwig
2011-05-19 17:29 ` Sunil Mushran
2011-05-19 11:04 ` [Ocfs2-devel] SEEK_DATA/HOLE on ocfs2 - v2 Christoph Hellwig
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=1305773084-19296-2-git-send-email-sunil.mushran@oracle.com \
--to=sunil.mushran@oracle.com \
--cc=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).