1 /* fsync.c - Synchronize a file's in-core state with storage device.
3 * Copyright 2015 Ranjan Kumar <ranjankumar.bth@gmail.comi>
7 USE_FSYNC(NEWTOY(fsync, "<1d", TOYFLAG_BIN))
13 usage: fsync [-d] [FILE...]
15 Synchronize a file's in-core state with storage device.
17 -d Avoid syncing metadata.
23 static void do_fsync(int fd, char *name)
25 if (((toys.optflags & FLAG_d) ? fdatasync(fd) : fsync(fd)))
26 perror_msg("can't sync '%s'", name);
31 loopfiles_rw(toys.optargs, O_RDONLY|O_NOATIME|O_NOCTTY|O_CLOEXEC|WARN_ONLY,