From: Eric Sandeen <sandeen@sandeen.net>
To: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Cc: Eric Sandeen <sandeen@redhat.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
ext4 development <linux-ext4@vger.kernel.org>,
Andreas Dilger <adilger@dilger.ca>
Subject: Re: [PATCH] vfs: allow custom EOF in generic_file_llseek code
Date: Fri, 27 Apr 2012 18:01:38 -0500 [thread overview]
Message-ID: <4F9B2552.9010803@sandeen.net> (raw)
In-Reply-To: <4F9B2219.6090302@itwm.fraunhofer.de>
On 4/27/12 5:47 PM, Bernd Schubert wrote:
> On 04/27/2012 06:21 PM, Eric Sandeen wrote:
...
>> +generic_file_llseek_size_eof(struct file *file, loff_t offset, int origin,
>> + loff_t maxsize, loff_t eof)
>> {
>> struct inode *inode = file->f_mapping->host;
>>
>> switch (origin) {
>> case SEEK_END:
>> - offset += i_size_read(inode);
>> + offset += eof;
>> break;
>
> Here is the only glitch I can see. As Andreas already said before, it
> might overflow here. Do we need do care about that? As you already said,
> SEEK_END is unlikely to be ever called for directories. But then we also
> cannot keep user space from doing weird calls...
It can happen already today, for a sufficiently large file offset.
# ls -l reallybigfile
-rw-r--r--. 1 root root 9223372036854775807 Apr 27 18:02 reallybigfile
(that's 2^63 - 1)
so overflow protection may be warranted in here, but I think it's a separate problem.
...
>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>> index 8de6755..a6ae7a4 100644
>> --- a/include/linux/fs.h
>> +++ b/include/linux/fs.h
>> @@ -2402,6 +2402,8 @@ extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
>> extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
>> extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
>> int origin, loff_t maxsize);
>> +extern loff_t generic_file_llseek_size_eof(struct file *file, loff_t offset,
>> + int origin, loff_t maxsize, loff_t eof);
>> extern int generic_file_open(struct inode * inode, struct file * filp);
>> extern int nonseekable_open(struct inode * inode, struct file * filp);
>
> Another question, wouldn't it be better to entirely move
> generic_file_llseek_size() and generic_file_llseek() into fs.h to make
> sure it gets inlined?
Hm, perhaps. It wasn't done for generic_file_llseek_size() so I just followed
that example, for now.
-Eric
next prev parent reply other threads:[~2012-04-27 23:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-27 16:21 [PATCH] vfs: allow custom EOF in generic_file_llseek code Eric Sandeen
2012-04-27 16:28 ` Eric Sandeen
2012-04-27 22:47 ` Bernd Schubert
2012-04-27 23:01 ` Eric Sandeen [this message]
2012-04-28 18:33 ` Matthew Wilcox
2012-04-30 14:17 ` Eric Sandeen
2012-04-30 18:11 ` [PATCH 1/3 V2] " Eric Sandeen
2012-04-30 18:14 ` [PATCH 2/3] ext4: use core vfs llseek code for dir seeks Eric Sandeen
2012-04-30 18:16 ` [PATCH 3/3] ext3: pass custom EOF to generic_file_llseek_size() Eric Sandeen
2012-04-30 22:10 ` Jan Kara
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=4F9B2552.9010803@sandeen.net \
--to=sandeen@sandeen.net \
--cc=adilger@dilger.ca \
--cc=bernd.schubert@itwm.fraunhofer.de \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sandeen@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.