-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rootfs: consolidate mountpoint creation logic #4359
rootfs: consolidate mountpoint creation logic #4359
Conversation
The logic for how we create mountpoints is spread over each mountpoint preparation function, when in reality the behaviour is pretty uniform with only a handful of exceptions. So just move it all to one function that is easier to understand. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
// but properly handling the case where path or root are "/". | ||
// | ||
// NOTE: The return value only make sense if the path doesn't contain "..". | ||
func IsLexicallyInRoot(root, path string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have unit tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with adding them later, if that helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
me := mountEntry{Mount: m} | ||
// For all other filesystems, just make the target. | ||
if _, err := createMountpoint(c.config.Rootfs, me); err != nil { | ||
return fmt.Errorf("create criu restore mountpoint for %s mount: %w", me.Destination, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do we want to use %q for the destination here? It quotes the string, in case it has spaces and so
The logic for how we create mountpoints is spread over each mountpoint preparation function, when in reality the behaviour is pretty uniform with only a handful of exceptions. So just move it all to one function that is easier to understand.
Signed-off-by: Aleksa Sarai cyphar@cyphar.com