Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3938375 in mainline


Ignore:
Timestamp:
2012-02-22T19:43:46Z (8 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
master
Children:
b0fecad
Parents:
9587b37
Message:

mkexfat: Fix comments and structure names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkexfat/mkexfat.c

    r9587b37 r3938375  
    5959#define EBS_BACKUP_SECTOR_START 13
    6060
    61 /** First sector of the VBR */
    62 #define VBR_SECTOR 0
    63 
    64 /** First sector if the VBR Backup */
    65 #define VBR_BACKUP_SECTOR 12
     61/** First sector of the Main Boot Sector */
     62#define MBS_SECTOR 0
     63
     64/** First sector of the Main Boot Sector Backup */
     65#define MBS_BACKUP_SECTOR 12
    6666
    6767/** Size of the Main Extended Boot Region */
     
    159159}
    160160
    161 /** Initialize the Volume Boot Record fields.
    162  *
    163  * @param vbr Pointer to the Volume Boot Record structure.
     161/** Initialize the Main Boot Sector fields.
     162 *
     163 * @param mbs Pointer to the Main Boot Sector structure.
    164164 * @param cfg Pointer to the exFAT configuration structure.
    165165 * @return    Initial checksum value.
    166166 */
    167167static uint32_t
    168 vbr_initialize(exfat_bs_t *vbr, exfat_cfg_t *cfg)
     168vbr_initialize(exfat_bs_t *mbs, exfat_cfg_t *cfg)
    169169{
    170170        /* Fill the structure with zeroes */
    171         memset(vbr, 0, sizeof(exfat_bs_t));
     171        memset(mbs, 0, sizeof(exfat_bs_t));
    172172
    173173        /* Init Jump Boot section */
    174         vbr->jump[0] = 0xEB;
    175         vbr->jump[1] = 0x76;
    176         vbr->jump[2] = 0x90;
     174        mbs->jump[0] = 0xEB;
     175        mbs->jump[1] = 0x76;
     176        mbs->jump[2] = 0x90;
    177177
    178178        /* Set the filesystem name */
    179         memcpy(vbr->oem_name, "EXFAT   ", sizeof(vbr->oem_name));
    180 
    181         vbr->volume_start = host2uint64_t_le(cfg->volume_start);
    182         vbr->volume_count = host2uint64_t_le(cfg->volume_count);
    183         vbr->fat_sector_start = host2uint32_t_le(FAT_SECTOR_START);
    184         vbr->fat_sector_count = host2uint32_t_le(cfg->fat_sector_count);
    185         vbr->data_start_sector = host2uint32_t_le(cfg->data_start_sector);
    186 
    187         vbr->data_clusters = host2uint32_t_le(cfg->total_clusters -
     179        memcpy(mbs->oem_name, "EXFAT   ", sizeof(mbs->oem_name));
     180
     181        mbs->volume_start = host2uint64_t_le(cfg->volume_start);
     182        mbs->volume_count = host2uint64_t_le(cfg->volume_count);
     183        mbs->fat_sector_start = host2uint32_t_le(FAT_SECTOR_START);
     184        mbs->fat_sector_count = host2uint32_t_le(cfg->fat_sector_count);
     185        mbs->data_start_sector = host2uint32_t_le(cfg->data_start_sector);
     186
     187        mbs->data_clusters = host2uint32_t_le(cfg->total_clusters -
    188188            div_round_up(cfg->data_start_sector, cfg->cluster_size));
    189189
    190         vbr->rootdir_cluster = 0;
    191         vbr->volume_serial = 0;
    192         vbr->version.major = 1;
    193         vbr->version.minor = 0;
    194         vbr->volume_flags = host2uint16_t_le(0);
    195         vbr->bytes_per_sector = log2(cfg->sector_size);
    196         vbr->sec_per_cluster = log2(cfg->cluster_size / cfg->sector_size);
     190        mbs->rootdir_cluster = 0;
     191        mbs->volume_serial = 0;
     192        mbs->version.major = 1;
     193        mbs->version.minor = 0;
     194        mbs->volume_flags = host2uint16_t_le(0);
     195        mbs->bytes_per_sector = log2(cfg->sector_size);
     196        mbs->sec_per_cluster = log2(cfg->cluster_size / cfg->sector_size);
    197197
    198198        /* Maximum cluster size is 32 Mb */
    199         assert((vbr->bytes_per_sector + vbr->sec_per_cluster) <= 25);
    200 
    201         vbr->fat_count = 1;
    202         vbr->drive_no = 0x80;
    203         vbr->allocated_percent = 0;
    204         vbr->signature = host2uint16_t_le(0xAA55);
    205 
    206         return vbr_checksum_start(vbr, sizeof(exfat_bs_t));
     199        assert((mbs->bytes_per_sector + mbs->sec_per_cluster) <= 25);
     200
     201        mbs->fat_count = 1;
     202        mbs->drive_no = 0x80;
     203        mbs->allocated_percent = 0;
     204        mbs->signature = host2uint16_t_le(0xAA55);
     205
     206        return vbr_checksum_start(mbs, sizeof(exfat_bs_t));
    207207}
    208208
     
    210210bootsec_write(service_id_t service_id, exfat_cfg_t *cfg)
    211211{
    212         exfat_bs_t vbr;
     212        exfat_bs_t mbs;
    213213        uint32_t vbr_checksum;
    214214        uint32_t initial_checksum;
    215215        int rc;
    216216
    217         vbr_checksum = vbr_initialize(&vbr, cfg);
     217        vbr_checksum = vbr_initialize(&mbs, cfg);
    218218        initial_checksum = vbr_checksum;
    219219
    220         /* Write the VBR on disk */
    221         rc = block_write_direct(service_id, VBR_SECTOR, 1, &vbr);
     220        /* Write the Main Boot Sector to disk */
     221        rc = block_write_direct(service_id, MBS_SECTOR, 1, &mbs);
    222222        if (rc != EOK)
    223223                return rc;
    224224
    225         /* Write the VBR backup on disk */
    226         rc = block_write_direct(service_id, VBR_BACKUP_SECTOR, 1, &vbr);
     225        /* Write the Main extended boot sectors to disk */
     226        rc = ebs_write(service_id, cfg, EBS_SECTOR_START, &vbr_checksum);
    227227        if (rc != EOK)
    228228                return rc;
    229229
    230         rc = ebs_write(service_id, cfg, EBS_SECTOR_START, &vbr_checksum);
     230        /* Write the Main Boot Sector backup to disk */
     231        rc = block_write_direct(service_id, MBS_BACKUP_SECTOR, 1, &mbs);
    231232        if (rc != EOK)
    232233                return rc;
     
    235236        vbr_checksum = initial_checksum;
    236237
     238        /* Write the Main extended boot sectors backup to disk */
    237239        return ebs_write(service_id, cfg,
    238240            EBS_BACKUP_SECTOR_START, &vbr_checksum);
     
    299301/** Writes the FAT on disk.
    300302 *
     303 * @param service_id  The service id.
    301304 * @param cfg Pointer to the exfat_cfg structure.
    302305 * @return EOK on success or a negative error code.
Note: See TracChangeset for help on using the changeset viewer.