If the root cluster is bad, then mkfs.fat creates a filesystem which
fsck.fat considers to be broken and cannot fix.
Find the next free FAT cluster for root instead during creation.
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
Instead of the special --invariant flag, use SOURCE_DATE_EPOCH (and the
volume-id option) for reproducible build. (Plan for eventual removal of
the --invariant flag.)
Use "export SOURCE_DATE_EPOCH=1426325213; command" instead of the
simpler "SOURCE_DATE_EPOCH=1426325213 command". Both forms work in bash,
but apparently only the "export" version works in dash. Run in a
subshell to not leak SOURCE_DATE_EPOCH.
Signed-off-by: Bjørn Forsman <bjorn.forsman@gmail.com>
This ensures that fsck does not change its behavior and repair filesystems
in the same way. Repaired reference images were generated by dosfstools 4.1
to ensure that they are still same.
This requirement is needed by DOS systems and also by Linux mtools project.
Without proper alignment, mtools applications refuse to work on such
filesystem.
This change makes fsck.fat check whether "." and ".." entries exist in
all non-root directories as the two very first. If those entries are
occupied by some other file, fsck.fat will offer to move them to some
later slot. "." and ".." entries found in any other slots are treated
as ordinary bad-shortname entries. The test case for this situation has
been enabled and verified to perform as expected.
The function drop_file() was also modified so that it does not mark
dropped file clusters as free. This was necessary because otherwise
dropping too-late "." and ".." entries would delete their containing
directory. If deleted entries' clusters are truly no longer used, they
shall be picked up by a later reclamation stage.
Additionally, subdirs() and check_file() were modified not to check
unused directory entries.
Additionally-fixed-by: Dave Odell <dmo2118@gmail.com>
Use this CHS calculation when disk geometry is not available. This change
replaces hardcoded 64/32 value by formula based on total number of sectors.
For SD cards with more then 256MB capacity is CHS calculation according to
SD Card Part 2 File System Specification same as CHS calculation for hard
disks via LBA-Assist Translation.
It is needed only for non-removable disks used on Microsoft Windows systems
and only when formatting whole unpartitioned disk.
Also some removable USB flash disks accessed via USB Mass Storage declares
themselves as non-removable and Microsoft Windows systems do not recognize
them without MBR partition table and MBR disk signature.
Because MBR sector and first FAT sector are very similar (starts with
boot code, ends with boot sign 0xAA55) they can live together at one
sector. Moreover location of the MBR partition table overlaps only with the
end of FAT boot code where is just place for the error message, it is
possible to fill (fake) MBR partition table with one partition which refers
to whole disk itself (starts at sector 0 and spans whole disk).
Similar thing is doing mformat (FAT12/16/32 formatting tool) from mtools
project or mkudffs (UDF formatting tool) from udftools project.
Static builds have broken iconv support which is detected at configure time
as usable. This leads to usage of internal CP850 conversion table as
fallback solution which throws runtime non-fatal error.
Faulty filesystems are able to trigger integer overflows in read_boot which eventually lead to insufficient allocation of memory for the FAT and therefore out of boundary reads.
* Use both gcc and clang compilers
* Compile with -fwrapv and -fsanitize=address
* Compile in both 32 and 64 modes for x86 systems
* Cross compile for little endian arm and big endian powerpc
* Run cross compiled binaries in qemu
These FAT32 images were generated for FAT label test suite in October 2017.
Now fatlabel reports same FAT32 label as MS-DOS 6, 7 and Windows 98, XP, 10.
For more information about test result see email:
https://www.spinics.net/lists/kernel/msg2640891.html
The FAT16 test image contains four files with three errors. One has a
space in the name, one a space in the extension and one contains '>' in
the name.
Signed-off-by: Andreas Bombe <aeb@debian.org>
The FAT32 test image contains three files. One shares a cluster with the
root directory and the other two share clusters among themselves.
Signed-off-by: Andreas Bombe <aeb@debian.org>
Now the test-mkfs script also runs fsck on the created image to test its
basic operation. The test fails if fsck reports seeing an error.
Signed-off-by: Andreas Bombe <aeb@debian.org>
Before automake 1.13, parallel-tests wasn't the default set it
explicitly in the automake options list. The parallel test harness was
introduced in 1.11 therefore that is the minimum now.
However, the AM_TESTS_ENVIRONMENT variable was only starting to work in
1.13, so there is now a version check and a conditional assignment to
TESTS_ENVIRONMENT (which should be for user setting only) in case
automake is 1.11 or 1.12.
Without it, the fact of xxd being found is not passed to the test
scripts which then skip all tests due to perceived lack of xxd.
Signed-off-by: Andreas Bombe <aeb@debian.org>
The test image contains a file four clusters in length where the third
cluster has been modified to point back to the second cluster.
Signed-off-by: Andreas Bombe <aeb@debian.org>
The test image contains a file marked as 7 bytes in length (just a small
part of 1 cluster) in the directory entry that has 2 clusters assigned
to it in the FAT.
Signed-off-by: Andreas Bombe <aeb@debian.org>
Add the framework for a fsck testsuite and a few tests, including a test
for the yet unimplemented check for misordered dot/dotdot directory
entries.
The test driver runs fsck twice on a given image and fails the test if
the first run does not detect an error or the second run still detects
an error.
Signed-off-by: Andreas Bombe <aeb@debian.org>
Add testsuite on the basis of the automake framework. As a start, three
tests for basic mkfs functionality compare mkfs generated images against
references images.
Signed-off-by: Andreas Bombe <aeb@debian.org>