Skip to content

Commit 8bb3fbb

Browse files
committed
Ensure IsSymlink works on Windows mount point
1 parent a63a4ec commit 8bb3fbb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg/os/filesystem/api.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ func (filesystemAPI) IsSymlink(tgt string) (bool, error) {
112112
// This code is similar to k8s.io/kubernetes/pkg/util/mount except the pathExists usage.
113113
// Also in a remote call environment the os error cannot be passed directly back, hence the callers
114114
// are expected to perform the isExists check before calling this call in CSI proxy.
115-
stat, err := os.Lstat(tgt)
115+
isSymlink, err := utils.IsPathSymlink(tgt)
116116
if err != nil {
117117
return false, err
118118
}
119119

120-
// If its a link and it points to an existing file then its a mount point.
121-
if stat.Mode()&os.ModeSymlink != 0 {
120+
// mounted folder created by SetVolumeMountPoint may still report ModeSymlink == 0
121+
mountedFolder, err := utils.IsMountedFolder(tgt)
122+
if err != nil {
123+
return false, err
124+
}
125+
126+
if isSymlink || mountedFolder {
122127
target, err := os.Readlink(tgt)
123128
if err != nil {
124129
return false, fmt.Errorf("readlink error: %v", err)

0 commit comments

Comments
 (0)