Changeset 0f22528 in mainline


Ignore:
Timestamp:
2012-02-28T21:57: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:
ebea7acf
Parents:
9bbe54f
Message:

mkexfat: Be sure there is sufficient space to create the filesystem on device.

File:
1 edited

Legend:

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

    r9bbe54f r0f22528  
    144144{
    145145        unsigned long fat_bytes;
     146        unsigned long fat_cls;
    146147        aoff64_t const volume_bytes = (cfg->volume_count - FAT_SECTOR_START) *
    147148            cfg->sector_size;
     
    180181         * number of available clusters.
    181182         */
    182         cfg->total_clusters -= div_round_up((cfg->data_start_sector -
     183        fat_cls = div_round_up((cfg->data_start_sector -
    183184            FAT_SECTOR_START) * cfg->sector_size,
    184185            cfg->cluster_size);
     186        if (fat_cls >= cfg->total_clusters) {
     187                /* Insufficient disk space on device */
     188                cfg->total_clusters = 0;
     189                return;
     190        }
     191        cfg->total_clusters -= fat_cls;
    185192
    186193        /* Compute the bitmap size */
     
    821828        cfg_print_info(&cfg);
    822829
    823         if ((cfg.total_clusters - cfg.allocated_clusters) <= 2) {
     830        if (cfg.total_clusters <= cfg.allocated_clusters + 2) {
    824831                printf(NAME ": Error, insufficient disk space on device.\n");
    825832                return 2;
     
    897904        }
    898905
     906        printf(NAME ": Writing the boot sectors.\n");
     907
    899908        rc = bootsec_write(service_id, &cfg);
    900909        if (rc != EOK) {
Note: See TracChangeset for help on using the changeset viewer.