From: Sami Kerola Date: Sat, 13 Apr 2013 19:54:56 +0000 (+0100) Subject: mkswap: unify write check to a file descriptor X-Git-Tag: v2.24-rc1~584 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=833b7e0d8064e2b86ab42d8a9185897bc7f6e507;p=thirdparty%2Futil-linux.git mkswap: unify write check to a file descriptor Signed-off-by: Sami Kerola --- diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index ec6fc5f993..71503f4462 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; }