#include #include #include #include #include int main(void) { int fd = open("testfile", O_CREAT | O_RDWR, 0600); struct stat st1, st2; if (fd < 0) { perror("NA: open"); exit(1); } if (close(fd) < 0) { perror("NA: close"); exit(1); } unlink("testlink"); if (stat("testfile", &st1) < 0) { perror("NA: first stat"); exit(1); } sleep(5); if (chmod("testfile", 0660) < 0) { perror("NA: chmod"); exit(1); } if (stat("testfile", &st2) < 0) { perror("NA: second stat"); exit(1); } if (st2.st_ctim.tv_sec == st1.st_ctim.tv_sec) { printf("FAIL: chmod didn't update ctime\n"); } else { printf("OK: chmod updated ctime\n"); } st1 = st2; sleep(5); if (link("testfile", "testlink") < 0) { perror("NA: link failed"); exit(1); } if (stat("testfile", &st2) < 0) { perror("NA: third stat"); exit(1); } if (st2.st_ctim.tv_sec == st1.st_ctim.tv_sec) { printf("FAIL: link didn't update ctime\n"); exit(1); } else { printf("OK: link updated ctime\n"); } return 0; }