Don't show subvolumes by default

This commit is contained in:
Linus Dierheimer
2023-01-16 11:52:54 +01:00
parent ab7b0571f3
commit b1ccd2e2c0
10 changed files with 74 additions and 55 deletions
+29 -12
View File
@@ -28,6 +28,21 @@ static void strbufAppendMountPoint(FFstrbuf* mountpoint, const char* source)
}
}
#ifndef __ANDROID__
static bool isSubvolume(const char* options)
{
const char* prefix = "subvol=/@"; //Btrfs subvolume
const char* subvolume = strstr(options, prefix);
if(subvolume == NULL)
return false;
subvolume += strlen(prefix);
//If there is no space or comma after the @, it is a btrfs subvolume
return *subvolume != ' ' && *subvolume != ',';
}
#endif
void ffDetectDisksImpl(FFDiskResult* disks)
{
FILE* mountsFile = fopen("/proc/mounts", "r");
@@ -82,19 +97,21 @@ void ffDetectDisksImpl(FFDiskResult* disks)
++currentPos;
#ifdef __ANDROID__
if(ffStrbufEqualS(&disk->mountpoint, "/") || ffStrbufEqualS(&disk->mountpoint, "/storage/emulated"))
disk->type = FF_DISK_TYPE_REGULAR;
else if(ffStrbufStartsWithS(&disk->mountpoint, "/mnt/media_rw/"))
disk->type = FF_DISK_TYPE_EXTERNAL;
else
disk->type = FF_DISK_TYPE_HIDDEN;
if(ffStrbufEqualS(&disk->mountpoint, "/") || ffStrbufEqualS(&disk->mountpoint, "/storage/emulated"))
disk->type = FF_DISK_TYPE_REGULAR;
else if(ffStrbufStartsWithS(&disk->mountpoint, "/mnt/media_rw/"))
disk->type = FF_DISK_TYPE_EXTERNAL;
else
disk->type = FF_DISK_TYPE_HIDDEN;
#else
if(strstr(currentPos, "nosuid") != NULL || strstr(currentPos, "nodev") != NULL)
disk->type = FF_DISK_TYPE_EXTERNAL;
else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi"))
disk->type = FF_DISK_TYPE_HIDDEN;
else
disk->type = FF_DISK_TYPE_REGULAR;
if(isSubvolume(currentPos))
disk->type = FF_DISK_TYPE_SUBVOLUME;
else if(strstr(currentPos, "nosuid") != NULL || strstr(currentPos, "nodev") != NULL)
disk->type = FF_DISK_TYPE_EXTERNAL;
else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi"))
disk->type = FF_DISK_TYPE_HIDDEN;
else
disk->type = FF_DISK_TYPE_REGULAR;
#endif
//Detects stats