From: Michihiro NAKAJIMA Date: Tue, 10 Jan 2012 10:10:03 +0000 (-0500) Subject: Do not try a test restoring atime when the filesytem is mounted with noatime option. X-Git-Tag: v3.0.4~2^2~205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6ce93f710bc5f173cc648f39a5fba7b7895bb45;p=thirdparty%2Flibarchive.git Do not try a test restoring atime when the filesytem is mounted with noatime option. SVN-Revision: 4119 --- diff --git a/libarchive/test/test_read_disk_directory_traversals.c b/libarchive/test/test_read_disk_directory_traversals.c index d8f874242..ebbbdefeb 100644 --- a/libarchive/test/test_read_disk_directory_traversals.c +++ b/libarchive/test/test_read_disk_directory_traversals.c @@ -25,6 +25,18 @@ #include "test.h" __FBSDID("$FreeBSD$"); +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_STATFS_H +#include +#endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif #include #if defined(_WIN32) && !defined(__CYGWIN__) # if !defined(__BORLANDC__) @@ -32,6 +44,41 @@ __FBSDID("$FreeBSD$"); # endif #endif +/* + * Test if the current filesytem can restore atime. + */ +#if defined(HAVE_STATVFS) && defined(ST_NOATIME) +static int +canRestoreAtime(void) +{ + struct statvfs sfs; + int r; + + r = statvfs(".", &sfs); + if (r != 0) + return (1); + return (sfs.f_flag & ST_NOATIME)?0:1; +} +#elif defined(HAVE_STATFS) && defined(MNT_NOATIME) +static int +canRestoreAtime(void) +{ + struct statfs sfs; + int r; + + r = statfs(".", &sfs); + if (r != 0) + return (1); + return (sfs.f_flags & MNT_NOATIME)?0:1; +} +#else +static int +canRestoreAtime(void) +{ + return (1); +} +#endif + static void test_basic(void) { @@ -1001,6 +1048,11 @@ test_restore_atime(void) int64_t offset; int file_count; + if (!canRestoreAtime()) { + skipping("Can't test restoring atime on this filesystem"); + return; + } + assertMakeDir("at", 0755); assertMakeFile("at/f1", 0644, "0123456789"); assertMakeFile("at/f2", 0644, "hello world");