Skip to content

Commit

Permalink
fixup! mkdirall: add openat2 support
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Jun 26, 2024
1 parent 2f76de6 commit 9766756
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openat2_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func partialOpenat2(root, unsafePath string) (*os.File, string, error) {
return nil, "", fmt.Errorf("openat2: %w", unix.ENOTSUP)
}

rootFile, err := os.OpenFile(root, unix.O_PATH|unix.O_NOFOLLOW|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
rootDir, err := os.OpenFile(root, unix.O_PATH|unix.O_DIRECTORY|unix.O_CLOEXEC, 0)
if err != nil {
return nil, "", fmt.Errorf("open root: %w", err)
}
Expand All @@ -76,7 +76,7 @@ func partialOpenat2(root, unsafePath string) (*os.File, string, error) {
subpath := unsafePath[:endIdx]

var err error
handle, err := openat2File(rootFile, subpath, &unix.OpenHow{
handle, err := openat2File(rootDir, subpath, &unix.OpenHow{
Flags: unix.O_PATH | unix.O_NOFOLLOW | unix.O_DIRECTORY | unix.O_CLOEXEC,
Resolve: unix.RESOLVE_IN_ROOT | unix.RESOLVE_NO_MAGICLINKS,
})
Expand All @@ -92,5 +92,5 @@ func partialOpenat2(root, unsafePath string) (*os.File, string, error) {
endIdx = strings.LastIndexByte(subpath, '/')
}
// If we couldn't open anything, the whole subpath is missing.
return rootFile, unsafePath, nil
return rootDir, unsafePath, nil
}

0 comments on commit 9766756

Please sign in to comment.