Skip to content

Commit 50e9898

Browse files
committed
utils: use fsopen to open reference to proc
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 2e86c95 commit 50e9898

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/libcrun/utils.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,23 @@ libcrun_get_cached_proc_fd (libcrun_container_t *container, libcrun_error_t *err
28142814
{
28152815
if (container->proc_fd < 0)
28162816
{
2817+
#ifdef HAVE_NEW_MOUNT_API
2818+
cleanup_close int fsfd = -1;
2819+
int ret;
2820+
2821+
fsfd = syscall_fsopen ("proc", FSOPEN_CLOEXEC);
2822+
if (fsfd >= 0)
2823+
{
2824+
ret = syscall_fsconfig (fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0);
2825+
if (ret >= 0)
2826+
{
2827+
container->proc_fd = syscall_fsmount (fsfd, FSMOUNT_CLOEXEC, 0);
2828+
if (container->proc_fd >= 0)
2829+
return container->proc_fd;
2830+
}
2831+
}
2832+
#endif
2833+
28172834
container->proc_fd = open ("/proc", O_RDONLY | O_DIRECTORY | O_CLOEXEC);
28182835
if (container->proc_fd < 0)
28192836
return crun_make_error (err, errno, "open `/proc`");

0 commit comments

Comments
 (0)