syscallcompat: OpenNofollow: fix relPath="" case
Sometimes want to open baseDir itself. This case was broken, fix it.
This commit is contained in:
parent
47b13e0a8d
commit
e604ce6dea
@ -27,6 +27,10 @@ func OpenNofollow(baseDir string, relPath string, flags int, mode uint32) (fd in
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
// Caller wanted to open baseDir itself?
|
||||
if relPath == "" {
|
||||
return dirfd, nil
|
||||
}
|
||||
// Split the path into components and separate intermediate directories
|
||||
// and the final basename
|
||||
parts := strings.Split(relPath, "/")
|
||||
|
@ -34,4 +34,11 @@ func TestOpenNofollow(t *testing.T) {
|
||||
if err != syscall.ELOOP {
|
||||
t.Errorf("expected ELOOP, got %v", err)
|
||||
}
|
||||
// Check to see that the base dir can be opened as well
|
||||
fd, err = OpenNofollow(tmpDir, "", syscall.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
t.Errorf("cannot open base dir: %v", err)
|
||||
} else {
|
||||
syscall.Close(fd)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user