Changeset a927398 in mainline for uspace/app/mkfat/mkfat.c
- Timestamp:
- 2017-07-02T17:03:58Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 58fa3e6
- Parents:
- f4ae95a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkfat/mkfat.c
rf4ae95a ra927398 213 213 } 214 214 215 printf(NAME ": Creating FAT %d filesystem on device %s.\n", cfg.fat_type, dev_path);215 printf(NAME ": Creating FAT filesystem on device %s.\n", dev_path); 216 216 217 217 rc = fat_params_compute(&cfg); … … 220 220 return 2; 221 221 } 222 223 printf(NAME ": Filesystem type FAT%d.\n", cfg.fat_type); 222 224 223 225 rc = fat_blocks_write(&cfg, service_id); … … 274 276 { 275 277 uint32_t fat_bytes; 278 uint32_t non_data_sectors_lb_16; 276 279 uint32_t non_data_sectors_lb; 280 uint32_t rd_sectors; 281 uint32_t tot_clust_16; 277 282 278 283 /* … … 280 285 * system. The optimum could be potentially smaller since we 281 286 * do not subtract size of the FAT itself when computing the 282 * size of the data region. 287 * size of the data region. Also the root dir area might not 288 * need FAT entries if we decide to make a FAT32. 283 289 */ 284 290 285 291 cfg->reserved_sectors = 1 + cfg->addt_res_sectors; 286 if (cfg->fat_type != FAT32) { 287 cfg->rootdir_sectors = div_round_up(cfg->root_ent_max * DIRENT_SIZE,288 cfg->sector_size);289 } else290 cfg->rootdir_sectors = cfg->sectors_per_cluster;291 non_data_sectors_lb = cfg->reserved_sectors + cfg->rootdir_sectors; 292 293 cfg->total_clusters = div_round_up(cfg->total_sectors - non_data_sectors_lb,292 293 /* Only correct for FAT12/16 (FAT32 has root dir stored in clusters */ 294 rd_sectors = div_round_up(cfg->root_ent_max * DIRENT_SIZE, 295 cfg->sector_size); 296 non_data_sectors_lb_16 = cfg->reserved_sectors + rd_sectors; 297 298 /* Only correct for FAT12/16 */ 299 tot_clust_16 = div_round_up(cfg->total_sectors - non_data_sectors_lb_16, 294 300 cfg->sectors_per_cluster); 295 301 296 if (cfg->total_clusters <= FAT12_CLST_MAX) { 302 /* Now detect FAT type */ 303 if (tot_clust_16 <= FAT12_CLST_MAX) { 297 304 if (cfg->fat_type == FATAUTO) 298 305 cfg->fat_type = FAT12; 299 306 else if (cfg->fat_type != FAT12) 300 307 return EINVAL; 301 } else if ( cfg->total_clusters<= FAT16_CLST_MAX) {308 } else if (tot_clust_16 <= FAT16_CLST_MAX) { 302 309 if (cfg->fat_type == FATAUTO) 303 310 cfg->fat_type = FAT16; … … 310 317 return EINVAL; 311 318 } 319 320 /* Actual root directory size, non-data sectors */ 321 if (cfg->fat_type != FAT32) { 322 cfg->rootdir_sectors = div_round_up(cfg->root_ent_max * DIRENT_SIZE, 323 cfg->sector_size); 324 non_data_sectors_lb = cfg->reserved_sectors + cfg->rootdir_sectors; 325 326 } else { 327 /* We create a single-cluster root dir */ 328 cfg->rootdir_sectors = cfg->sectors_per_cluster; 329 non_data_sectors_lb = cfg->reserved_sectors; 330 } 331 332 /* Actual total number of clusters */ 333 cfg->total_clusters = div_round_up(cfg->total_sectors - non_data_sectors_lb, 334 cfg->sectors_per_cluster); 312 335 313 336 fat_bytes = div_round_up((cfg->total_clusters + 2) *
Note:
See TracChangeset
for help on using the changeset viewer.