2009-12-04 16:05:20 +01:00
|
|
|
#ifndef _PARTITION_H_
|
2009-05-03 20:53:31 +02:00
|
|
|
#define _PARTITION_H_
|
|
|
|
|
2009-12-04 16:05:20 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* 'partition entry' structure */
|
|
|
|
typedef struct {
|
|
|
|
/* Boot indicator */
|
|
|
|
u8 boot;
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Starting CHS */
|
|
|
|
u8 start[3];
|
2009-12-04 16:05:20 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Partition type */
|
|
|
|
u8 type;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Ending CHS */
|
|
|
|
u8 end[3];
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Partition sector */
|
|
|
|
u32 sector;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Partition size */
|
|
|
|
u32 size;
|
|
|
|
} ATTRIBUTE_PACKED partitionEntry;
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Constants */
|
2009-12-04 16:05:20 +01:00
|
|
|
#define MAX_PARTITIONS 4
|
|
|
|
#define MAX_PARTITIONS_EX 10
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2009-12-04 16:05:20 +01:00
|
|
|
#define FS_TYPE_UNK 0
|
|
|
|
#define FS_TYPE_FAT16 1
|
|
|
|
#define FS_TYPE_FAT32 2
|
|
|
|
#define FS_TYPE_NTFS 3
|
|
|
|
#define FS_TYPE_WBFS 4
|
2009-11-15 20:52:58 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-02-15 00:22:52 +01:00
|
|
|
u8 fs_type;
|
|
|
|
u8 part_fs;
|
|
|
|
u8 wbfs_i; // seq wbfs part index
|
|
|
|
u8 fat_i; // seq fat part index
|
|
|
|
u8 ntfs_i; // seq ntfs part index
|
|
|
|
u8 index;
|
2010-02-09 11:59:55 +01:00
|
|
|
} PartInfo;
|
2009-11-15 20:52:58 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
2010-02-15 00:22:52 +01:00
|
|
|
u8 num;
|
2010-02-09 11:59:55 +01:00
|
|
|
u32 sector_size;
|
|
|
|
partitionEntry pentry[MAX_PARTITIONS_EX];
|
2010-02-15 00:22:52 +01:00
|
|
|
u8 wbfs_n;
|
|
|
|
u8 fat_n;
|
|
|
|
u8 ntfs_n;
|
2010-02-09 11:59:55 +01:00
|
|
|
PartInfo pinfo[MAX_PARTITIONS_EX];
|
|
|
|
} PartList;
|
2009-11-15 20:52:58 +01:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
/* Prototypes */
|
|
|
|
s32 Partition_GetEntries(u32 device, partitionEntry *outbuf, u32 *outval);
|
2010-02-15 00:22:52 +01:00
|
|
|
s32 Partition_GetEntriesEx(u32 device, partitionEntry *outbuf, u32 *outval, u8 *num);
|
2010-02-09 11:59:55 +01:00
|
|
|
bool Device_ReadSectors(u32 device, u32 sector, u32 count, void *buffer);
|
|
|
|
bool Device_WriteSectors(u32 device, u32 sector, u32 count, void *buffer);
|
|
|
|
s32 Partition_GetList(u32 device, PartList *plist);
|
2010-02-15 00:22:52 +01:00
|
|
|
int Partition_FixEXT(u32 device, u8 part);
|
2009-05-03 20:53:31 +02:00
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
bool part_is_extended(int type);
|
|
|
|
bool part_is_data(int type);
|
|
|
|
char* part_type_data(int type);
|
|
|
|
char* part_type_name(int type);
|
|
|
|
bool part_valid_data(partitionEntry *entry);
|
|
|
|
int get_fs_type(void *buf);
|
|
|
|
bool is_type_fat(int type);
|
|
|
|
char* get_fs_name(int i);
|
2009-07-30 07:41:12 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2009-05-03 20:53:31 +02:00
|
|
|
|
|
|
|
#endif
|