From d413c0ce38a1737903122a02e37e2da40a391a03 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 9 Jan 2002 13:07:03 +0000 Subject: [PATCH] Explicitly close (=>flush) files. --- lib/format_text/format-text.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index f08b7e9ec..296b2037b 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -73,12 +73,18 @@ static int _vg_write(struct format_instance *fi, struct volume_group *vg) /* FIXME: should be opened exclusively */ if (!(fp = fopen(file, "w"))) { - log_err("Couldn't open text file '%s'.", file); + log_sys_error("fopen", file); return 0; } if (!text_vg_export(fp, vg)) { - log_err("Couldn't write text format file."); + log_error("Failed to write metadata to %s.", file); + fclose(fp); + return 0; + } + + if (!fclose(fp)) { + log_sys_error("fclose", file); return 0; }