From: Linus Torvalds <torvalds@linux-foundation.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: jens.axboe@oracle.com, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: splice vs O_APPEND
Date: Thu, 9 Oct 2008 09:17:59 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.2.00.0810090908200.3210@nehalem.linux-foundation.org> (raw)
In-Reply-To: <E1Knxzm-0003y2-Jy@pomaz-ex.szeredi.hu>
On Thu, 9 Oct 2008, Miklos Szeredi wrote:
>
> Your patch still ignores O_APPEND, is that what we want? It sounds
> sort of strange. pwrite() for example honors O_APPEND and ignores the
> position, AFAICS.
You're right. We can (and should) just check O_APPEND, because it must be
set if IS_APPEND() is set on the inode.
And yeah, IS_IMMUTABLE is checked at open too. So no worries.
And it turns out that handling O_APPEND is actually pretty easy, so
instead of doing -EINVAL, we can just implement it. Something like this
(untested, of course).
Does this look better?
Linus
---
fs/splice.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/fs/splice.c b/fs/splice.c
index 1bbc6f4..8aca87b 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1120,11 +1120,17 @@ static long do_splice(struct file *in, loff_t __user *off_in,
if (off_in)
return -ESPIPE;
if (off_out) {
+ if (out->f_flags & O_APPEND)
+ return -EINVAL;
if (out->f_op->llseek == no_llseek)
return -EINVAL;
if (copy_from_user(&offset, off_out, sizeof(loff_t)))
return -EFAULT;
off = &offset;
+ } else if (out->f_flags & O_APPEND) {
+ struct inode *inode = out->f_dentry->d_inode;
+ offset = i_size_read(inode);
+ off = &offset;
} else
off = &out->f_pos;
next prev parent reply other threads:[~2008-10-09 16:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-09 15:02 splice vs O_APPEND Miklos Szeredi
2008-10-09 15:37 ` Linus Torvalds
2008-10-09 16:04 ` Miklos Szeredi
2008-10-09 16:17 ` Linus Torvalds [this message]
2008-10-09 16:30 ` Miklos Szeredi
2008-10-09 19:22 ` Linus Torvalds
2008-10-09 19:51 ` Miklos Szeredi
2008-10-09 21:14 ` Linus Torvalds
2008-10-09 21:20 ` Jens Axboe
2008-10-09 21:27 ` Linus Torvalds
2008-10-10 9:46 ` Miklos Szeredi
2008-10-10 10:06 ` Jens Axboe
2008-10-10 15:49 ` [stable] " Greg KH
2008-10-10 16:05 ` Miklos Szeredi
2008-10-10 16:20 ` Greg KH
2008-10-10 10:23 ` Michael Kerrisk
2008-10-09 16:30 ` Andreas Schwab
2008-10-09 16:43 ` Miklos Szeredi
2008-10-09 17:03 ` Andreas Schwab
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=alpine.LFD.2.00.0810090908200.3210@nehalem.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=jens.axboe@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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