diff options
Diffstat (limited to 'write_or_die.c')
-rw-r--r-- | write_or_die.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/write_or_die.c b/write_or_die.c index e125e11d3b..630be4cb94 100644 --- a/write_or_die.c +++ b/write_or_die.c @@ -40,7 +40,7 @@ void maybe_flush_or_die(FILE *f, const char *desc) } } -int read_in_full(int fd, void *buf, size_t count) +ssize_t read_in_full(int fd, void *buf, size_t count) { char *p = buf; ssize_t total = 0; @@ -57,7 +57,7 @@ int read_in_full(int fd, void *buf, size_t count) return total; } -int write_in_full(int fd, const void *buf, size_t count) +ssize_t write_in_full(int fd, const void *buf, size_t count) { const char *p = buf; ssize_t total = 0; @@ -78,6 +78,13 @@ int write_in_full(int fd, const void *buf, size_t count) return total; } +void fsync_or_die(int fd, const char *msg) +{ + if (fsync(fd) < 0) { + die("%s: fsync error (%s)", msg, strerror(errno)); + } +} + void write_or_die(int fd, const void *buf, size_t count) { if (write_in_full(fd, buf, count) < 0) { |