[PATCH 28/33] mkswap: unify write check to a file descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 disk-utils/mkswap.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index ec6fc5f..71503f4 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;
 }
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux