lkml.org 
[lkml]   [2006]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: splice() and file offsets
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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-10 14:53    [from the cache]
©2003-2011 Jasper Spaans