diff --git a/cmd/metacache-walk.go b/cmd/metacache-walk.go index 010658ac5..938551ddc 100644 --- a/cmd/metacache-walk.go +++ b/cmd/metacache-walk.go @@ -58,7 +58,7 @@ type WalkDirOptions struct { // WalkDir will traverse a directory and return all entries found. // On success a sorted meta cache stream will be returned. // Metadata has data stripped, if any. -func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writer) error { +func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writer) (err error) { // Verify if volume is valid and it exists. volumeDir, err := s.getVolDir(opts.Bucket) if err != nil { @@ -100,7 +100,7 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ metadata: metadata, } } else { - if st, err := os.Lstat(pathJoin(volumeDir, opts.BaseDir, xlStorageFormatFile)); err == nil && st.Mode().IsRegular() { + if st, err := Lstat(pathJoin(volumeDir, opts.BaseDir, xlStorageFormatFile)); err == nil && st.Mode().IsRegular() { return errFileNotFound } } @@ -272,7 +272,7 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ } func (p *xlStorageDiskIDCheck) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writer) error { - defer p.updateStorageMetrics(storageMetricWalkDir)() + defer p.updateStorageMetrics(storageMetricWalkDir, opts.Bucket, opts.BaseDir)() if err := p.checkDiskStale(); err != nil { return err } diff --git a/cmd/os-readdir_unix.go b/cmd/os-readdir_unix.go index a77d75b44..7f24734e2 100644 --- a/cmd/os-readdir_unix.go +++ b/cmd/os-readdir_unix.go @@ -107,7 +107,7 @@ func readDir(dirPath string) (entries []string, err error) { // the directory itself, if the dirPath doesn't exist this function doesn't return // an error. func readDirFn(dirPath string, fn func(name string, typ os.FileMode) error) error { - f, err := os.Open(dirPath) + f, err := Open(dirPath) if err != nil { if osErrToFileErr(err) == errFileNotFound { return nil @@ -185,7 +185,7 @@ 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 readDirN(dirPath string, count int) (entries []string, err error) { - f, err := os.Open(dirPath) + f, err := Open(dirPath) if err != nil { return nil, osErrToFileErr(err) } @@ -229,7 +229,7 @@ func readDirN(dirPath string, count int) (entries []string, err error) { // support Dirent.Type and have DT_UNKNOWN (0) there // instead. if typ == unexpectedFileMode || typ&os.ModeSymlink == os.ModeSymlink { - fi, err := os.Stat(pathJoin(dirPath, string(name))) + fi, err := Stat(pathJoin(dirPath, string(name))) if err != nil { // It got deleted in the meantime, not found // or returns too many symlinks ignore this diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index a33daefb0..73b04d705 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -393,7 +393,7 @@ func (s *xlStorage) Healing() *healingTracker { } func (s *xlStorage) readMetadata(itemPath string) ([]byte, error) { - f, err := os.OpenFile(itemPath, readMode, 0) + f, err := OpenFile(itemPath, readMode, 0) if err != nil { return nil, err }