]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add human compatible message for EBADMSG errno
authorKarel Zak <kzak@redhat.com>
Mon, 2 Oct 2017 11:44:29 +0000 (13:44 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 2 Oct 2017 11:44:29 +0000 (13:44 +0200)
 mount: /media/sdb5: mount(2) system call failed: Bad message.

is really ugly for end users. It seems XFS, extN (etc) use EBADMSG for
bad checksums. For network or pseudo filesystems continue to use "Bad
message" error...

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1496764
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_mount.c

index e84947f00a3360be79c7192e5c32bade0f8208e1..8ef806314687f5181a2b7ecdb8a86da41bb4419c 100644 (file)
@@ -1578,6 +1578,14 @@ int mnt_context_get_mount_excode(
                        snprintf(buf, bufsz, _("no medium found on %s"), src);
                break;
 
+       case EBADMSG:
+               /* Bad CRC for classic filesystems (e.g. extN or XFS) */
+               if (buf && (S_ISBLK(st.st_mode) || S_ISREG(st.st_mode))) {
+                       snprintf(buf, bufsz, _("cannot mount; probably corrupted filesystem on %s"), src);
+                       break;
+               }
+               /* fallthrough */
+
        default:
                if (buf) {
                        errno = syserr;