Skip to content

Commit 42e14bb

Browse files
committed
pathrs: rename MkdirAllInRootOpen -> MkdirAllInRoot
Now that MkdirAllInRoot has been removed, we can make MkdirAllInRootOpen less wordy by renaming it to MkdirAllInRoot. This is a non-functional change. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 3bfad05 commit 42e14bb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

internal/pathrs/mkdirall_pathrslite.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"golang.org/x/sys/unix"
2929
)
3030

31-
// MkdirAllInRootOpen attempts to make
31+
// MkdirAllInRoot attempts to make
3232
//
3333
// path, _ := securejoin.SecureJoin(root, unsafePath)
3434
// os.MkdirAll(path, mode)
@@ -49,10 +49,10 @@ import (
4949
// handling if unsafePath has already been scoped within the rootfs (this is
5050
// needed for a lot of runc callers and fixing this would require reworking a
5151
// lot of path logic).
52-
func MkdirAllInRootOpen(root, unsafePath string, mode os.FileMode) (*os.File, error) {
52+
func MkdirAllInRoot(root, unsafePath string, mode os.FileMode) (*os.File, error) {
5353
// If the path is already "within" the root, get the path relative to the
5454
// root and use that as the unsafe path. This is necessary because a lot of
55-
// MkdirAllInRootOpen callers have already done SecureJoin, and refactoring
55+
// MkdirAllInRoot callers have already done SecureJoin, and refactoring
5656
// all of them to stop using these SecureJoin'd paths would require a fair
5757
// amount of work.
5858
// TODO(cyphar): Do the refactor to libpathrs once it's ready.

internal/pathrs/root_pathrslite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func CreateInRoot(root, subpath string, flags int, fileMode uint32) (*os.File, e
5555
return nil, fmt.Errorf("create in root subpath %q has bad trailing component %q", subpath, filename)
5656
}
5757

58-
dirFd, err := MkdirAllInRootOpen(root, dir, 0o755)
58+
dirFd, err := MkdirAllInRoot(root, dir, 0o755)
5959
if err != nil {
6060
return nil, err
6161
}

libcontainer/rootfs_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func mountCgroupV1(m mountEntry, c *mountConfig) error {
332332
// TODO: Why not just use b.Destination (c.root is the root here)?
333333
subsystemPath := filepath.Join(c.root, b.Destination)
334334
subsystemName := filepath.Base(b.Destination)
335-
subsystemDir, err := pathrs.MkdirAllInRootOpen(c.root, subsystemPath, 0o755)
335+
subsystemDir, err := pathrs.MkdirAllInRoot(c.root, subsystemPath, 0o755)
336336
if err != nil {
337337
return err
338338
}
@@ -561,7 +561,7 @@ func (m *mountEntry) createOpenMountpoint(rootfs string) (Err error) {
561561
if dstIsFile {
562562
dstFile, err = pathrs.CreateInRoot(rootfs, unsafePath, unix.O_CREAT|unix.O_EXCL|unix.O_NOFOLLOW, 0o644)
563563
} else {
564-
dstFile, err = pathrs.MkdirAllInRootOpen(rootfs, unsafePath, 0o755)
564+
dstFile, err = pathrs.MkdirAllInRoot(rootfs, unsafePath, 0o755)
565565
}
566566
if err != nil {
567567
return fmt.Errorf("make mountpoint %q: %w", m.Destination, err)
@@ -617,7 +617,7 @@ func mountToRootfs(c *mountConfig, m mountEntry) error {
617617
} else if !fi.IsDir() {
618618
return fmt.Errorf("filesystem %q must be mounted on ordinary directory", m.Device)
619619
}
620-
dstFile, err := pathrs.MkdirAllInRootOpen(rootfs, dest, 0o755)
620+
dstFile, err := pathrs.MkdirAllInRoot(rootfs, dest, 0o755)
621621
if err != nil {
622622
return err
623623
}
@@ -994,7 +994,7 @@ func createDeviceNode(rootfs string, node *devices.Device, bind bool) error {
994994
return fmt.Errorf("%w: mknod over rootfs", errRootfsToFile)
995995
}
996996
destDirPath, destName := filepath.Split(destPath)
997-
destDir, err := pathrs.MkdirAllInRootOpen(rootfs, destDirPath, 0o755)
997+
destDir, err := pathrs.MkdirAllInRoot(rootfs, destDirPath, 0o755)
998998
if err != nil {
999999
return fmt.Errorf("mkdir parent of device inode %q: %w", node.Path, err)
10001000
}

0 commit comments

Comments
 (0)