summaryrefslogtreecommitdiffstats
path: root/disk-utils/mkswap.c
diff options
context:
space:
mode:
authorSami Kerola2013-04-13 21:54:56 +0200
committerKarel Zak2013-04-26 13:26:07 +0200
commit833b7e0d8064e2b86ab42d8a9185897bc7f6e507 (patch)
tree9c7b923c7457f663a9fab84799aeb1242f6f1e47 /disk-utils/mkswap.c
parentmkfs.minix: check writing to a file descriptor was successful (diff)
downloadkernel-qcow2-util-linux-833b7e0d8064e2b86ab42d8a9185897bc7f6e507.tar.gz
kernel-qcow2-util-linux-833b7e0d8064e2b86ab42d8a9185897bc7f6e507.tar.xz
kernel-qcow2-util-linux-833b7e0d8064e2b86ab42d8a9185897bc7f6e507.zip
mkswap: unify write check to a file descriptor
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils/mkswap.c')
-rw-r--r--disk-utils/mkswap.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index ec6fc5f99..71503f446 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -625,15 +625,6 @@ main(int argc, char **argv) {
_("%s: unable to write signature page"),
device_name);
- /*
- * A subsequent swapon() will fail if the signature
- * is not actually on disk. (This is a kernel bug.)
- */
-#ifdef HAVE_FSYNC
- if (fsync(DEV))
- errx(EXIT_FAILURE, _("fsync failed"));
-#endif
-
#ifdef HAVE_LIBSELINUX
if (S_ISREG(statbuf.st_mode) && is_selinux_enabled() > 0) {
security_context_t context_string;
@@ -664,5 +655,12 @@ main(int argc, char **argv) {
freecon(oldcontext);
}
#endif
+ /*
+ * A subsequent swapon() will fail if the signature
+ * is not actually on disk. (This is a kernel bug.)
+ * The fsync() in close_fd() will take care of writing.
+ */
+ if (close_fd(DEV) != 0)
+ err(EXIT_FAILURE, _("write failed"));
return EXIT_SUCCESS;
}