io-uring icon indicating copy to clipboard operation
io-uring copied to clipboard

opcode: offset should be u64 instead of libc::off_t

Open stefano-garzarella opened this issue 2 years ago • 3 comments

libc::off_t is i64 while kernel and liburing uses an u64 for the offset field in most of the opcodes.

There are some exceptions like IORING_OP_FILES_UPDATE and IORING_OP_FALLOCATE.

To avoid differences and casting issues (e.g. using try_into() on u64 to cast to i64 can fail) we should follow what liburing does and expose offset as u64.

stefano-garzarella avatar Apr 07 '22 09:04 stefano-garzarella

And POSIX seems to confirm that off_t shall be signed: blkcnt_t and off_t shall be signed integer types. https://pubs.opengroup.org/onlinepubs/009696899/basedefs/sys/types.h.html

stefano-garzarella avatar Apr 07 '22 09:04 stefano-garzarella

Under the impression that the kernel will always convert it to loff_t, but I agree that we should follow liburing's interface.

Anyway this is a break change and we need to keep it until the next version.

quininer avatar Apr 07 '22 09:04 quininer

Under the impression that the kernel will always convert it to loff_t, but I agree that we should follow liburing's interface.

Right, actually then it always gets converted to loff_t which is signed, mah

Anyway this is a break change and we need to keep it until the next version.

It's fine, please let me know when I should rebase the PR.

stefano-garzarella avatar Apr 07 '22 10:04 stefano-garzarella