[PATCH][BZ #12723] Fix pathconf and fpathconf on Linux

Florian Weimer fweimer@redhat.com
Fri Mar 1 14:08:00 GMT 2013


On 03/01/2013 02:23 PM, Siddhesh Poyarekar wrote:
> The pathconf(_PC_PIPE_BUF) gets the pipe buffer size on Linux using
> F_GETPIPE_SZ on the file, or falls back to returning the default
> PIPE_BUF.  The fallback is incorrect since the default pipe buffer
> size for Linux is not PIPE_BUF.  Linux pipe buffer size is
> configurable using F_SETPIPE_SZ and is initially set to
> PIPE_DEF_BUFFERS * PAGE_SIZE, where PIPE_DEF_BUFFERS is 16.  The
> fallback should return this value.  Patch below does that and also
> includes a test case to verify that pathconf on a fifo and a directory
> are the same.

I think both the patch and the original code are wrong because Linux 
does not guarantee atomic delivery beyond PAGE_SIZE (at least that's how 
I read the code).  So pathconf(_PC_PIPE_BUF) should return PAGE_SIZE 
unconditionally.

F_SETPIPE_SZ increases the amount of data which can ideally be written 
without blocking, but not the size of atomically delivered chunks.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Libc-alpha mailing list