Skip to content

Commit

Permalink
cmds/core/du: clarify error message if no stat_t
Browse files Browse the repository at this point in the history
Signed-off-by: Siarhiej Siemianczuk <[email protected]>
  • Loading branch information
binjip978 committed Aug 20, 2024
1 parent 4c38e06 commit 6795f99
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmds/core/du/du.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package main

import (
"errors"
"fmt"
"io"
"io/fs"
Expand All @@ -16,6 +17,8 @@ import (
"syscall"
)

var errNoStatInfo = errors.New("os.FileInfo has no stat_t info")

func run(stdout io.Writer, files ...string) error {
if len(files) == 0 {
files = append(files, ".")
Expand All @@ -42,7 +45,7 @@ func du(file string) (int64, error) {

st, ok := info.Sys().(*syscall.Stat_t)
if !ok {
return fmt.Errorf("can not stat: %v", path)
return fmt.Errorf("%v: %w", path, errNoStatInfo)
}

blocks += st.Blocks
Expand Down

0 comments on commit 6795f99

Please sign in to comment.