diff --git a/HISTORY b/HISTORY index c960995b..13c12dbd 100644 --- a/HISTORY +++ b/HISTORY @@ -26,6 +26,8 @@ SnapRAID HISTORY * Removed the '-H,--filter-nohidden' option. It doesn't make sense to have it as command line option. You must use the 'nohidden' option in the configuration file. + * When opening files in read-only mode, also specify the noatime flag, + to avoid to update the file access time. 1.13 2012/11 ============ diff --git a/TODO b/TODO index ba5dd499..f18449dd 100644 --- a/TODO +++ b/TODO @@ -32,6 +32,14 @@ is too complex. - v2.x +* Checked the include/exclude rules for FILE to include also directories. +This is needed to allow to exclude files, before even calling stat() on them +to know if they are file or directory. +There are some cases where this is needed, like for the ".gvfs" mounted fuse directory by +gnome that cannot have stat() called *EVEN* by root. +This is totally wrong, because the stat() manpage explicitely tells that no permissions are +needed to call stat(). + * Remove the old MD5 support. * A new 'init' command to differentiate the first 'sync' operation. @@ -104,11 +112,6 @@ This is a list of rejected TODO items. data doesn't overlap, do not recompute it. - It's going to work only in RAID5 mode and only in special cases. -* Uses the O_NOATIME flag if run as 'root'. -- A better solution is to mount the disk with the "noatime" mount option. -Note also that at mount time you can also use the "nodiratime", and this is -the only way to specify it. - * Implements a multithread sync command. - At now it's questionable if it will result in a performance improvment. The murmur3 hash, and the RAID5/6 computations are so fast that even a single diff --git a/handle.c b/handle.c index 731b58b1..aaa5d07f 100644 --- a/handle.c +++ b/handle.c @@ -87,7 +87,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file) /* if failed for missing permission */ if (handle->f == -1 && errno == EACCES) { /* retry without requesting write permission */ - handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW); + handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW | O_NOATIME); } if (handle->f == -1) { @@ -161,7 +161,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file) /* opening in sequential mode in Windows */ /* do not follow links to ensure to open the real file */ - handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW); + handle->f = open(handle->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOFOLLOW | O_NOATIME); if (handle->f == -1) { /* invalidate for error */ diff --git a/parity.c b/parity.c index c7daa43b..a0e3e89f 100644 --- a/parity.c +++ b/parity.c @@ -222,7 +222,7 @@ int parity_open(struct snapraid_parity* parity, const char* path) pathcpy(parity->path, sizeof(parity->path), path); /* opening in sequential mode in Windows */ - parity->f = open(parity->path, O_RDONLY | O_BINARY | O_SEQUENTIAL); + parity->f = open(parity->path, O_RDONLY | O_BINARY | O_SEQUENTIAL | O_NOATIME); if (parity->f == -1) { fprintf(stderr, "Error opening parity file '%s'. %s.\n", parity->path, strerror(errno)); return -1; diff --git a/portable.h b/portable.h index e4e5805f..31927634 100644 --- a/portable.h +++ b/portable.h @@ -137,6 +137,14 @@ #define STAT_NSEC(st) -1 #endif +/** + * Defines O_NOATIME if absent. + * O_NOATIME is used to open files in RDONLY mode avoding to update their access time. + */ +#ifndef O_NOATIME +#define O_NOATIME 0 +#endif + /** * Check if the specified file is hidden. */ diff --git a/scan.c b/scan.c index 5693cc63..1a5a01ac 100644 --- a/scan.c +++ b/scan.c @@ -454,7 +454,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i const char* name; struct dirent* dd; - /* clear errno to detect errneous conditions */ + /* clear errno to detect erroneous conditions */ errno = 0; dd = readdir(d); if (dd == 0 && errno != 0) {