From: Karel Zak Date: Fri, 28 Apr 2017 09:03:24 +0000 (+0200) Subject: libmount: add read-only warning X-Git-Tag: v2.30-rc1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0361cb6f9bb8f74438c0577d968eb6f4bf9a2515;p=thirdparty%2Futil-linux.git libmount: add read-only warning Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index a370cea099..b945298e61 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -2362,7 +2362,7 @@ int mnt_context_get_excode( break; } - DBG(CXT, ul_debugobj(cxt, "return code: %d [%s]", rc, + DBG(CXT, ul_debugobj(cxt, "excode: rc=%d message=\"%s\"", rc, buf ? buf : "")); return rc; } diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index f2b42eb0b4..9caee70e5a 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -1311,6 +1311,8 @@ int mnt_context_get_mount_excode( /* * Libmount success && syscall success. */ + if (buf && mnt_context_forced_rdonly(cxt)) + snprintf(buf, bufsz, _("WARNING: device write-protected, mounted read-only")); return MNT_EX_SUCCESS; } diff --git a/sys-utils/mount.c b/sys-utils/mount.c index 9d5c6e1bd3..4d7a5fc73f 100644 --- a/sys-utils/mount.c +++ b/sys-utils/mount.c @@ -305,12 +305,8 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc) warnx(_("%s: %s."), spec, buf); } - if (rc == MNT_EX_SUCCESS) { - if (mnt_context_get_status(cxt) == 1) - selinux_warning(cxt, tgt); - - if (mnt_context_forced_rdonly(cxt)) - warnx(_("%s: WARNING: device write-protected, mounted read-only."), tgt); + if (rc == MNT_EX_SUCCESS && mnt_context_get_status(cxt) == 1) { + selinux_warning(cxt, tgt); } return rc; }