libmount: add read-only warning

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2017-04-28 11:03:24 +02:00
parent 79055689a2
commit 0361cb6f9b
3 changed files with 5 additions and 7 deletions

View File

@ -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 : "<no-message>"));
return rc;
}

View File

@ -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;
}

View File

@ -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;
}