From: Pavel Charvat Date: Wed, 6 Jun 2007 07:30:03 +0000 (+0200) Subject: fastbufs: added some I/O checks X-Git-Tag: holmes-import~506^2~13^2~105 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d1786d17088bd98ea6d5a702c25b42c2a2926375;p=libucw.git fastbufs: added some I/O checks --- 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;