X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fcacheio.c;h=6a6ed5ac7f093a590e621895a03f2c9e3729683e;hp=48292f8a5d49841c48f323c1b5977691396ef6be;hb=8414d150cee62ba0554cfd645956a88dba02a7eb;hpb=01f6e717f3e0bf953fadd3de22096c9025c3d38d diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c index 48292f8..6a6ed5a 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -24,6 +24,7 @@ #include #include #include +#include void qword_add(char **bpp, int *lp, char *str) { @@ -125,7 +126,10 @@ void qword_print(FILE *f, char *str) char *bp = qword_buf; int len = sizeof(qword_buf); qword_add(&bp, &len, str); - fwrite(qword_buf, bp-qword_buf, 1, f); + if (fwrite(qword_buf, bp-qword_buf, 1, f) != 1) { + xlog_warn("qword_print: fwrite failed: errno %d (%s)", + errno, strerror(errno)); + } } void qword_printhex(FILE *f, char *str, int slen) @@ -133,7 +137,10 @@ void qword_printhex(FILE *f, char *str, int slen) char *bp = qword_buf; int len = sizeof(qword_buf); qword_addhex(&bp, &len, str, slen); - fwrite(qword_buf, bp-qword_buf, 1, f); + if (fwrite(qword_buf, bp-qword_buf, 1, f) != 1) { + xlog_warn("qword_printhex: fwrite failed: errno %d (%s)", + errno, strerror(errno)); + } } void qword_printint(FILE *f, int num) @@ -147,15 +154,21 @@ int qword_eol(FILE *f) fprintf(f,"\n"); err = fflush(f); + if (err) { + xlog_warn("qword_eol: fflush failed: errno %d (%s)", + errno, strerror(errno)); + } /* * We must send one line (and one line only) in a single write * call. In case of a write error, libc may accumulate the * unwritten data and try to write it again later, resulting in a * multi-line write. So we must explicitly ask it to throw away - * any such cached data: + * any such cached data. But we return any original error + * indication to the caller. */ __fpurge(f); - return fflush(f); + fflush(f); + return err; } @@ -318,7 +331,10 @@ cache_flush(int force) sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]); fd = open(path, O_RDWR); if (fd >= 0) { - write(fd, stime, strlen(stime)); + if (write(fd, stime, strlen(stime)) != strlen(stime)) { + xlog_warn("Writing to '%s' failed: errno %d (%s)", + path, errno, strerror(errno)); + } close(fd); } }