7 #include <sys/statvfs.h>
10 static int do_test (void);
11 #define TEST_FUNCTION do_test ()
13 #include <test-skeleton.c>
28 buf
= (char *) malloc (strlen (test_dir
) + sizeof "/tst-atime.XXXXXX");
31 printf ("cannot allocate memory: %m\n");
34 stpcpy (stpcpy (buf
, test_dir
), "/tst-atime.XXXXXX");
39 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. */
45 e
= fstatvfs (fd
, &sv
);
50 printf ("cannot statvfs '%s': %m\n", buf
);
54 if ((sv
.f_flag
& ST_NOATIME
) != 0)
56 puts ("Bah! The filesystem is mounted with noatime");
61 /* Make sure it gets removed. */
64 if (write (fd
, "some string\n", 12) != 12)
66 printf ("cannot write temporary file: %m\n");
70 if (lseek (fd
, 0, SEEK_SET
) == (off_t
) -1)
72 printf ("cannot reposition temporary file: %m\n");
76 fp
= fdopen (fd
, "r");
79 printf ("cannot create stream: %m\n");
83 if (fstat (fd
, &st1
) == -1)
85 printf ("first stat failed: %m\n");
94 printf ("did not read correct character: got '%c', expected 's'\n", ch
);
98 if (fstat (fd
, &st2
) == -1)
100 printf ("second stat failed: %m\n");
104 if (st1
.st_atime
> st2
.st_atime
)
106 puts ("second atime smaller");
109 else if (st1
.st_atime
== st2
.st_atime
)
111 puts ("atime has not changed");