From 8ba971620e3304e2a2aa3d98ad33624c67eb3b70 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, 8 insertions(+), 1 deletion(-) diff --git a/src/libcrun/linux.c b/src/libcrun/linux.c index 2c46cc6824..69bb3939f3 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; @@ -4082,7 +4083,13 @@ maybe_get_idmapped_mount (runtime_spec_schema_config_schema *def, runtime_spec_s 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 (errno == EINVAL) + { + extraMsg = "(maybe the file system 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;