info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-mtools] [BUG] mcopy unable to copy to small FAT32 image starti


From: Pali Rohár
Subject: Re: [Info-mtools] [BUG] mcopy unable to copy to small FAT32 image starting v4.0.32
Date: Sat, 17 Sep 2022 11:49:22 +0200
User-agent: NeoMutt/20180716

On Saturday 17 September 2022 01:24:03 Alexander Bazarov wrote:
> Hi Alain,
> 
> Thank you for your detailed response!
> 
> > Would it be possible to have more details about this embedded device?
> > Which make, maybe "official" example images, etc.
> 
> It is a part of a proprietary SDK provided with multi-core ARM based
> SoCs for digital cameras. The SDK generates an embedded Linux image
> with sample applications.
> (the fat32 image is used inside a proprietary bootloader for storing
> configs before mounting other non-fat partitions and booting Linux)
> 
> As follows from Ubuntu's package manager, it installs the following
> versions of mtools https://packages.ubuntu.com/search?keywords=mtools
> :
> focal (20.04LTS): 4.0.24-1
> jammy (22.04LTS): 4.0.33-1
> 
> So it was pointed out that they will be required to fix the SDK
> somehow to add support development on Ubuntu 22.04 (the problem starts
> with mtools v4.0.32).
> 
> > Actually, according to Microsoft's specification, number of FAT bits of
> > an existing filesystem is SOLELY determined by the number of clusters.
> > This applies to all *three* bit numbers: 12/16/32
> [...]
> > I'm hesitant in bringing back this override (due to its incompatibility
> > with the intended target, namely windows and MS-DOS), and astonished
> > that there exist embedded devices which seem to require it.
> 
> But, as we see, `mkfs.vfat` does support creating non-standard
> partitions, and there is a way to mount them, so it is useful to have
> mtools to fill them with files after creation ;-)

Hello! Linux kernel does not allow mounting non-standard FAT-12 and
FAT-16 partitions since v2.6 era anymore. That mount option fat= was
removed long time ago.

And for same reasons support for this was removed from mkfs.fat (IIRC
in version v4.2). There is no OS which can handle it, so mkfs.fat does
not allow creating non-standard FAT-12 or FAT-16 too anymore.

But as Alain pointed Microsoft FAT implementation (fastfat.sys) for
FAT32 detection does not use number of clusters, but rather explicit
marking of FAT32. Same behavior has Linux kernel implementation
(msdos.ko and vfat.ko) and same in dosfstools project. Hence this
non-standard FAT32 can be still created by mkfs.fat.

mkfs.fat tries to be compatible with Microsoft fastfat.sys
implementation (source code is available!), old MS-DOS implementation
and of course also by Linux vfat.ko.

> For example, in this case, the partition has nothing to do with MS-DOS
> or Windows.
> 
> > However, *other* aspects of FAT32 (FAT size, location of root directory,
> > info block) are determined by whether the 16 bit fatlen boot sector
> > variable (offset 22) is 0 or not.
>  [...]
> > Maybe the device would understand a FAT16 with a freely plaçable root
> > directory? (i.e. boot.fatlen is 0, but boot.ext.fat32.bigFat is not).
> 
> Thank you for pointing out possible directions to check and sorry for
> not being able to share more details.
> 
> Best Regards,
> Alex
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]