Skip to content

Commit

Permalink
Improve error msg on idmap mounts
Browse files Browse the repository at this point in the history
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 <rodrigoca@microsoft.com>
  • Loading branch information
rata committed Dec 27, 2023
1 parent f987a57 commit 9917c3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libcrun/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9917c3b

Please sign in to comment.