Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ require (
github.com/kubernetes-csi/csi-lib-utils v0.14.1
github.com/kubernetes-csi/csi-proxy/client v1.0.1
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/microsoft/wmi v0.38.3
github.com/onsi/ginkgo/v2 v2.28.0
github.com/onsi/gomega v1.39.1
github.com/pkg/errors v0.9.1
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021
github.com/stretchr/testify v1.11.1
go.uber.org/goleak v1.3.0
Expand Down Expand Up @@ -103,6 +101,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/selinux v1.13.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE=
github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A=
github.com/microsoft/wmi v0.38.3 h1:RVbn+m2jlPRsB2fLADXqabJj/EhMXQbvKM7OYS8VOv0=
github.com/microsoft/wmi v0.38.3/go.mod h1:XF+cfluA15xGnSCYkJIYuj2vWzdm2YrNuvqlC+baWY0=
github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU=
github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
Expand Down
205 changes: 0 additions & 205 deletions pkg/os/cim/wmi.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/os/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ package filesystem

import (
"context"
"errors"
"fmt"
"os"
"regexp"
"strings"

"github.com/pkg/errors"
"golang.org/x/sys/windows"
"k8s.io/klog/v2"
"sigs.k8s.io/azurefile-csi-driver/pkg/util"
Expand Down
59 changes: 33 additions & 26 deletions pkg/os/smb/smb_cim.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ limitations under the License.
package smb

import (
"fmt"

"k8s.io/klog/v2"
"sigs.k8s.io/azurefile-csi-driver/pkg/os/cim"
wmi "sigs.k8s.io/azurefile-csi-driver/pkg/os/wmi"
)

var _ SMBAPI = &cimSMBAPI{}
Expand All @@ -34,43 +36,48 @@ func NewCimSMBAPI() *cimSMBAPI {

func (*cimSMBAPI) IsSmbMapped(remotePath string) (bool, error) {
var isMapped bool
err := cim.WithCOMThread(func() error {
inst, err := cim.QuerySmbGlobalMappingByRemotePath(remotePath)
if err != nil {
klog.V(6).Infof("error querying smb mapping for remote path %s. err: %v", remotePath, err)
return err
}
err := wmi.WithCOMThread(func() error {
return wmi.WithScope(func(scope *wmi.Scope) error {
inst, err := wmi.QuerySmbGlobalMappingByRemotePath(scope, remotePath)
if err != nil {
klog.V(6).Infof("error querying smb mapping for remote path %s. err: %v", remotePath, err)
return err
}

status, err := cim.GetSmbGlobalMappingStatus(inst)
if err != nil {
klog.V(6).Infof("error getting smb mapping status for remote path %s. err: %v", remotePath, err)
return err
}
status, err := wmi.GetSmbGlobalMappingStatus(inst)
if err != nil {
klog.V(6).Infof("error getting smb mapping status for remote path %s. err: %v", remotePath, err)
return err
}

isMapped = status == cim.SmbMappingStatusOK
return nil
isMapped = status == wmi.SmbMappingStatusOK
return nil
})
})
return isMapped, cim.IgnoreNotFound(err)
return isMapped, wmi.IgnoreNotFound(err)
}

func (*cimSMBAPI) NewSmbGlobalMapping(remotePath, username, password string) error {
return cim.WithCOMThread(func() error {
result, err := cim.NewSmbGlobalMapping(remotePath, username, password, true)
requirePrivacy := true
return wmi.WithCOMThread(func() error {
err := wmi.NewSmbGlobalMapping(remotePath, username, password, requirePrivacy)
if err != nil {
klog.V(6).Infof("error creating smb mapping for remote path %s. result %d, err: %v", remotePath, result, err)
return err
klog.V(6).Infof("error creating smb mapping for remote path %s. err: %v", remotePath, err)
return fmt.Errorf("create SMB mapping failed for %s: %w", remotePath, err)
}
return nil
})
}

func (*cimSMBAPI) RemoveSmbGlobalMapping(remotePath string) error {
return cim.WithCOMThread(func() error {
err := cim.RemoveSmbGlobalMappingByRemotePath(remotePath)
if err != nil {
klog.V(6).Infof("error removing smb mapping for remote path %s. err: %v", remotePath, err)
return err
}
return nil
return wmi.WithCOMThread(func() error {
return wmi.WithScope(func(scope *wmi.Scope) error {
err := wmi.RemoveSmbGlobalMappingByRemotePath(scope, remotePath)
if err != nil {
klog.V(6).Infof("error removing smb mapping for remote path %s. err: %v", remotePath, err)
return fmt.Errorf("error remove smb mapping '%s'. err: %w", remotePath, err)
}
return nil
})
})
}
Loading
Loading