2021-11-16 02:55:57 +03:00
|
|
|
#include <errno.h>
|
2021-11-14 10:04:54 +03:00
|
|
|
#include <stdio.h>
|
2021-11-16 02:55:57 +03:00
|
|
|
#include <string.h>
|
2021-11-14 10:04:54 +03:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
2021-11-16 02:55:57 +03:00
|
|
|
char * file = ".";
|
|
|
|
if (argc > 1) {
|
|
|
|
file = argv[1];
|
|
|
|
}
|
|
|
|
int fd = open(file,O_RDONLY|O_DIRECTORY);
|
|
|
|
if (fd < 0) {
|
|
|
|
fd = open(file,O_RDONLY);
|
|
|
|
}
|
|
|
|
if (fd < 0) {
|
|
|
|
fprintf(stderr, "sync: open: %s: %s (%d)\n", file, strerror(errno), fd);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
int res = ioctl(fd, IOCTLSYNC, NULL);
|
|
|
|
if (res < 0) {
|
|
|
|
fprintf(stderr, "sync: ioctl: %s (%d)\n", strerror(errno), fd);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2021-11-14 10:04:54 +03:00
|
|
|
}
|