summaryrefslogtreecommitdiff
path: root/lib/libc/aio/aio_fsync.c
blob: 2b06ba8f13f6ac7f17abcb1016b1d4bcdd654b3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "linux/io_uring.h" // for io_uring_op, IORING_FSYNC_DATASYNC
#include "stddef.h"	    // for NULL

#include <__aio.h> // for __aio_lookup, __aio_request
#include <aio.h>   // for aio_fsync
#include <errno.h> // for EINVAL, errno
#include <fcntl.h> // for O_DSYNC

int aio_fsync(int op, struct aiocb *aiocbp)
{
	int opcode;
	struct aio_request *req;

	req = __aio_lookup(aiocbp);

	if (req == NULL) {
		errno = EINVAL;
		return -1;
	}

	if (op == O_DSYNC) {
		opcode = IORING_OP_FSYNC | IORING_FSYNC_DATASYNC;
	} else {
		opcode = IORING_OP_FSYNC;
	}

	return __aio_request(req, opcode);
}