From 0361cb6f9bb8f74438c0577d968eb6f4bf9a2515 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 28 Apr 2017 11:03:24 +0200 Subject: [PATCH] libmount: add read-only warning Signed-off-by: Karel Zak --- libmount/src/context.c | 2 +- libmount/src/context_mount.c | 2 ++ sys-utils/mount.c | 8 ++------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libmount/src/context.c b/libmount/src/context.c index a370cea09..b945298e6 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 f2b42eb0b..9caee70e5 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 9d5c6e1bd..4d7a5fc73 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; }