8 #include <sys/statvfs.h>
11 static int do_test (void);
12 #define TEST_FUNCTION do_test ()
14 #include <test-skeleton.c>
27 buf
= (char *) malloc (strlen (test_dir
) + sizeof "/tst-atime.XXXXXX");
30 printf ("cannot allocate memory: %m\n");
33 stpcpy (stpcpy (buf
, test_dir
), "/tst-atime.XXXXXX");
38 printf ("cannot open temporary file: %m\n");
43 /* Make sure the filesystem doesn't have the noatime option set. If
44 statvfs is not available just continue. */
46 int e
= fstatvfs (fd
, &sv
);
51 printf ("cannot statvfs '%s': %m\n", buf
);
55 if ((sv
.f_flag
& ST_NOATIME
) != 0)
57 puts ("Bah! The filesystem is mounted with noatime");
63 /* Make sure it gets removed. */
66 if (write (fd
, "some string\n", 12) != 12)
68 printf ("cannot write temporary file: %m\n");
72 if (lseek (fd
, 0, SEEK_SET
) == (off_t
) -1)
74 printf ("cannot reposition temporary file: %m\n");
78 fp
= fdopen (fd
, "r");
81 printf ("cannot create stream: %m\n");
85 if (fstat (fd
, &st1
) == -1)
87 printf ("first stat failed: %m\n");
96 printf ("did not read correct character: got '%c', expected 's'\n", ch
);
100 if (fstat (fd
, &st2
) == -1)
102 printf ("second stat failed: %m\n");
106 if (st1
.st_atime
> st2
.st_atime
)
108 puts ("second atime smaller");
111 else if (st1
.st_atime
== st2
.st_atime
)
113 puts ("atime has not changed");