From d1786d17088bd98ea6d5a702c25b42c2a2926375 Mon Sep 17 00:00:00 2001 From: Pavel Charvat Date: Wed, 6 Jun 2007 09:30:03 +0200 Subject: [PATCH] fastbufs: added some I/O checks --- lib/fb-file.c | 3 ++- lib/fb-mmap.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fb-file.c b/lib/fb-file.c index bf5684af..66227ed1 100644 --- a/lib/fb-file.c +++ b/lib/fb-file.c @@ -196,7 +196,8 @@ bfd_close(struct fastbuf *f) if (unlink(f->name) < 0) log(L_ERROR, "unlink(%s): %m", f->name); case 0: - close(FB_FILE(f)->fd); + if (close(FB_FILE(f)->fd)) + die("close(%s): %m", f->name); } xfree(f); } diff --git a/lib/fb-mmap.c b/lib/fb-mmap.c index 1e610c9c..15c542a0 100644 --- a/lib/fb-mmap.c +++ b/lib/fb-mmap.c @@ -148,7 +148,8 @@ bfmm_close(struct fastbuf *f) if (unlink(f->name) < 0) log(L_ERROR, "unlink(%s): %m", f->name); case 0: - close(F->fd); + if (close(F->fd)) + die("close(%s): %m", f->name); } xfree(f); } @@ -178,6 +179,8 @@ bfmmopen_internal(int fd, byte *name, uns mode) memcpy(f->name, name, namelen); F->fd = fd; F->file_extend = F->file_size = sh_seek(fd, 0, SEEK_END); + if (F->file_size < 0) + die("seek(%s): %m", name); if (mode & O_APPEND) f->pos = F->file_size; F->mode = mode; -- 2.39.5