fat32_get_free_count() and fat32_get_next_free() - code style
This commit is contained in:
parent
1398b863c2
commit
ccc47d5bf2
2 changed files with 14 additions and 2 deletions
|
@ -747,12 +747,14 @@ int comp_FAT(disk_t *disk, const partition_t *partition, const unsigned long int
|
|||
|
||||
unsigned long int fat32_get_free_count(const unsigned char *boot_fat32, const unsigned int sector_size)
|
||||
{
|
||||
return (boot_fat32[sector_size+0x1E8+3]<<24)+(boot_fat32[sector_size+0x1E8+2]<<16)+(boot_fat32[sector_size+0x1E8+1]<<8)+boot_fat32[sector_size+0x1E8];
|
||||
const struct fat_fsinfo *fsinfo=(const struct fat_fsinfo *)&boot_fat32[sector_size];
|
||||
return le32(fsinfo->freecnt);
|
||||
}
|
||||
|
||||
unsigned long int fat32_get_next_free(const unsigned char *boot_fat32, const unsigned int sector_size)
|
||||
{
|
||||
return (boot_fat32[sector_size+0x1EC+3]<<24)+(boot_fat32[sector_size+0x1EC+2]<<16)+(boot_fat32[sector_size+0x1EC+1]<<8)+boot_fat32[sector_size+0x1EC];
|
||||
const struct fat_fsinfo *fsinfo=(const struct fat_fsinfo *)&boot_fat32[sector_size];
|
||||
return le32(fsinfo->nextfree);
|
||||
}
|
||||
|
||||
int recover_FAT(disk_t *disk_car, const struct fat_boot_sector*fat_header, partition_t *partition, const int verbose, const int dump_ind, const int backup)
|
||||
|
|
10
src/fat.h
10
src/fat.h
|
@ -75,6 +75,16 @@ struct fat_boot_sector {
|
|||
uint16_t marker;
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
struct fat_fsinfo {
|
||||
uint32_t leadsig; /* 0x41615252 */
|
||||
uint8_t reserved1[480];
|
||||
uint32_t strucsig; /* 0x61417272 */
|
||||
uint32_t freecnt; /* free clusters 0xfffffffff if unknown */
|
||||
uint32_t nextfree; /* next free cluster */
|
||||
uint8_t reserved3[12];
|
||||
uint32_t magic3; /* 0xAA550000 */
|
||||
} __attribute__ ((__packed__));
|
||||
|
||||
struct msdos_dir_entry {
|
||||
int8_t name[8],ext[3]; /* 00 name and extension */
|
||||
uint8_t attr; /* 0B attribute bits */
|
||||
|
|
Loading…
Reference in a new issue