From 53a816b17af4293ed26a0d7bb9f08f161785f40b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 2 Aug 2022 14:57:36 -0700 Subject: [PATCH] fix: readdir fallback on root of the drive (#15457) fixes #15452 --- cmd/os_unix.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/os_unix.go b/cmd/os_unix.go index 96f77f5ff..b9e18e620 100644 --- a/cmd/os_unix.go +++ b/cmd/os_unix.go @@ -232,9 +232,16 @@ func readDirFn(dirPath string, fn func(name string, typ os.FileMode) error) erro // Return count entries at the directory dirPath and all entries // if count is set to -1 func readDirWithOpts(dirPath string, opts readDirOpts) (entries []string, err error) { - f, err := OpenFile(dirPath, readMode, 0) + f, err := OpenFile(dirPath, readMode, 0o666) if err != nil { - return nil, osErrToFileErr(err) + if osIsPermission(err) { + f, err = Open(dirPath) + if err != nil { + return nil, osErrToFileErr(err) + } + } else { + return nil, osErrToFileErr(err) + } } defer f.Close()