diff options
Diffstat (limited to 'libmount/src/context_mount.c')
-rw-r--r-- | libmount/src/context_mount.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 41986e7..478a9fd 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -1571,6 +1571,12 @@ int mnt_context_get_mount_excode( */ syserr = mnt_context_get_syscall_errno(cxt); + if (buf && cxt->syscall_errmsg) { + snprintf(buf, bufsz, _("%s system call failed: %s"), + cxt->syscall_name ? : "mount", + cxt->syscall_errmsg); + return MNT_EX_FAIL; + } switch(syserr) { case EPERM: @@ -1617,10 +1623,8 @@ int mnt_context_get_mount_excode( return MNT_EX_SUCCESS; if (buf) snprintf(buf, bufsz, _("special device %s does not exist"), src); - } else if (buf) { - errno = syserr; - snprintf(buf, bufsz, _("mount(2) system call failed: %m")); - } + } else + goto generic_error; break; case ENOTDIR: @@ -1633,10 +1637,8 @@ int mnt_context_get_mount_excode( if (buf) snprintf(buf, bufsz, _("special device %s does not exist " "(a path prefix is not a directory)"), src); - } else if (buf) { - errno = syserr; - snprintf(buf, bufsz, _("mount(2) system call failed: %m")); - } + } else + goto generic_error; break; case EINVAL: @@ -1717,10 +1719,8 @@ int mnt_context_get_mount_excode( snprintf(buf, bufsz, _("cannot remount %s read-write, is write-protected"), src); else if (mflags & MS_BIND) snprintf(buf, bufsz, _("bind %s failed"), src); - else { - errno = syserr; - snprintf(buf, bufsz, _("mount(2) system call failed: %m")); - } + else + goto generic_error; break; case ENOMEDIUM: @@ -1740,9 +1740,11 @@ int mnt_context_get_mount_excode( /* fallthrough */ default: + generic_error: if (buf) { errno = syserr; - snprintf(buf, bufsz, _("mount(2) system call failed: %m")); + snprintf(buf, bufsz, _("%s system call failed: %m"), + cxt->syscall_name ? : "mount"); } break; } @@ -1752,7 +1754,8 @@ int mnt_context_get_mount_excode( #ifdef TEST_PROGRAM -static int test_perms(struct libmnt_test *ts, int argc, char *argv[]) +static int test_perms(struct libmnt_test *ts __attribute__((unused)), + int argc, char *argv[]) { struct libmnt_context *cxt; struct libmnt_optlist *ls; @@ -1795,7 +1798,8 @@ static int test_perms(struct libmnt_test *ts, int argc, char *argv[]) return 0; } -static int test_fixopts(struct libmnt_test *ts, int argc, char *argv[]) +static int test_fixopts(struct libmnt_test *ts __attribute__((unused)), + int argc, char *argv[]) { struct libmnt_context *cxt; struct libmnt_optlist *ls; |