/* testcase for time structure issues * Robin H. Johnson * 1. the times should never decrease. * 2. depending on the sync behavior of your filesystem, NOT having the * unlink() call but having an existing file may give you the OLD file * timestamp */ #include #include #include #include #define pb(s) stat(f, &buf); printf("%s %ld.%ld\n",s,(long int)buf.st_mtime,(long int)buf.st_mtim.tv_nsec); int main(int argc, char** argv) { if(argc != 2) return 1; char* f = argv[1]; int i; struct stat buf; pb("before"); //unlink(f); int fd = open(f,O_CREAT|O_WRONLY,0600); pb("created"); close(fd); for(i = 5; i; i--) { pb("utimes"); if(i>1) { utimes(f, NULL); usleep(5000); } } }