fio: ioengine flag cleanup
[fio.git] / engines / ftruncate.c
CommitLineData
a467027e
DM
1/*
2 * ftruncate: ioengine for git://git.kernel.dk/fio.git
3 *
4 * IO engine that does regular truncates to simulate data transfer
5 * as fio ioengine.
6 * DDIR_WRITE does ftruncate
7 *
8 */
a467027e 9#include <errno.h>
3d2d14bc 10#include <unistd.h>
a467027e
DM
11
12#include "../fio.h"
a467027e 13
2e4ef4fb
JA
14static enum fio_q_status fio_ftruncate_queue(struct thread_data *td,
15 struct io_u *io_u)
a467027e
DM
16{
17 struct fio_file *f = io_u->file;
18 int ret;
2e4ef4fb 19
a467027e
DM
20 fio_ro_check(td, io_u);
21
22 if (io_u->ddir != DDIR_WRITE) {
23 io_u->error = EINVAL;
24 return FIO_Q_COMPLETED;
25 }
a467027e 26
2e4ef4fb 27 ret = ftruncate(f->fd, io_u->offset);
a467027e
DM
28 if (ret)
29 io_u->error = errno;
30
31 return FIO_Q_COMPLETED;
32}
33
34static struct ioengine_ops ioengine = {
35 .name = "ftruncate",
36 .version = FIO_IOOPS_VERSION,
37 .queue = fio_ftruncate_queue,
38 .open_file = generic_open_file,
39 .close_file = generic_close_file,
40 .get_file_size = generic_get_file_size,
41 .flags = FIO_SYNCIO | FIO_FAKEIO
42};
43
44static void fio_init fio_syncio_register(void)
45{
46 register_ioengine(&ioengine);
47}
48
49static void fio_exit fio_syncio_unregister(void)
50{
51 unregister_ioengine(&ioengine);
52}