]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 223. Revise r4120 and merge r4122 from trunk.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 11 Jan 2012 07:21:25 +0000 (02:21 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 11 Jan 2012 07:21:25 +0000 (02:21 -0500)
SVN-Revision: 4123

libarchive/test/test_read_disk_directory_traversals.c

index c574d64dd338002b59a1dff8c1c4196aab008387..6741ee1b48beb3c925dde9e29a924ab90e7954e6 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD$");
 
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_SYS_MOUNT_H
-#include <sys/mount.h>
-#endif
-#ifdef HAVE_SYS_STATFS_H
-#include <sys/statfs.h>
-#endif
-#ifdef HAVE_SYS_STATVFS_H
-#include <sys/statvfs.h>
-#endif
 #include <limits.h>
 #if defined(_WIN32) && !defined(__CYGWIN__)
 # if !defined(__BORLANDC__)
@@ -45,39 +33,28 @@ __FBSDID("$FreeBSD$");
 #endif
 
 /*
- * Test if the current filesytem can restore atime.
+ * Test if the current filesytem is mounted with noatime option.
  */
-#if defined(HAVE_STATVFS) && defined(ST_NOATIME)
 static int
-canRestoreAtime(void)
+atimeIsUpdated(void)
 {
-       struct statvfs sfs;
-       int r;
-
-       r = statvfs(".", &sfs);
-       if (r != 0)
+       const char *fn = "fs_noatime";
+       struct stat st;
+
+       if (!assertMakeFile(fn, 0666, "a"))
+               return (0);
+       if (!assertUtimes(fn, 1, 0, 1, 0))
+               return (0);
+       /* Test the file contents in order to update its atime. */
+       if (!assertTextFileContents("a", fn))
+               return (0);
+       if (stat(fn, &st) != 0)
+               return (0);
+       /* Is atime updated? */
+       if (st.st_atime > 1)
                return (1);
-       return (sfs.f_flag & ST_NOATIME)?0:1;
+       return (0);
 }
-#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)
@@ -927,7 +904,7 @@ test_restore_atime(void)
        int64_t offset;
        int file_count;
 
-       if (!canRestoreAtime()) {
+       if (!atimeIsUpdated()) {
                skipping("Can't test restoring atime on this filesystem");
                return;
        }