@@ -320,7 +320,8 @@ func (cs *ControllerServer) copyFromVolume(ctx context.Context, req *csi.CreateV
320
320
if err != nil {
321
321
return status .Error (codes .NotFound , err .Error ())
322
322
}
323
- srcPath := getInternalVolumePath (cs .Driver .workingMountDir , srcVol )
323
+ // Note that the source path must include trailing '/.', can't use 'filepath.Join()' as it performs path cleaning
324
+ srcPath := fmt .Sprintf ("%v/." , getInternalVolumePath (cs .Driver .workingMountDir , srcVol ))
324
325
dstPath := getInternalVolumePath (cs .Driver .workingMountDir , dstVol )
325
326
klog .V (2 ).Infof ("copy volume from volume %v -> %v" , srcPath , dstPath )
326
327
@@ -345,13 +346,12 @@ func (cs *ControllerServer) copyFromVolume(ctx context.Context, req *csi.CreateV
345
346
}
346
347
}()
347
348
348
- // recursive 'cp' with '-a' to handle symlinks. Note that the source path must include trailing '/.',
349
- // which is the reason why 'filepath.Join()' is not used as it would perform path cleaning
350
- out , err := exec .Command ("cp" , "-a" , fmt .Sprintf ("%v%v." , srcPath , filepath .Separator ), dstPath ).CombinedOutput ()
351
- klog .V (2 ).Infof ("copied %s -> %s output: %v" , srcPath , dstPath , string (out ))
349
+ // recursive 'cp' with '-a' to handle symlinks
350
+ out , err := exec .Command ("cp" , "-a" , srcPath , dstPath ).CombinedOutput ()
352
351
if err != nil {
353
- return status .Error (codes .Internal , err . Error ( ))
352
+ return status .Error (codes .Internal , fmt . Sprintf ( "%v: %v" , err , string ( out ) ))
354
353
}
354
+ klog .V (2 ).Infof ("copied %s -> %s output: %v" , srcPath , dstPath )
355
355
return nil
356
356
}
357
357
0 commit comments