Changeset ed9bf14 in mainline


Ignore:
Timestamp:
2015-11-07T23:46:59Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f63a0073
Parents:
44183b98
Message:

mkfat can live without the user specifying the FAT type just fine. This fixes FAT creation via fdisk for sizes not corresponding to FAT16 (i.e. too small or too large).

Location:
uspace/app/mkfat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/mkfat/fat.h

    r44183b98 red9bf14  
    4343#define FAT16_CLST_MAX    65525
    4444
     45#define FATAUTO 0
    4546#define FAT12   12
    4647#define FAT16   16
  • uspace/app/mkfat/mkfat.c

    r44183b98 red9bf14  
    102102        cfg.addt_res_sectors = 0;
    103103        cfg.root_ent_max = 128;
    104         cfg.fat_type = FAT16;
     104        cfg.fat_type = FATAUTO;
    105105
    106106        if (argc < 2) {
     
    189189        }
    190190
    191         if (cfg.fat_type != FAT12 && cfg.fat_type != FAT16 && cfg.fat_type != FAT32) {
     191        if (cfg.fat_type != FATAUTO && cfg.fat_type != FAT12 && cfg.fat_type != FAT16 &&
     192            cfg.fat_type != FAT32) {
    192193                printf(NAME ": Error. Unknown FAT type.\n");
    193194                return 2;
     
    247248            cfg->sectors_per_cluster);
    248249
    249         if ((cfg->fat_type == FAT12 && cfg->total_clusters > FAT12_CLST_MAX) ||
    250             (cfg->fat_type == FAT16 && (cfg->total_clusters <= FAT12_CLST_MAX ||
    251             cfg->total_clusters > FAT16_CLST_MAX)) ||
    252             (cfg->fat_type == FAT32 && cfg->total_clusters <= FAT16_CLST_MAX))
    253                 return ENOSPC;
     250        if (cfg->total_clusters <= FAT12_CLST_MAX) {
     251                if (cfg->fat_type == FATAUTO)
     252                        cfg->fat_type = FAT12;
     253                else if (cfg->fat_type != FAT12)
     254                        return EINVAL;
     255        } else if (cfg->total_clusters <= FAT16_CLST_MAX) {
     256                if (cfg->fat_type == FATAUTO)
     257                        cfg->fat_type = FAT16;
     258                else if (cfg->fat_type != FAT16)
     259                        return EINVAL;
     260        } else {
     261                if (cfg->fat_type == FATAUTO)
     262                        cfg->fat_type = FAT32;
     263                else if (cfg->fat_type != FAT32)
     264                        return EINVAL;
     265        }
    254266
    255267        fat_bytes = div_round_up((cfg->total_clusters + 2) *
Note: See TracChangeset for help on using the changeset viewer.