Skip to content

[1.5] Pre-open container root directory#5204

Merged
cyphar merged 4 commits intoopencontainers:release-1.5from
kolyshkin:1.5-5190
Mar 31, 2026
Merged

[1.5] Pre-open container root directory#5204
cyphar merged 4 commits intoopencontainers:release-1.5from
kolyshkin:1.5-5190

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

Backport of #5190.


A lot of filesystem-related stuff happens inside the container root
directory, and we have used its name before. It makes sense to pre-open
it and use a *os.File handle instead.

Function names in internal/pathrs are kept as is for simplicity (and it
is an internal package), but they now accept root as *os.File.

This is a somewhat naive attempt at it, but it is surprisingly simple.

kolyshkin and others added 4 commits March 30, 2026 11:12
Indeed, it does not make sense to prepend c.root once we started using
MkdirAllInRoot in commit 63c2908.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 6035252)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
No change in functionality, just a preparation for the next patch.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 78b8067)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
A lot of filesystem-related stuff happens inside the container root
directory, and we have used its name before. It makes sense to pre-open
it and use a *os.File handle instead.

Function names in internal/pathrs are kept as is for simplicity (and it
is an internal package), but they now accept root as *os.File.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 28cb321)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This uses preopened rootfs in Chdir and pivotRoot.

While at it, add O_PATH when opening oldroot in pivotRoot.

Co-authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: lfbzhm <lifubang@acmcoder.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 5b094ed)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin added this to the 1.5.0-rc.2 milestone Mar 30, 2026
@kolyshkin kolyshkin added the backport/1.5-pr A backport PR to release-1.5 label Mar 30, 2026
@cyphar cyphar merged commit 47fc012 into opencontainers:release-1.5 Mar 31, 2026
63 checks passed
@kolyshkin kolyshkin mentioned this pull request Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.5-pr A backport PR to release-1.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants