static void init_mbr(BDRVVVFATState* s)

{

    /* TODO: if the files mbr.img and bootsect.img exist, use them */

    mbr_t* real_mbr=(mbr_t*)s->first_sectors;

    partition_t* partition = &(real_mbr->partition[0]);

    int lba;



    memset(s->first_sectors,0,512);



    /* Win NT Disk Signature */

    real_mbr->nt_id= cpu_to_le32(0xbe1afdfa);



    partition->attributes=0x80; /* bootable */



    /* LBA is used when partition is outside the CHS geometry */

    lba = sector2CHS(s->bs, &partition->start_CHS, s->first_sectors_number-1);

    lba|= sector2CHS(s->bs, &partition->end_CHS,   s->sector_count);



    /*LBA partitions are identified only by start/length_sector_long not by CHS*/

    partition->start_sector_long =cpu_to_le32(s->first_sectors_number-1);

    partition->length_sector_long=cpu_to_le32(s->sector_count - s->first_sectors_number+1);



    /* FAT12/FAT16/FAT32 */

    /* DOS uses different types when partition is LBA,

       probably to prevent older versions from using CHS on them */

    partition->fs_type= s->fat_type==12 ? 0x1:

                        s->fat_type==16 ? (lba?0xe:0x06):

                         /*fat_tyoe==32*/ (lba?0xc:0x0b);



    real_mbr->magic[0]=0x55; real_mbr->magic[1]=0xaa;

}

static void init_mbr(BDRVVVFATState* s)

{

    

    mbr_t* real_mbr=(mbr_t*)s->first_sectors;

    partition_t* partition = &(real_mbr->partition[0]);

    int lba;



    memset(s->first_sectors,0,512);



    

    real_mbr->nt_id= cpu_to_le32(0xbe1afdfa);



    partition->attributes=0x80; 



    

    lba = sector2CHS(s->bs, &partition->start_CHS, s->first_sectors_number-1);

    lba|= sector2CHS(s->bs, &partition->end_CHS,   s->sector_count);



    

    partition->start_sector_long =cpu_to_le32(s->first_sectors_number-1);

    partition->length_sector_long=cpu_to_le32(s->sector_count - s->first_sectors_number+1);



    

    



    partition->fs_type= s->fat_type==12 ? 0x1:

                        s->fat_type==16 ? (lba?0xe:0x06):

                          (lba?0xc:0x0b);



    real_mbr->magic[0]=0x55; real_mbr->magic[1]=0xaa;

}

    lba|= sector2CHS(s->bs, &partition->end_CHS,   s->sector_count);     partition->start_sector_long =cpu_to_le32(s->first_sectors_number-1);     partition->length_sector_long=cpu_to_le32(s->sector_count - s->first_sectors_number+1);
static void FUNC_0(BDRVVVFATState* VAR_0)

{

    

    mbr_t* real_mbr=(mbr_t*)VAR_0->first_sectors;

    partition_t* partition = &(real_mbr->partition[0]);

    int VAR_1;



    memset(VAR_0->first_sectors,0,512);



    

    real_mbr->nt_id= cpu_to_le32(0xbe1afdfa);



    partition->attributes=0x80; 



    

    VAR_1 = sector2CHS(VAR_0->bs, &partition->start_CHS, VAR_0->first_sectors_number-1);

    VAR_1|= sector2CHS(VAR_0->bs, &partition->end_CHS,   VAR_0->sector_count);



    

    partition->start_sector_long =cpu_to_le32(VAR_0->first_sectors_number-1);

    partition->length_sector_long=cpu_to_le32(VAR_0->sector_count - VAR_0->first_sectors_number+1);



    

    



    partition->fs_type= VAR_0->fat_type==12 ? 0x1:

                        VAR_0->fat_type==16 ? (VAR_1?0xe:0x06):

                          (VAR_1?0xc:0x0b);



    real_mbr->magic[0]=0x55; real_mbr->magic[1]=0xaa;

}

static void FUNC_0(BDRVVVFATState* VAR_0)
{ mbr_t* real_mbr=(mbr_t*)VAR_0->first_sectors; partition_t* partition = &(real_mbr->partition[0]); int VAR_1; memset(VAR_0->first_sectors,0,512); real_mbr->nt_id= cpu_to_le32(0xbe1afdfa); partition->attributes=0x80; VAR_1 = sector2CHS(VAR_0->bs, &partition->start_CHS, VAR_0->first_sectors_number-1); VAR_1|= sector2CHS(VAR_0->bs, &partition->end_CHS,   VAR_0->sector_count); partition->start_sector_long =cpu_to_le32(VAR_0->first_sectors_number-1); partition->length_sector_long=cpu_to_le32(VAR_0->sector_count - VAR_0->first_sectors_number+1); partition->fs_type= VAR_0->fat_type==12 ? 0x1:
VAR_0->fat_type==16 ? (VAR_1?0xe:0x06):
(VAR_1?0xc:0x0b); real_mbr->magic[0]=0x55; real_mbr->magic[1]=0xaa; }