Skip to content

Commit

Permalink
Merge pull request kubernetes#121881 from cji/5528
Browse files Browse the repository at this point in the history
Use golang library instead of mklink
  • Loading branch information
k8s-ci-robot committed Nov 14, 2023
2 parents 58d0853 + 2d91281 commit 620bc81
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions staging/src/k8s.io/mount-utils/mount_windows.go
Expand Up @@ -150,12 +150,12 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
mklinkSource = mklinkSource + "\\"
}

output, err := exec.Command("cmd", "/c", "mklink", "/D", target, mklinkSource).CombinedOutput()
err := os.Symlink(mklinkSource, target)
if err != nil {
klog.Errorf("mklink failed: %v, source(%q) target(%q) output: %q", err, mklinkSource, target, string(output))
klog.Errorf("symlink failed: %v, source(%q) target(%q)", err, mklinkSource, target)
return err
}
klog.V(2).Infof("mklink source(%q) on target(%q) successfully, output: %q", mklinkSource, target, string(output))
klog.V(2).Infof("symlink source(%q) on target(%q) successfully", mklinkSource, target)

return nil
}
Expand Down Expand Up @@ -219,8 +219,9 @@ func removeSMBMapping(remotepath string) (string, error) {
func (mounter *Mounter) Unmount(target string) error {
klog.V(4).Infof("Unmount target (%q)", target)
target = NormalizeWindowsPath(target)
if output, err := exec.Command("cmd", "/c", "rmdir", target).CombinedOutput(); err != nil {
klog.Errorf("rmdir failed: %v, output: %q", err, string(output))

if err := os.Remove(target); err != nil {
klog.Errorf("removing directory %s failed: %v", target, err)
return err
}
return nil
Expand Down

0 comments on commit 620bc81

Please sign in to comment.