From: Aaron Carroll Date: Mon, 26 Nov 2007 08:08:53 +0000 (+0100) Subject: Fix failure in opening files with O_NOATIME X-Git-Tag: fio-1.17.3~31 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=056f3459149a7670257350d84b49858718e4a0e6;hp=046ee3021f5a8a951c41f6604341d26e74183df7 Fix failure in opening files with O_NOATIME If we try to open a file with O_NOATIME and it fails, turn off O_NOATIME and try again. This occurs if the user does not own the file and is unprivileged. Signed-off-by: Jens Axboe --- diff --git a/filesetup.c b/filesetup.c index 5134fdbb..6c241516 100644 --- a/filesetup.c +++ b/filesetup.c @@ -234,6 +234,7 @@ int generic_open_file(struct thread_data *td, struct fio_file *f) if (f->filetype != FIO_TYPE_FILE) flags |= O_NOATIME; +open_again: if (td_write(td)) { assert(!read_only); @@ -262,6 +263,11 @@ int generic_open_file(struct thread_data *td, struct fio_file *f) char buf[FIO_VERROR_SIZE]; int __e = errno; + if (errno == EPERM && (flags & O_NOATIME)) { + flags &= ~O_NOATIME; + goto open_again; + } + snprintf(buf, sizeof(buf) - 1, "open(%s)", f->file_name); td_verror(td, __e, buf);