#include #include #include int main(int argc, char **argv) { int fd; struct stat st; fd = open(argv[1], O_WRONLY | O_APPEND); if (fd == -1) { perror("open failed"); return 0; } if (fstat(fd, &st)) { perror("stat failed"); return 0; } printf("old file size %d\n", st.st_size); if (write(fd, "hello", 5) != 5) { perror("write failed"); return 0; } if (fstat(fd, &st)) { perror("stat failed"); return 0; } printf("new file size %d\n", st.st_size); if (fsync(fd)) { perror("fsync failed"); return 0; } printf("rebooting"); fflush(stdout); system("reboot -f -n"); return 0; }