summaryrefslogtreecommitdiffstats
path: root/text-utils/pg.c
diff options
context:
space:
mode:
authorSami Kerola2013-04-13 21:54:41 +0200
committerKarel Zak2013-04-26 13:26:06 +0200
commit944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad (patch)
tree20365431da3380a5a25f63888146eef4ee812014 /text-utils/pg.c
parentagetty: check writing to a file was successful (diff)
downloadkernel-qcow2-util-linux-944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad.tar.gz
kernel-qcow2-util-linux-944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad.tar.xz
kernel-qcow2-util-linux-944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad.zip
pg: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/pg.c')
-rw-r--r--text-utils/pg.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/text-utils/pg.c b/text-utils/pg.c
index c00b7371f..7ddf96bf9 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -1228,7 +1228,14 @@ static void pgfile(FILE *f, const char *name)
/* No error check for compat. */
fwrite_all(b, sizeof *b, sz, save);
}
- fclose(save);
+ if (close_stream(save) != 0) {
+ cmd.count = errno;
+ mesg(_("write failed"));
+ mesg(": ");
+ mesg(p);
+ mesg(strerror(cmd.count));
+ goto newcmd;
+ }
fseeko(fbuf, (off_t)0, SEEK_END);
mesg(_("saved"));
goto newcmd;