From: Martin Mares Date: Sun, 15 Aug 2004 12:09:45 +0000 (+0000) Subject: Added bfilesync(). X-Git-Tag: holmes-import~922 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=c412387ccb174b79bbcf461633f70728577a7532;p=libucw.git Added bfilesync(). --- diff --git a/lib/fastbuf.h b/lib/fastbuf.h index fadf3061..851a1a0c 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -84,6 +84,7 @@ struct fastbuf *bopen(byte *name, uns mode, uns buflen); struct fastbuf *bopen_tmp(uns buflen); struct fastbuf *bfdopen(int fd, uns buflen); struct fastbuf *bfdopen_shared(int fd, uns buflen); +void bfilesync(struct fastbuf *b); /* FastIO on in-memory streams */ diff --git a/lib/fb-file.c b/lib/fb-file.c index 915c1b40..9fa3f8f5 100644 --- a/lib/fb-file.c +++ b/lib/fb-file.c @@ -153,6 +153,14 @@ bfdopen_shared(int fd, uns buflen) return f; } +void +bfilesync(struct fastbuf *b) +{ + bflush(b); + if (fsync(FB_FILE(b)->fd) < 0) + log(L_ERROR, "fsync(%s) failed: %m", b->name); +} + #ifdef TEST int main(int argc, char **argv)