O_DIRECT on stdin?

Donn Cave donn at u.washington.edu
Mon Nov 7 23:20:07 CET 2005


In article <mailman.237.1131399306.18701.python-list at python.org>,
 jepler at unpythonic.net wrote:

> Here's some text from my open(2) manpage:
>     Transfer  sizes,  and the alignment of user buffer and file offset must 
>     all
>     be multiples of the logical block  size  of the file system.

Does that apply in the example he gave,  < /dev/sda1  ?

It seems to me this would not go through any filesystem anyway.
That might account for the "invalid argument" error, but at any
rate it would be irrelevant.

Plus it doesn't seem to score very high on portability, according
to the Linux man page I'm looking at -- apparently not a POSIX
or any such standard, just borrowed from Irix in recent Linux
versions, and FreeBSD with slightly different behavior.  Don't
see any trace of it in NetBSD, MacOS X.

> It's unlikely that in practice you can get Python's sys.stdin.read() or
> os.read() to reliably use a buffer that fits the alignment restriction.

Though of course os.read() would eliminate one layer of buffering
altogether.  Might be worth a try.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list