From d154f8d021377563f658d36226624d138bebd5af Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 12 Apr 2018 12:32:46 +0000 Subject: [PATCH] fix nsenter GetFileType issue use outputBytes as return error --- pkg/util/mount/nsenter_mount.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/util/mount/nsenter_mount.go b/pkg/util/mount/nsenter_mount.go index dd2ad3c640..b887b1a3ef 100644 --- a/pkg/util/mount/nsenter_mount.go +++ b/pkg/util/mount/nsenter_mount.go @@ -235,8 +235,13 @@ func (n *NsenterMounter) MakeRShared(path string) error { func (mounter *NsenterMounter) GetFileType(pathname string) (FileType, error) { var pathType FileType - outputBytes, err := mounter.ne.Exec("stat", []string{"-L", `--printf "%F"`, pathname}).CombinedOutput() + outputBytes, err := mounter.ne.Exec("stat", []string{"-L", "--printf=%F", pathname}).CombinedOutput() if err != nil { + if strings.Contains(string(outputBytes), "No such file") { + err = fmt.Errorf("%s does not exist", pathname) + } else { + err = fmt.Errorf("stat %s error: %v", pathname, string(outputBytes)) + } return pathType, err }