All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: splice() and file offsets
Date: Mon, 10 Jul 2006 14:51:50 +0200	[thread overview]
Message-ID: <20060710125150.GM25911@suse.de> (raw)
In-Reply-To: <20060710121110.26260@gmx.net>

On Mon, Jul 10 2006, Michael Kerrisk wrote:
> Jens,
> 
> What are the semantics of splice() supposed to be with respect 
> to the current file offsets of 'fd_in' and 'fd_out', and how
> is the presence or absence (NULL) of 'off_in' and 'off_out'
> supposed to affect things.
> 
> Using the program below, here is what I observe for 
> fd_out/off_out:
> 
> 1. If off_out is NULL, then 
>    a) splice() changes the current file offset of fd_out.
> 
> 2. If off_out is not NULL, then splice() 
>    a) does not change the current file offset of fd_out, but 
>    b) treats off_out as a value result parameter, returning 
>       an updated offset of the file.
> 
> It is "2 a)" that surprises me.  But perhaps it's expected 
> behaviour; or I'm doing something dumb in my test program.

Not sure why you find that surprising, that is exactly what is supposed
to happen :-)

If you don't give off_out, we use the current position. For most people,
that's probably what they want. If you are sharing the fd, that doesn't
work though. So you pass off_in/off_out as you please, and the kernel
uses those and passes the updated parameter back out so you don't have
to update it manually.

It's identical to how sendfile() works.

-- 
Jens Axboe


  reply	other threads:[~2006-07-10 12:49 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 [this message]
2006-07-10 13:07   ` Michael Kerrisk
2006-07-10 13:25     ` Jens Axboe
2006-07-10 13:54       ` Michael Kerrisk
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=20060710125150.GM25911@suse.de \
    --to=axboe@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk-manpages@gmx.net \
    /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.