Skip to content

Commit 3df7c1e

Browse files
Merge pull request #121881 from cji/5528
Use golang library instead of mklink Kubernetes-commit: 620bc81d9780d27a94621922fc855e561f274b45
2 parents c834cde + d888029 commit 3df7c1e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mount_windows.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ func (mounter *Mounter) MountSensitive(source string, target string, fstype stri
150150
mklinkSource = mklinkSource + "\\"
151151
}
152152

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

160160
return nil
161161
}
@@ -219,8 +219,9 @@ func removeSMBMapping(remotepath string) (string, error) {
219219
func (mounter *Mounter) Unmount(target string) error {
220220
klog.V(4).Infof("Unmount target (%q)", target)
221221
target = NormalizeWindowsPath(target)
222-
if output, err := exec.Command("cmd", "/c", "rmdir", target).CombinedOutput(); err != nil {
223-
klog.Errorf("rmdir failed: %v, output: %q", err, string(output))
222+
223+
if err := os.Remove(target); err != nil {
224+
klog.Errorf("removing directory %s failed: %v", target, err)
224225
return err
225226
}
226227
return nil

0 commit comments

Comments
 (0)