aio_read2() and aio_write2()

From: Vinícius_dos_Santos_Oliveira <vini.ipsmaker_at_gmail.com>
Date: Fri, 12 Jan 2024 16:41:23 UTC
Can we have some aio_read() function that ignores aio_offset (i.e. the
current file position is used)? I'm trying to port libboost's ASIO
file support to FreeBSD, and I stumbled upon this limitation.

Boost.Asio only exposes file support for proactor systems (Windows
IOCP and Linux io_uring). For Windows and Linux, it's possible to
perform the feature I'm requesting (on Linux you just pass -1 as the
offset to ignore it in io_uring).

Boost.Asio offers two interfaces for file IO on proactor systems:
serial access (current file offset is used) and random access (you
always specify an offset). Right now it's only possible to implement
the random access interface for FreeBSD.

What I'd like to see:

int aio_read2(struct aiocb *iocb, unsigned flags);
int aio_write2(struct aiocb *iocb, unsigned flags);

aio_read(iocb) would be equivalent to aio_read2(iocb, 0) and
aio_write(iocb) would be equivalent to aio_write2(iocb, 0).

Then we would define the following flags:

AIO_USEIOV
AIO_IGNOREOFFSET

aio_readv(iocb) would be equivalent to aio_read2(iocb, AIO_USEIOV) and
aio_writev(iocb) would be equivalent to aio_write2(iocb, AIO_USEIOV).

The flag AIO_IGNOREOFFSET would instruct the call to ignore aio_offset
in aiocb and use the file position (lseek) if applicable. This flag
should not conflict with LIO opcodes so one could OR it into
aio_lio_opcode for usage with lio_listio() as well.

-- 
Vinícius dos Santos Oliveira
https://vinipsmaker.github.io/