mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/system/stat_unix: wrap errors in PathError
syscall.Stat (and Lstat), unlike functions from os pkg, return "raw" errors (like EPERM or EINVAL), and those are propagated up the function call stack unchanged, and gets logged and/or returned to the user as is. Wrap those into os.PathError{} so the error message will at least have function name and file name. Note we use Capitalized function names to distinguish between functions in os and ours. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
3e44f58966
commit
8072e62d83
2 changed files with 4 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
package system // import "github.com/docker/docker/pkg/system"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
|
@ -13,7 +14,7 @@ import (
|
|||
func Lstat(path string) (*StatT, error) {
|
||||
s := &syscall.Stat_t{}
|
||||
if err := syscall.Lstat(path, s); err != nil {
|
||||
return nil, err
|
||||
return nil, &os.PathError{"Lstat", path, err}
|
||||
}
|
||||
return fromStatT(s)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
package system // import "github.com/docker/docker/pkg/system"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
|
@ -59,7 +60,7 @@ func (s StatT) IsDir() bool {
|
|||
func Stat(path string) (*StatT, error) {
|
||||
s := &syscall.Stat_t{}
|
||||
if err := syscall.Stat(path, s); err != nil {
|
||||
return nil, err
|
||||
return nil, &os.PathError{"Stat", path, err}
|
||||
}
|
||||
return fromStatT(s)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue