News for hackers. Stuff that matters.
Re:Lord of the io_uring: io_uring tutorial, examples and ref... by jra_samba_org on Sunday May 10, 2020 @03:56PM (#23135597)
Well pread/pwrite have the same return values, and historically for disk reads they block or return a device error.

pread only returns a short value on EOF.

Re:Lord of the io_uring: io_uring tutorial, examples and ref... by magicalhippo on Sunday May 10, 2020 @06:07PM (#23136736)
Well, the man page does say that "The readv() system call works just like read(2) except that multiple buffers are filled".

If we go to read(2) we find "It is not an error if [the return value] is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now [...], or because read() was interrupted by a signal."

As an outsider, I'd never rely on this returning the requested number of bytes. If I required N bytes, I'd write use a read loop.

But I do agree that the RWF_NOWAIT flag mentioned in your other comment doesn't help, as it suggests the default is to block.

Re:Lord of the io_uring: io_uring tutorial, examples and ref... by loeg on Sunday May 10, 2020 @06:34PM (#23136959)
Well, or EINTR if your signal handlers are not SA_RESTART.
Re:Lord of the io_uring: io_uring tutorial, examples and ref... by jra_samba on Sunday May 10, 2020 @07:22PM (#23137248)
For EINTR it never returns a short read, as the only way to see EINTR is a return of -1 with errno==EINTR.

We handle signals fine.

Re:Lord of the io_uring: io_uring tutorial, examples and ref... by loeg on Sunday May 10, 2020 @10:19PM (#23138279)
Sure, I was imprecise. A signal can cause a read to return a short result.