Message83639
Hello Eduardo,
> 1) to allocated an aligned buffer it is as simple as allocate 4096 + len
> (buffer) and truncate address to 4k boundary.
Yes, but it is wasteful, especially since the common case is not to use
O_DIRECT. Also, os.read does not allocate a buffer, it allocates a whole
string object, and there's no way in the current Python object allocator
to choose a specific alignment boundary.
> 2) I wrote a floppy imager, and without O_DIRECT, it gives me 8 sectors
> (4k = kernel page) errors whenever one sector is bad.
Well, sorry for that... I guess Python is not well adapted to this (very
particular) use case.
Or you could write a C extension to read() to a properly aligned buffer,
or try to do it with ctypes.
> 3) There is os.O_DIRECT and os.open help page references it
I think the policy is to mirror all possible O_* constants, even if they
are of no use in Python. For example, we also have os.O_DIRECTORY.
Regards
Antoine. |
|
Date |
User |
Action |
Args |
2009-03-15 16:05:28 | pitrou | set | recipients:
+ pitrou, aguiar |
2009-03-15 16:05:26 | pitrou | link | issue5396 messages |
2009-03-15 16:05:26 | pitrou | create | |
|