File tree Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Expand file tree Collapse file tree 1 file changed +6
-14
lines changed Original file line number Diff line number Diff line change 1
1
package filesystem
2
2
3
3
import (
4
- "fmt"
5
4
"os"
6
5
"path/filepath"
7
6
@@ -112,23 +111,16 @@ func (filesystemAPI) IsSymlink(tgt string) (bool, error) {
112
111
// This code is similar to k8s.io/kubernetes/pkg/util/mount except the pathExists usage.
113
112
// Also in a remote call environment the os error cannot be passed directly back, hence the callers
114
113
// are expected to perform the isExists check before calling this call in CSI proxy.
115
- stat , err := os . Lstat (tgt )
114
+ isSymlink , err := utils . IsPathSymlink (tgt )
116
115
if err != nil {
117
116
return false , err
118
117
}
119
118
120
- // If its a link and it points to an existing file then its a mount point.
121
- if stat .Mode ()& os .ModeSymlink != 0 {
122
- target , err := os .Readlink (tgt )
123
- if err != nil {
124
- return false , fmt .Errorf ("readlink error: %v" , err )
125
- }
126
- exists , err := pathExists (target )
127
- if err != nil {
128
- return false , err
129
- }
130
- return exists , nil
119
+ // mounted folder created by SetVolumeMountPoint may still report ModeSymlink == 0
120
+ mountedFolder , err := utils .IsMountedFolder (tgt )
121
+ if err != nil {
122
+ return false , err
131
123
}
132
124
133
- return false , nil
125
+ return isSymlink || mountedFolder , nil
134
126
}
You can’t perform that action at this time.
0 commit comments