mkfs: set perc_in_use to 0xFF
PATCH 1/1 mkfs: set perc_in_use to 0xFF
Currently, mkfs.exfat always sets the perc_in_use field in the boot header to zero. This is not the correct behaviour since there is always going to be used clusters for the volume structures like the allocation bitmap and upcase table.
perc_in_use is only an advisory field. As the number of used clusters are determined later on during the formatting process, it's not worth risking a huge code change just for correctness. Therefore, to avoid confusion, set it to 0xFF which is the magic value that should be interpreted as "not known" according to the spec.
As the Linux kernel exfat driver currently does not modify perc_in_use at all, unless the volume is mounted by an implementation that modifies it, it will always be read as 0. Setting it to 0xFF should somewhat alleviate the issue because the user would at least know it's not valid.
--- mkfs/mkfs.c | 1 + 1 file changed, 1 insertion(+)
mkfs/mkfs.c +1 -0
@@ -388,6 +388,7 @@ static void exfat_setup_boot_sector(struct pbr *ppbr, pbsx->fs_version[0 ] =0 ; pbsx->fs_version[1 ] =1 ; pbsx->phy_drv_no =0x80 ; + pbsx->perc_in_use =0xFF ;memset (pbsx->reserved2,0 ,7 );memset (ppbr->boot_code,0 ,390 );
Signature · 1 line
2.55.0
Quoted 11 lines · David Timber
Currently, mkfs.exfat always sets the
perc_in_usefield in the boot header to zero. This is not the correct behaviour since there is always going to be used clusters for the volume structures like the allocation bitmap and upcase table.
perc_in_useis only an advisory field. As the number of used clusters are determined later on during the formatting process, it's not worth risking a huge code change just for correctness. Therefore, to avoid confusion, set it to0xFFwhich is the magic value that should be interpreted as "not known" according to the spec.
Quoted 6 lines
As the Linux kernel exfat driver currently does not modify
perc_in_useat all, unless the volume is mounted by an implementation that modifies it, it will always be read as 0. Setting it to0xFFshould somewhat alleviate the issue because the user would at least know it's not valid.Signed-off-by David Timber <[email protected]>
Thank you for this patch.
Quoted 19 lines
--- mkfs/mkfs.c | 1 + 1 file changed, 1 insertion(+)mkfs/mkfs.c +1
-0@@ -388,6 +388,7 @@ static void exfat_setup_boot_sector(struct pbr *ppbr, pbsx->fs_version[0 ] =0 ; pbsx->fs_version[1 ] =1 ; pbsx->phy_drv_no =0x80 ; + pbsx->perc_in_use =0xFF ;memset (pbsx->reserved2,0 ,7 );memset (ppbr->boot_code,0 ,390 );Signature · 1 line
2.55.0
Signature · 2 lines
Thanks, Hyunchul
Quoted 12 lines · David Timber
Currently, mkfs.exfat always sets the
perc_in_usefield in the boot header to zero. This is not the correct behaviour since there is always going to be used clusters for the volume structures like the allocation bitmap and upcase table.
perc_in_useis only an advisory field. As the number of used clusters are determined later on during the formatting process, it's not worth risking a huge code change just for correctness. Therefore, to avoid confusion, set it to0xFFwhich is the magic value that should be interpreted as "not known" according to the spec.
Quoted 6 lines
As the Linux kernel exfat driver currently does not modify
perc_in_useat all, unless the volume is mounted by an implementation that modifies it, it will always be read as 0. Setting it to0xFFshould somewhat alleviate the issue because the user would at least know it's not valid.Signed-off-by David Timber <[email protected]>
Applied it to #exfat-next.
Thanks!