Skip to content

Commit

Permalink
Merge pull request aristocratos#602 from jfouquart/main
Browse files Browse the repository at this point in the history
Fix getting zfs pool name with '.' char in freebsd
  • Loading branch information
aristocratos committed Aug 26, 2023
2 parents 9c8af4d + 22e64ca commit 9a1e760
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/freebsd/btop_collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,16 @@ namespace Mem {

// find all zpools in the system. Do this only at startup.
void get_zpools() {
std::regex toReplace("\\.");
PipeWrapper poolPipe = PipeWrapper("zpool list -H -o name", "r");

while (not std::feof(poolPipe())) {
char poolName[512];
size_t len = 512;
if (fgets(poolName, len, poolPipe())) {
poolName[strcspn(poolName, "\n")] = 0;
Logger::debug("zpool found: " + string(poolName));
Mem::zpools.push_back(poolName);
Mem::zpools.push_back(std::regex_replace(poolName, toReplace, "%25"));
}
}
}
Expand Down Expand Up @@ -583,7 +585,7 @@ namespace Mem {
}

// this code is for ZFS mounts
for (string poolName : Mem::zpools) {
for (const auto &poolName : Mem::zpools) {
char sysCtl[1024];
snprintf(sysCtl, sizeof(sysCtl), "sysctl kstat.zfs.%s.dataset | egrep \'dataset_name|nread|nwritten\'", poolName.c_str());
PipeWrapper f = PipeWrapper(sysCtl, "r");
Expand Down

0 comments on commit 9a1e760

Please sign in to comment.