#include #include #include int main(int argc, char **argv) { struct stat stat_buf; time_t now = time(NULL); if (argc != 3) { fprintf(stderr, "usage: path1 path2\n"); exit(1); } if (rename(argv[1], argv[2]) < 0) { perror("rename"); exit(1); } if (stat(argv[2], &stat_buf) < 0) { perror("stat"); exit(1); } if (stat_buf.st_mtime < now - 60*60) { fprintf(stderr, "Bad karma: mtime=%u now-60*60=%u\n", stat_buf.st_mtime, now - 60*60); exit(1); } else { fprintf(stderr, "OK: mtime=%u now-60*60=%u\n", stat_buf.st_mtime, now - 60*60); } return 0; }