Index: gio/glocalfileinfo.c =================================================================== --- gio/glocalfileinfo.c (revision 7754) +++ gio/glocalfileinfo.c (working copy) @@ -57,6 +57,14 @@ #endif /* HAVE_XATTR */ +#ifndef O_NOATIME +#if defined(__linux__) && (defined(__i386__) || defined(__PPC__)) +#define O_NOATIME 01000000 +#else +#define O_NOATIME 0 +#endif +#endif + #include #include @@ -1191,6 +1199,24 @@ #endif /* !G_OS_WIN32 */ +static int +open_noatime (const char *path, + GFileQueryInfoFlags flags) +{ + int fd; + + if (flags & G_FILE_QUERY_INFO_NOATIME) + { + fd = open (path, O_RDONLY | O_NOATIME); + if (fd < 0 && errno != ENOENT) + fd = open (path, O_RDONLY); + } + else + fd = open (path, O_RDONLY); + + return fd; +} + static char * get_content_type (const char *basename, const char *path, @@ -1235,7 +1261,7 @@ if (sniff_length > 4096) sniff_length = 4096; - fd = open (path, O_RDONLY); + fd = open_noatime (path, flags); if (fd != -1) { ssize_t res; Index: gio/gioenums.h =================================================================== --- gio/gioenums.h (revision 7754) +++ gio/gioenums.h (working copy) @@ -142,12 +142,15 @@ * GFileQueryInfoFlags: * @G_FILE_QUERY_INFO_NONE: No flags set. * @G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS: Don't follow symlinks. + * @G_FILE_QUERY_INFO_NOATIME: Try to avoid updating a file's + * access time when possible. * * Flags used when querying a #GFileInfo. */ typedef enum { G_FILE_QUERY_INFO_NONE = 0, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS = (1 << 0) /*< nick=nofollow-symlinks >*/ + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS = (1 << 0), /*< nick=nofollow-symlinks >*/ + G_FILE_QUERY_INFO_NOATIME = (1 << 1) } GFileQueryInfoFlags;