Changeset 6cf9aeb in mainline


Ignore:
Timestamp:
2012-02-19T16:28:51Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3f6d4ea
Parents:
f8973122
Message:

mkexfat: superblock initialization is now completed

  • Added a function that prints some info about the filesystem we are creating.
  • Try to keep the FAT size under 16 Mb (4000000 clusters) by increasing the cluster size
File:
1 edited

Legend:

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

    rf8973122 r6cf9aeb  
    4242#include <errno.h>
    4343#include <byteorder.h>
     44#include <align.h>
    4445#include <sys/types.h>
    4546#include <sys/typefmt.h>
     
    6263        aoff64_t volume_start;
    6364        aoff64_t volume_count;
    64         uint32_t fat_sector_count;
    65         uint32_t data_start_sector;
    66         uint32_t data_cluster;
    67         uint32_t rootdir_cluster;
     65        unsigned long fat_sector_count;
     66        unsigned long data_start_sector;
     67        unsigned long rootdir_cluster;
     68        unsigned long total_clusters;
    6869        size_t   sector_size;
    6970        size_t   cluster_size;
    70         uint32_t total_clusters;
    7171} exfat_cfg_t;
    7272
     
    9696         * the entire storage device.
    9797         */
    98         while (n_req_clusters > UINT32_MAX &&
     98        while (n_req_clusters > 4000000 &&
    9999            (cfg->cluster_size < 32 * 1024 * 1024)) {
    100100
     
    103103        }
    104104
    105         cfg->total_clusters = n_req_clusters;
     105        cfg->total_clusters = n_req_clusters + 2;
    106106
    107107        /* Compute the FAT size in sectors */
     
    109109        cfg->fat_sector_count = div_round_up(fat_bytes, cfg->sector_size);
    110110
     111        /* Compute the number of the first data sector */
     112        cfg->data_start_sector = ROUND_UP(FAT_SECTOR_START +
     113            cfg->fat_sector_count, cfg->cluster_size / cfg->sector_size);
     114
     115        cfg->rootdir_cluster = 0;
     116
    111117        /* The first sector of the partition is zero */
    112118        cfg->volume_start = 0;
     119}
     120
     121/** Prints the exFAT structure values
     122 *
     123 * @param cfg Pointer to the exfat_cfg_t structure.
     124 */
     125static void
     126cfg_print_info(exfat_cfg_t *cfg)
     127{
     128        printf(NAME ": Sector size:           %lu\n", cfg->sector_size);
     129        printf(NAME ": Cluster size:          %lu\n", cfg->cluster_size);
     130        printf(NAME ": FAT size in sectors:   %lu\n", cfg->fat_sector_count);
     131        printf(NAME ": Data start sector:     %lu\n", cfg->data_start_sector);
     132        printf(NAME ": Total num of clusters: %lu\n", cfg->total_clusters);
    113133}
    114134
     
    136156        vbr->fat_sector_start = host2uint32_t_le(FAT_SECTOR_START);
    137157        vbr->fat_sector_count = host2uint32_t_le(cfg->fat_sector_count);
     158        vbr->data_start_sector = host2uint32_t_le(cfg->data_start_sector);
     159
     160        vbr->data_clusters = host2uint32_t_le(cfg->total_clusters -
     161            div_round_up(cfg->data_start_sector, cfg->cluster_size));
     162
     163        vbr->rootdir_cluster = 0;
     164        vbr->volume_serial = 0;
    138165        vbr->version.major = 1;
    139166        vbr->version.minor = 0;
     
    155182 * It works only if n is a power of two.
    156183 */
    157 static unsigned log2(unsigned n)
     184static unsigned
     185log2(unsigned n)
    158186{
    159187        unsigned r;
     
    221249
    222250        cfg_params_initialize(&cfg);
     251        cfg_print_info(&cfg);
    223252        vbr_initialize(&vbr, &cfg);
    224253
Note: See TracChangeset for help on using the changeset viewer.