|
|
673c78 |
From f02e9004303df5ab3d9b868f6f60af44663cce69 Mon Sep 17 00:00:00 2001
|
|
|
673c78 |
From: Karel Zak <kzak@redhat.com>
|
|
|
673c78 |
Date: Tue, 19 Apr 2022 09:44:07 +0200
|
|
|
673c78 |
Subject: libblkid: check fsync() return code
|
|
|
673c78 |
|
|
|
673c78 |
Since 39f5af25982d8b0244000e92a9d0e0e6557d0e17 libblkid uses
|
|
|
673c78 |
O_NONBLOCK. Now it's more obvious that check fsync() (and close())
|
|
|
673c78 |
return value after write() is always a good idea ...
|
|
|
673c78 |
|
|
|
673c78 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2074486
|
|
|
673c78 |
Upstream: http://github.com/util-linux/util-linux/commit/133a0d70f637b4f4e4337811e452153b04f2bdcf
|
|
|
673c78 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
673c78 |
---
|
|
|
673c78 |
libblkid/src/probe.c | 5 ++++-
|
|
|
673c78 |
misc-utils/wipefs.c | 8 ++++++--
|
|
|
673c78 |
2 files changed, 10 insertions(+), 3 deletions(-)
|
|
|
673c78 |
|
|
|
673c78 |
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
|
|
|
673c78 |
index 5f01bc3b3..d317dc19a 100644
|
|
|
673c78 |
--- a/libblkid/src/probe.c
|
|
|
673c78 |
+++ b/libblkid/src/probe.c
|
|
|
673c78 |
@@ -1298,7 +1298,10 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
|
|
|
673c78 |
/* wipen on device */
|
|
|
673c78 |
if (write_all(fd, buf, len))
|
|
|
673c78 |
return -1;
|
|
|
673c78 |
- fsync(fd);
|
|
|
673c78 |
+
|
|
|
673c78 |
+ if (fsync(fd) != 0)
|
|
|
673c78 |
+ return -1;
|
|
|
673c78 |
+
|
|
|
673c78 |
pr->flags &= ~BLKID_FL_MODIF_BUFF; /* be paranoid */
|
|
|
673c78 |
|
|
|
673c78 |
return blkid_probe_step_back(pr);
|
|
|
673c78 |
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
|
|
|
673c78 |
index 78dc63ee7..f08a9ba4f 100644
|
|
|
673c78 |
--- a/misc-utils/wipefs.c
|
|
|
673c78 |
+++ b/misc-utils/wipefs.c
|
|
|
673c78 |
@@ -615,7 +615,9 @@ static int do_wipe(struct wipe_control *ctl)
|
|
|
673c78 |
if (need_force)
|
|
|
673c78 |
warnx(_("Use the --force option to force erase."));
|
|
|
673c78 |
|
|
|
673c78 |
- fsync(blkid_probe_get_fd(pr));
|
|
|
673c78 |
+ if (fsync(blkid_probe_get_fd(pr)) != 0)
|
|
|
673c78 |
+ err(EXIT_FAILURE, _("%s: cannot flush modified buffers"),
|
|
|
673c78 |
+ ctl->devname);
|
|
|
673c78 |
|
|
|
673c78 |
#ifdef BLKRRPART
|
|
|
673c78 |
if (reread && (mode & O_EXCL)) {
|
|
|
673c78 |
@@ -635,7 +637,9 @@ static int do_wipe(struct wipe_control *ctl)
|
|
|
673c78 |
}
|
|
|
673c78 |
#endif
|
|
|
673c78 |
|
|
|
673c78 |
- close(blkid_probe_get_fd(pr));
|
|
|
673c78 |
+ if (close(blkid_probe_get_fd(pr)) != 0)
|
|
|
673c78 |
+ err(EXIT_FAILURE, _("%s: close device failed"), ctl->devname);
|
|
|
673c78 |
+
|
|
|
673c78 |
blkid_free_probe(pr);
|
|
|
673c78 |
free(backup);
|
|
|
673c78 |
return 0;
|
|
|
673c78 |
--
|
|
|
673c78 |
2.36.1
|
|
|
673c78 |
|