Try using O_NOATIME when sniffing for mime types. Based on a patch by A.
authorMatthias Clasen <matthiasc@src.gnome.org>
Mon, 5 Jan 2009 16:20:40 +0000 (16:20 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 5 Jan 2009 16:20:40 +0000 (16:20 +0000)
        * glocalfileinfo.c (get_content_type): Try using O_NOATIME when
        sniffing for mime types. Based on a patch by A. Walton

svn path=/trunk/; revision=7773

gio/ChangeLog
gio/glocalfileinfo.c

index 6736067..43ed5e4 100644 (file)
@@ -1,3 +1,10 @@
+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
+
 2009-01-05  Ryan Lortie  <desrt@desrt.ca>
 
        * tests/.gitignore: improve
index 60d4686..299fc2d 100644 (file)
@@ -33,6 +33,7 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#define _GNU_SOURCE
 #include <fcntl.h>
 #include <errno.h>
 #ifdef HAVE_GRP_H
@@ -1234,8 +1235,13 @@ get_content_type (const char          *basename,
          sniff_length = _g_unix_content_type_get_sniff_len ();
          if (sniff_length > 4096)
            sniff_length = 4096;
-         
-         fd = open (path, O_RDONLY);
+
+#ifdef O_NOATIME         
+          fd = open (path, O_RDONLY | O_NOATIME);
+          if (fd < 0 && errno == EPERM)
+#endif
+           fd = open (path, O_RDONLY);
+
          if (fd != -1)
            {
              ssize_t res;