Changeset d7f09583 in mainline
- Timestamp:
- 2012-02-27T19:48:09Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2601383
- Parents:
- 9ce1acf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/mkexfat/mkexfat.c
r9ce1acf rd7f09583 146 146 aoff64_t const volume_bytes = (cfg->volume_count - FAT_SECTOR_START) * 147 147 cfg->sector_size; 148 aoff64_t n_req_clusters;149 148 150 149 if (cfg->cluster_size != 0) { 151 150 /* The user already choose the cluster size he wants */ 152 n_req_clusters = volume_bytes / cfg->cluster_size;151 cfg->total_clusters = volume_bytes / cfg->cluster_size; 153 152 goto skip_cluster_size_set; 154 153 } 155 154 156 n_req_clusters = volume_bytes / DEFAULT_CLUSTER_SIZE;155 cfg->total_clusters = volume_bytes / DEFAULT_CLUSTER_SIZE; 157 156 cfg->cluster_size = DEFAULT_CLUSTER_SIZE; 158 157 … … 161 160 * size less or equal to 64 Mb. 162 161 */ 163 while ( n_req_clusters > 16000000ULL &&162 while (cfg->total_clusters > 16000000ULL && 164 163 (cfg->cluster_size < 32 * 1024 * 1024)) { 165 164 166 165 cfg->cluster_size <<= 1; 167 n_req_clusters = div_round_up(volume_bytes, cfg->cluster_size); 166 cfg->total_clusters = div_round_up(volume_bytes, 167 cfg->cluster_size); 168 168 } 169 169 170 170 skip_cluster_size_set: 171 171 172 /* The first two clusters are reserved */173 cfg->total_clusters = n_req_clusters + 2;174 175 172 /* Compute the FAT size in sectors */ 176 fat_bytes = (cfg->total_clusters + 1) * 4;173 fat_bytes = (cfg->total_clusters + 3) * sizeof(uint32_t); 177 174 cfg->fat_sector_count = div_round_up(fat_bytes, cfg->sector_size); 178 175 … … 182 179 183 180 /* Compute the bitmap size */ 184 cfg->bitmap_size = div_round_up( n_req_clusters, 8);181 cfg->bitmap_size = div_round_up(cfg->total_clusters, 8); 185 182 186 183 /* Compute the number of clusters reserved to the bitmap */ … … 194 191 cfg->allocated_clusters += div_round_up(sizeof(upcase_table), 195 192 cfg->cluster_size); 193 194 /* Subtract the FAT and bootsector space from the total 195 * number of available clusters. 196 */ 197 cfg->total_clusters -= div_round_up(cfg->data_start_sector * 198 cfg->sector_size, cfg->cluster_size); 196 199 197 200 /* Will be set later */ … … 219 222 printf(NAME ": Data start sector: %lu\n", cfg->data_start_sector); 220 223 printf(NAME ": Total num of clusters: %lu\n", cfg->total_clusters); 224 printf(NAME ": Total used clusters: %lu\n", cfg->allocated_clusters); 221 225 printf(NAME ": Bitmap size: %lu\n", (unsigned long) 222 226 div_round_up(cfg->bitmap_size, cfg->cluster_size)); … … 251 255 mbs->data_start_sector = host2uint32_t_le(cfg->data_start_sector); 252 256 253 mbs->data_clusters = host2uint32_t_le(cfg->total_clusters - 254 div_round_up(cfg->data_start_sector * cfg->sector_size, 255 cfg->cluster_size)); 257 mbs->data_clusters = host2uint32_t_le(cfg->total_clusters); 256 258 257 259 mbs->rootdir_cluster = host2uint32_t_le(cfg->rootdir_cluster); … … 818 820 cfg_print_info(&cfg); 819 821 822 if ((cfg.total_clusters - cfg.allocated_clusters) <= 2) { 823 printf(NAME ": Error, insufficient disk space on device.\n"); 824 return 2; 825 } 826 820 827 printf(NAME ": Writing the allocation table.\n"); 821 828
Note:
See TracChangeset
for help on using the changeset viewer.