Skip to content

Commit a4941ad

Browse files
committed
utils: use fsopen to open reference to proc
Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent 0f3b1ce commit a4941ad

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/libcrun/utils.c

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

0 commit comments

Comments
 (0)