GNOME Bugzilla – Bug 566064
Add NOATIME flag to query_info_flags
Last modified: 2009-01-05 16:21:03 UTC
Indexers like Tracker would like to use the O_NOATIME flag on Linux to prevent lots of spurious updates to the file system. (Pointed out here http://mail.gnome.org/archives/tracker-list/2008-December/msg00146.html). Patch introducing the new flag and implementing it in GLocalFile follows.
Created attachment 125536 [details] [review] adds noatime
The general idea makes sense to me. Some comments on the implementation: +#ifndef O_NOATIME +#if defined(__linux__) && (defined(__i386__) || defined(__PPC__)) +#define O_NOATIME 01000000 +#else +#define O_NOATIME 0 +#endif +#endif I don't think we should do hackery like this. Instead, define _GNU_SOURCE before including fcntl.h. Also, man open mentions only EPERM as something that may be affected by O_NOATIME, so I think open_noatime should maybe look more like this: static int open_noatime (const char *path, GFileQueryInfoFlags flags) { int fd; #ifdef O_NOATIME errno = 0; if (flags & G_FILE_QUERY_INFO_NOATIME) fd = open (path, O_RDONLY | O_NOATIME); if (errno == EPERM) #endif fd = open (path, O_RDONLY); return fd; }
Created attachment 125615 [details] [review] as suggested Sounds good to me. I was following git's example, so understandably might not have been the best idea for libraries. *g*
is there any need to bash errno? can't you just do "if (fd == -1 && errno == EPERM)" ?
Created attachment 125769 [details] [review] third times a charm?
Actually, I talked to alex about this, and we think we should just unconditionally try noatime for mime sniffing, so there's no need for a new query flag.
2009-01-05 Matthias Clasen <mclasen@redhat.com> Bug 566064 – Add NOATIME flag to query_info_flags * glocalfileinfo.c (get_content_type): Try using O_NOATIME when sniffing for mime types. Based on a patch by A. Walton