mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-29 22:51:35 +02:00
Fix getting zfs pool name with '.' char in freebsd
This commit is contained in:
parent
1b126f55e3
commit
22e64caaff
@ -543,14 +543,16 @@ namespace Mem {
|
|||||||
|
|
||||||
// find all zpools in the system. Do this only at startup.
|
// find all zpools in the system. Do this only at startup.
|
||||||
void get_zpools() {
|
void get_zpools() {
|
||||||
|
std::regex toReplace("\\.");
|
||||||
PipeWrapper poolPipe = PipeWrapper("zpool list -H -o name", "r");
|
PipeWrapper poolPipe = PipeWrapper("zpool list -H -o name", "r");
|
||||||
|
|
||||||
while (not std::feof(poolPipe())) {
|
while (not std::feof(poolPipe())) {
|
||||||
char poolName[512];
|
char poolName[512];
|
||||||
size_t len = 512;
|
size_t len = 512;
|
||||||
if (fgets(poolName, len, poolPipe())) {
|
if (fgets(poolName, len, poolPipe())) {
|
||||||
poolName[strcspn(poolName, "\n")] = 0;
|
poolName[strcspn(poolName, "\n")] = 0;
|
||||||
Logger::debug("zpool found: " + string(poolName));
|
Logger::debug("zpool found: " + string(poolName));
|
||||||
Mem::zpools.push_back(poolName);
|
Mem::zpools.push_back(std::regex_replace(poolName, toReplace, "%25"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -583,7 +585,7 @@ namespace Mem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this code is for ZFS mounts
|
// this code is for ZFS mounts
|
||||||
for (string poolName : Mem::zpools) {
|
for (const auto &poolName : Mem::zpools) {
|
||||||
char sysCtl[1024];
|
char sysCtl[1024];
|
||||||
snprintf(sysCtl, sizeof(sysCtl), "sysctl kstat.zfs.%s.dataset | egrep \'dataset_name|nread|nwritten\'", poolName.c_str());
|
snprintf(sysCtl, sizeof(sysCtl), "sysctl kstat.zfs.%s.dataset | egrep \'dataset_name|nread|nwritten\'", poolName.c_str());
|
||||||
PipeWrapper f = PipeWrapper(sysCtl, "r");
|
PipeWrapper f = PipeWrapper(sysCtl, "r");
|
||||||
|
Loading…
Reference in New Issue
Block a user