@@ -33,19 +33,8 @@ func New() API {
3333	return  filesystemAPI {}
3434}
3535
36- func  pathExists (path  string ) (bool , error ) {
37- 	_ , err  :=  os .Lstat (path )
38- 	if  err  ==  nil  {
39- 		return  true , nil 
40- 	}
41- 	if  os .IsNotExist (err ) {
42- 		return  false , nil 
43- 	}
44- 	return  false , err 
45- }
46- 
4736func  (filesystemAPI ) PathExists (path  string ) (bool , error ) {
48- 	return  pathExists (path )
37+ 	return  utils . PathExists (path )
4938}
5039
5140// PathValid determines whether all elements of a path exist 
@@ -112,18 +101,23 @@ func (filesystemAPI) IsSymlink(tgt string) (bool, error) {
112101	// This code is similar to k8s.io/kubernetes/pkg/util/mount except the pathExists usage. 
113102	// Also in a remote call environment the os error cannot be passed directly back, hence the callers 
114103	// are expected to perform the isExists check before calling this call in CSI proxy. 
115- 	stat , err  :=  os .Lstat (tgt )
104+ 	isSymlink , err  :=  utils .IsPathSymlink (tgt )
105+ 	if  err  !=  nil  {
106+ 		return  false , err 
107+ 	}
108+ 
109+ 	// mounted folder created by SetVolumeMountPoint may still report ModeSymlink == 0 
110+ 	mountedFolder , err  :=  utils .IsMountedFolder (tgt )
116111	if  err  !=  nil  {
117112		return  false , err 
118113	}
119114
120- 	// If its a link and it points to an existing file then its a mount point. 
121- 	if  stat .Mode ()& os .ModeSymlink  !=  0  {
115+ 	if  isSymlink  ||  mountedFolder  {
122116		target , err  :=  os .Readlink (tgt )
123117		if  err  !=  nil  {
124118			return  false , fmt .Errorf ("readlink error: %v" , err )
125119		}
126- 		exists , err  :=  pathExists (target )
120+ 		exists , err  :=  utils . PathExists (target )
127121		if  err  !=  nil  {
128122			return  false , err 
129123		}
0 commit comments