[PATCH] Fix failure in opening files with O_NOATIME

From: Aaron Carroll <aaronc_at_gelato.unsw.edu.au>
Date: Fri, 26 Oct 2007 13:44:14 +1000

 - 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.

---
 filesetup.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/filesetup.c b/filesetup.c
index 5134fdb..6c24151 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);
-- 
1.5.1.6
Received on Fri Oct 26 2007 - 05:44:14 CEST

This archive was generated by hypermail 2.2.0 : Fri Oct 26 2007 - 06:00:02 CEST