Skip to content

Commit 37699cf

Browse files
committed
filter out PCI Bus directories
Signed-off-by: Niclas Schad <niclas.schad@stackit.cloud>
1 parent 482cd1d commit 37699cf

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

pkg/csi/util/mount/mount.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os"
2222
"path"
2323
"path/filepath"
24+
"regexp"
2425
"slices"
2526
"strings"
2627
"time"
@@ -42,6 +43,10 @@ const (
4243
operationFinishSteps = 15
4344
)
4445

46+
var (
47+
pciAddressRegex = regexp.MustCompile(`^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-9a-fA-F]$`)
48+
)
49+
4550
type IMount interface {
4651
Mounter() *mount.SafeFormatAndMount
4752
ScanForAttach(devicePath string) error
@@ -159,8 +164,9 @@ func GetEmptyPCIeRootPorts() (int64, error) {
159164
klog.Errorf("failed to read dir %s : %v", devPath, err2)
160165
}
161166
for _, file := range files {
162-
// PCI addresses always contain a colon
163-
if strings.Contains(file.Name(), ":") {
167+
// Ignore PCI bus directories such as pci001 pci002 and pci010
168+
// Devices must follow <domain:bus:device.function> format
169+
if pciAddressRegex.MatchString(file.Name()) {
164170
hasChild = true
165171
break
166172
}

0 commit comments

Comments
 (0)