From: "Michael Kerrisk" <mtk-manpages@gmx.net>
To: Jens Axboe <axboe@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: splice() and file offsets
Date: Mon, 10 Jul 2006 15:54:27 +0200 [thread overview]
Message-ID: <20060710135427.26270@gmx.net> (raw)
In-Reply-To: <20060710132529.GD5210@suse.de>
Jens,
> > I'm still not clear here. Let me phrase my question another way:
> > why is it that the presence or absence of off_out affects whether
> > or not splice() changes the current file offset for fd_out?
>
> The logic is simple - either you don't give an explicit offset, and the
> current position is used and updated. Or you give an offset, and the
> current position is ignored (not read, not updated).
Yes, I understand what the code is doing, but *why* do
things this way? (To put things another way: why not *always
have splice() update the file offset?) I realise there may be
some good reason for this, and if there is, it will go into the
man page!
> > > It's identical to how sendfile() works.
> >
> > But it isn't: sendfile() never changes the file offset
> > of its 'in_fd'.
>
> Ehm, yes it does. Would you expect the app to do an appropriate lseek()
> on every sendfile() call?
No! It does not! See the sendfile.2 man page: "sendfile()
does not modify the current file offset of in_fd."
(You had me worried -- I just now went and *tested*
the operation of sendfile().) The app does not need to
do an lseek() call because the 'offset' argument is *always*
updated with the new "virtual" offset. This is part of why I
am disturbed/confused: sendfile() always updates its 'offset'
argument and *never* changes the file offset; splice() only
does that if its 'offset' argument is non-NULL.
Cheers,
Michael
--
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7
Want to help with man page maintenance?
Grab the latest tarball at
ftp://ftp.win.tue.nl/pub/linux-local/manpages/,
read the HOWTOHELP file and grep the source
files for 'FIXME'.
next prev parent reply other threads:[~2006-07-10 13:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-10 12:11 splice() and file offsets Michael Kerrisk
2006-07-10 12:51 ` Jens Axboe
2006-07-10 13:07 ` Michael Kerrisk
2006-07-10 13:25 ` Jens Axboe
2006-07-10 13:54 ` Michael Kerrisk [this message]
2006-07-10 14:22 ` Jens Axboe
2006-07-10 15:48 ` Michael Kerrisk
2006-07-10 16:51 ` Jens Axboe
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=20060710135427.26270@gmx.net \
--to=mtk-manpages@gmx.net \
--cc=axboe@suse.de \
--cc=linux-kernel@vger.kernel.org \
/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