[PATCH 20/33] cfdisk: check writing to a file descriptor was successful

Sami Kerola
2013-04-13T19:56:03Z

fdisks/cfdisk.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fdisks/cfdisk.c b/fdisks/cfdisk.c
index dcaa05d..e685f71 100644
--- a/fdisks/cfdisk.c
+++ b/fdisks/cfdisk.c
@@ -406,8 +406,12 @@ static void
fdexit(int ret) {
if (opened) {
if (changed)
- fsync(fd);
- close(fd);
+ if (close_fd(fd) != 0) {
+ fprintf(stderr, _("write failed\n"));
+ exit(2);
+ }
+ else
+ close(fd);
}
if (changed) {
fprintf(stderr, _("Disk has been changed.\n"));
--
1.8.2.1