Changeset b200230 in mainline for uspace/app/mkexfat/mkexfat.c


Ignore:
Timestamp:
2012-02-24T23:11:27Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ba55c194
Parents:
3467821
Message:

mkexfat: Add some comments, code cleaning

File:
1 edited

Legend:

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

    r3467821 rb200230  
    400400        assert(ncls > 0);
    401401
    402         if (ncls == 1) {
    403                 fat[cur_cls] = host2uint32_t_le(0xFFFFFFFF);
    404                 rc = block_write_direct(service_id, fat_sec, 1, fat);
    405                 goto exit;
    406         }
    407 
    408402        for (; cur_cls < fat_entries && ncls > 1; ++cur_cls, --ncls)
    409403                fat[cur_cls] = host2uint32_t_le(cur_cls + 1);
    410404
    411405        if (cur_cls == fat_entries) {
     406                /* This sector is full, there are no more free entries,
     407                 * read the next sector and restart the search.
     408                 */
    412409                rc = block_write_direct(service_id, fat_sec++, 1, fat);
    413410                if (rc != EOK)
     
    415412                cur_cls = 0;
    416413                goto loop;
    417         } else if (ncls == 1)
     414        } else if (ncls == 1) {
     415                /* This is the last cluster of this chain, mark it
     416                 * with EOK.
     417                 */
    418418                fat[cur_cls] = host2uint32_t_le(0xFFFFFFFF);
     419        }
    419420
    420421        rc = block_write_direct(service_id, fat_sec, 1, fat);
     
    492493                return ENOENT;
    493494
     495        /* Compute the start sector of the upcase table */
    494496        start_sec = cfg->data_start_sector;
    495497        start_sec += ((cfg->upcase_table_cluster - 2) * cfg->cluster_size) /
    496498            cfg->sector_size;
    497499
     500        /* Compute the number of sectors needed to store the table on disk */
    498501        nsecs = div_round_up(sizeof(upcase_table), cfg->sector_size);
    499502        table_ptr = (uint8_t *) upcase_table;
     
    503506            table_size -= cfg->sector_size) {
    504507
    505                 if (table_size < cfg->sector_size)
     508                if (table_size < cfg->sector_size) {
     509                        /* Reset the content of the unused part
     510                         * of the last sector.
     511                         */
    506512                        memset(buf, 0, cfg->sector_size);
     513                }
    507514                memcpy(buf, table_ptr, min(table_size, cfg->sector_size));
    508515
     
    621628        cfg_print_info(&cfg);
    622629
     630        /* Initialize the FAT table */
    623631        rc = fat_initialize(service_id, &cfg);
    624632        if (rc != EOK) {
     
    657665        }
    658666
     667        /* Write the allocation bitmap to disk */
    659668        rc = bitmap_write(service_id, &cfg);
    660669        if (rc != EOK) {
     
    664673        }
    665674
     675        /* Write the upcase table to disk */
    666676        rc = upcase_table_write(service_id, &cfg);
    667677        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.