Changeset df1b4a8 in mainline


Ignore:
Timestamp:
2024-06-18T21:28:27Z (2 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
7cec216
Parents:
c15296b
Message:

Fix volume label entry / rootdir creation in mkfat for FAT32

With FAT32 the root directory is stored in clusters (like any
other directory). Its start address must be adjusted for
root_cluster (which is 2).

File:
1 edited

Legend:

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

    rc15296b rdf1b4a8  
    6666        default_fat_count               = 2,
    6767        default_reserved_clusters       = 2,
    68         default_media_descriptor        = 0xF8 /**< fixed disk */
     68        default_media_descriptor        = 0xF8 /**< fixed disk */,
     69        fat32_root_cluster              = 2
    6970};
    7071
     
    313314        cfg->reserved_sectors = 1 + cfg->addt_res_sectors;
    314315
    315         /* Only correct for FAT12/16 (FAT32 has root dir stored in clusters */
     316        /* Only correct for FAT12/16 (FAT32 has root dir stored in clusters) */
    316317        rd_sectors = div_round_up(cfg->root_ent_max * DIRENT_SIZE,
    317318            cfg->sector_size);
     
    434435        }
    435436
     437        if (cfg->fat_type == FAT32) {
     438                /* Root dir is stored in cluster fat32_root_cluster */
     439                addr += fat32_root_cluster * cfg->sectors_per_cluster;
     440        }
     441
    436442        /* Root directory */
    437443        printf("Writing root directory.\n");
     
    529535                bs->fat32.ebs = 0x29;
    530536                bs->fat32.id = host2uint32_t_be(vsn);
    531                 bs->fat32.root_cluster = 2;
     537                bs->fat32.root_cluster = fat32_root_cluster;
    532538
    533539                (void) fat_label_encode(&bs->fat32.label, bs_label);
Note: See TracChangeset for help on using the changeset viewer.