heim icon indicating copy to clipboard operation
heim copied to clipboard

heim-cpu: fix glob pattern to support more than 10 cpus

Open kaspar030 opened this issue 2 years ago • 0 comments

The previous glob pattern matched only single-digit CPU numbers. I stumbled across this because vector was not showing more than 10 (the ones that match 0-9) physical cpus using its "host_metrics" source.

As fix, the glob pattern is changed to this: devices/system/cpu/cpu*/topology/core_id.

Unfortunately glob::glob() doesn't support "one or more of this character" like a regex would. So this fix only works until linux adds files that match cpu*/topology/core_id but not cpu[0-9]+/topology/core_id. I consider that highly unlikely. But I there are ways to ensure this never bites us:

  • add a regex to filter the glob results
  • concatenate three globs: .../cpu[0]/..., .../cpu[0]/... and .../cpu[0][0][0]/...
  • added later switch to the globset crate, and add those three globs to a globset
  • other suggestions?

kaspar030 avatar Mar 02 '23 10:03 kaspar030