28 lines
444 B
C
28 lines
444 B
C
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main(const int argc, const char **argv) {
|
|
if (argc == 1)
|
|
sync();
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
int fd = open(argv[i], O_WRONLY);
|
|
if (fd < 0) {
|
|
fprintf(stderr, "sync: %s\n", strerror(errno));
|
|
return 1;
|
|
}
|
|
|
|
if (fsync(fd)) {
|
|
fprintf(stderr, "sync: %s\n", strerror(errno));
|
|
return 1;
|
|
}
|
|
|
|
close(fd);
|
|
}
|
|
|
|
return 0;
|
|
}
|