2022-10-06 22:56:56 +08:00
|
|
|
#include "disk.h"
|
|
|
|
|
|
2023-06-12 22:09:52 +08:00
|
|
|
const char* ffDetectDisksImpl(FFlist* disks);
|
2022-10-06 22:56:56 +08:00
|
|
|
|
2022-10-17 13:19:48 +02:00
|
|
|
static int compareDisks(const void* disk1, const void* disk2)
|
2022-10-06 22:56:56 +08:00
|
|
|
{
|
2022-10-17 13:19:48 +02:00
|
|
|
return ffStrbufCompAlphabetically(&((const FFDisk*) disk1)->mountpoint, &((const FFDisk*) disk2)->mountpoint);
|
2022-10-06 22:56:56 +08:00
|
|
|
}
|
|
|
|
|
|
2023-06-12 22:09:52 +08:00
|
|
|
const char* ffDetectDisks(FFlist* disks)
|
2022-10-06 22:56:56 +08:00
|
|
|
{
|
2023-06-12 22:09:52 +08:00
|
|
|
const char* error = ffDetectDisksImpl(disks);
|
2022-10-06 22:56:56 +08:00
|
|
|
|
2023-06-12 22:09:52 +08:00
|
|
|
if (error) return error;
|
|
|
|
|
if (disks->length == 0) return "No disks found";
|
2022-10-06 22:56:56 +08:00
|
|
|
|
2023-06-12 22:09:52 +08:00
|
|
|
//We need to sort the disks, so that we can detect, which disk a path resides on
|
|
|
|
|
// For example for /boot/efi/bootmgr we need to check /boot/efi before /boot
|
|
|
|
|
//Note that we sort alphabetically here for a better ordering when printing the list,
|
|
|
|
|
// so the check must be done in reverse order
|
|
|
|
|
ffListSort(disks, compareDisks);
|
|
|
|
|
FF_LIST_FOR_EACH(FFDisk, disk, *disks)
|
|
|
|
|
{
|
|
|
|
|
if(disk->bytesTotal == 0)
|
|
|
|
|
disk->type |= FF_DISK_TYPE_UNKNOWN_BIT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
2022-10-06 22:56:56 +08:00
|
|
|
}
|