From 9917c3b3e329ac71e005d407cd1aac8e4e3b15d9 Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Wed, 27 Dec 2023 17:15:44 +0100 Subject: [PATCH] Improve error msg on idmap mounts Some filesystems don't support idmap mounts and just showing to the user invalid argument is not super clear. When errno is EINVAL, let's add a text hinting that the cause could be that idmap mounts are not supported on that filesystem used. Signed-off-by: Rodrigo Campos --- src/libcrun/linux.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libcrun/linux.c b/src/libcrun/linux.c index 2c46cc6824..32a9b3e9d5 100644 --- a/src/libcrun/linux.c +++ b/src/libcrun/linux.c @@ -4018,6 +4018,7 @@ maybe_get_idmapped_mount (runtime_spec_schema_config_schema *def, runtime_spec_s char proc_path[64]; bool has_mappings; int ret; + char *extraMsg = ""; *out_fd = -1; @@ -4081,8 +4082,12 @@ maybe_get_idmapped_mount (runtime_spec_schema_config_schema *def, runtime_spec_s attr.userns_fd = fd; ret = syscall_mount_setattr (newfs_fd, "", AT_EMPTY_PATH | (recursive ? AT_RECURSIVE : 0), &attr); - if (UNLIKELY (ret < 0)) - return crun_make_error (err, errno, "mount_setattr `%s`", mnt->destination); + if (UNLIKELY (ret < 0)) { + if (errno == EINVAL) { + extraMsg = "(maybe the filesystem used doesn't support idmap mounts on this kernel?)"; + } + return crun_make_error (err, errno, "mount_setattr `%s` %s", mnt->destination, extraMsg); + } *out_fd = get_and_reset (&newfs_fd); return 0;