Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libmount: add dmesg(1) hint for mount(2) failure #1444

Closed
wants to merge 1 commit into from

Conversation

Hello71
Copy link
Contributor

@Hello71 Hello71 commented Sep 7, 2021

it is a perpetual support issue at every Linux distro that the mount(8)
error messages are vague and often don't correctly identify the issue.
this is because of historical reasons: mount(2) jams hundreds of
distinct issues into a single errno. however, in 99% of cases, a verbose
error is printed to the kernel log. although we unfortunately can't
fetch it for them or even determine if it exists, we can at least hint
to the user that more info is likely available via dmesg.

it is a perpetual support issue at every Linux distro that the mount(8)
error messages are vague and often don't correctly identify the issue.
this is because of historical reasons: mount(2) jams hundreds of
distinct issues into a single errno. however, in 99% of cases, a verbose
error is printed to the kernel log. although we unfortunately can't
fetch it for them or even determine if it exists, we can at least hint
to the user that more info is likely available via dmesg.
@karelzak
Copy link
Collaborator

I'm not sure about this way. Maybe it would be better to keep this in mount(8) only. It means add the hint to sys-utils/mount.c:mk_exit_code(), what about:

diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index ceb0bb469..ac7af42cb 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -354,6 +354,10 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc)
                if (!spec)
                        spec = "???";
                warnx("%s: %s.", spec, buf);
+
+               if (mnt_context_syscall_called(cxt) &&
+                   mnt_context_get_syscall_errno(cxt) != 0)
+                       fprintf(stderr, _("       dmesg(1) may have more information after failed mount system call.\n"));
        }
 
        if (rc == MNT_EX_SUCCESS && mnt_context_get_status(cxt) == 1) {

For example:

# mount /dev/nvme0n1p1 /mnt
mount: /mnt: unknown filesystem type 'swap'.
       dmesg(1) may have more information after failed mount system call.

@Hello71
Copy link
Contributor Author

Hello71 commented Sep 16, 2021

sounds fine to me. do you want to make the patch or should I?

@karelzak
Copy link
Collaborator

sounds fine to me. do you want to make the patch or should I?

I have it as a patch, so I'll commit and push it. Thanks.

@karelzak karelzak closed this in 79534c0 Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants