Skip to content

Commit 954b839

Browse files
authored
Merge pull request #304 from jgehrcke/jp/regex-fun
Fix /proc/devices parsing regex
2 parents f7fc619 + 8eb531b commit 954b839

File tree

1 file changed

+3
-1
lines changed
  • cmd/compute-domain-kubelet-plugin

1 file changed

+3
-1
lines changed

cmd/compute-domain-kubelet-plugin/nvlib.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ func (l deviceLib) getDeviceMajor(name string) (int, error) {
237237
// Extract the number as capture group (the first and only group).
238238
"(?s)Character devices:.*?" +
239239
"([0-9]+) " + regexp.QuoteMeta(name) +
240-
".*Block devices:",
240+
// Require `name` to be newline-terminated (to not match on a device
241+
// that has `name` as prefix).
242+
"\n.*Block devices:",
241243
)
242244

243245
data, err := os.ReadFile(procDevicesPath)

0 commit comments

Comments
 (0)