Correctly handle zfs pools

#413
This commit is contained in:
Linus Dierheimer
2023-02-01 15:56:25 +01:00
parent 619ec921ee
commit a063cd4feb
22 changed files with 74 additions and 19 deletions
+12
View File
@@ -1,5 +1,7 @@
#include "disk.h"
#include "util/stringUtils.h"
#include <limits.h>
#include <ctype.h>
#include <dirent.h>
@@ -19,6 +21,10 @@ static bool isPhysicalDevice(const char* device)
if(strcmp(device, "drvfs") == 0)
return true;
//ZFS root pool. The format is rpool/<POOL_NAME>/<VOLUME_NAME>/<SUBVOLUME_NAME>
if(strncmp(device, "rpool/", 6) == 0)
return true;
//Pseudo filesystems don't have a device in /dev
const char* devPrefix = "/dev/";
if(strncmp(device, devPrefix, strlen(devPrefix)) != 0)
@@ -141,6 +147,7 @@ static bool isSubvolume(const FFlist* devices)
{
const FFstrbuf* currentDevie = ffListGet(devices, devices->length - 1);
//Filter all disks which device was already found. This catches BTRFS subvolumes.
for(uint32_t i = 0; i < devices->length - 1; i++)
{
const FFstrbuf* otherDevice = ffListGet(devices, i);
@@ -149,6 +156,11 @@ static bool isSubvolume(const FFlist* devices)
return true;
}
//ZFS subvolumes: rpool/<POOL_NAME>/<VOLUME_NAME>/<SUBVOLUME_NAME>.
//Test if the third slash is present.
if(strncmp(currentDevie->chars, "rpool/", 6) == 0 && ffStrHasNChars(currentDevie->chars, '/', 3))
return true;
return false;
}