mirror of
https://github.com/rvtr/unlaunch-installer_dev.git
synced 2026-01-26 13:43:08 -05:00
Add sd cluster size check
If a sd is present, and its cluster size is bigger than 32k, abort installing
This commit is contained in:
parent
f1d6f13ff2
commit
001442fd8a
@ -200,6 +200,13 @@ int main(int argc, char **argv)
|
||||
messageBox("fatInitDefault()...\x1B[31mFailed\n\x1B[47m");
|
||||
}
|
||||
|
||||
u32 clusterSize = getClusterSizeForPartition("sd:/");
|
||||
if(clusterSize > 32768)
|
||||
{
|
||||
messageBox("Sd card cluster size is too large");
|
||||
return 0;
|
||||
}
|
||||
|
||||
//setup nand access
|
||||
if (!fatMountSimple("nand", &io_dsi_nand))
|
||||
{
|
||||
|
||||
@ -226,3 +226,32 @@ bool removeIfExists(const char* path)
|
||||
{
|
||||
return remove(path) == 0 || errno == ENOENT;
|
||||
}
|
||||
|
||||
// Filesystem type
|
||||
typedef enum {FS_UNKNOWN, FS_FAT12, FS_FAT16, FS_FAT32} FS_TYPE;
|
||||
//trimmed down PARTITION struct from libfat internals
|
||||
typedef struct {
|
||||
const void* disc;
|
||||
void* cache;
|
||||
// Info about the partition
|
||||
FS_TYPE filesysType;
|
||||
uint64_t totalSize;
|
||||
sec_t rootDirStart;
|
||||
uint32_t rootDirCluster;
|
||||
uint32_t numberOfSectors;
|
||||
sec_t dataStart;
|
||||
uint32_t bytesPerSector;
|
||||
uint32_t sectorsPerCluster;
|
||||
uint32_t bytesPerCluster;
|
||||
uint32_t fsInfoSector;
|
||||
} PARTITION;
|
||||
|
||||
extern PARTITION* _FAT_partition_getPartitionFromPath(const char* path);
|
||||
|
||||
u32 getClusterSizeForPartition(const char* path)
|
||||
{
|
||||
PARTITION* p = _FAT_partition_getPartitionFromPath(path);
|
||||
if(!p)
|
||||
return 0;
|
||||
return p->bytesPerCluster;
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ bool safeCreateDir(const char* path);
|
||||
//Files and directories
|
||||
bool removeIfExists(const char* path);
|
||||
|
||||
u32 getClusterSizeForPartition(const char* path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user