From a836486e24780616579ab0f8ef657a2a78960183 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 5 Jan 2009 16:20:40 +0000 Subject: [PATCH] Try using O_NOATIME when sniffing for mime types. Based on a patch by A. * 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 | 7 +++++++ gio/glocalfileinfo.c | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index 6736067ab..43ed5e486 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,10 @@ +2009-01-05 Matthias Clasen + + 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 * tests/.gitignore: improve diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 60d4686a2..299fc2d62 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -33,6 +33,7 @@ #ifdef HAVE_UNISTD_H #include #endif +#define _GNU_SOURCE #include #include #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;