Comments (15)
git bisect
says it first showed up in 4d01db7.
from dosfstools.
@fstirlitz this is your commit.
In 4d01db7 is broken -S option, see:
$ ./src/fsck.fat -S disk.fat
./src/fsck.fat: invalid option -- 'S'
Usage: ./src/fsck.fat [OPTIONS] DEVICE
Check FAT filesystem on DEVICE for errors.
Options:
-a automatically repair the filesystem
-A toggle Atari variant of the FAT filesystem
-b make read-only boot sector check
-c N use DOS codepage N to decode short file names (default: 850)
-d PATH drop file with name PATH (can be given multiple times)
-f salvage unused chains to files
-l list path names
-n no-op, check non-interactively without changing
-p same as -a, for compat with other *fsck
-r interactively repair the filesystem (default)
-S disallow spaces in the middle of short file names
-t test for bad clusters
-u PATH try to undelete (non-directory) file that was named PATH (can be
given multiple times)
-v verbose mode
-V perform a verification pass
--variant=TYPE handle variant TYPE of the filesystem
-w write changes to disk immediately
-y same as -a, for compat with other *fsck
--help print this message
Also in that commit is added no_spaces_in_sfns
into fatlabel.c
even it does not modify fatlabel. This is another mistake.
from dosfstools.
Here's the fix. I'd squash it on top of my last commit.
from dosfstools.
This is probably not the best way how to check for root entry. What if other invalid FAT entry would have offset set to zero?
from dosfstools.
The offset
field of a DOS_FILE
struct is set by add_file
according to one of its arguments, which in turn is computed internally as the offset of the direntry relative to the start of the entire file system image (or set to 0, for the synthetic FAT32 root node). That value is never read from the file system image. The same check is used in auto_rename
, rename_file
and check_file
; I think it's fine.
By the way, I think it'd be wise to ask why the test suite failed to catch this mistake.
from dosfstools.
Ok, then it seems fine. And why test suite failed is a good question. There must be missing such test which creates an empty filesystem and then runs on it fsck.
from dosfstools.
Actually I do know the answer to that one:
./tests$ XXD_FOUND=yes srcdir=. sh -x ./test-mkfs ./referenceFAT32.mkfs
+ [ 1 -ne 1 ]
+ basename ./referenceFAT32.mkfs .mkfs
+ testname=referenceFAT32
+ [ yes != yes ]
+ . ./referenceFAT32.mkfs
+ ARGS=-n TESTFAT32
+ SIZE=1024000
+ CMP_LIMIT=10M
+ echo Test referenceFAT32
Test referenceFAT32
+ rm -f referenceFAT32.out referenceFAT32.refimg
+ xxd -r ./referenceFAT32.xxd referenceFAT32.refimg
+ run_mkfs -C -v --invariant -n TESTFAT32 referenceFAT32.out 1024000
+ ../src/mkfs.fat -C -v --invariant -n TESTFAT32 referenceFAT32.out 1024000
mkfs.fat 4.1+git (2017-01-24)
Auto-selecting FAT32 for large filesystem
referenceFAT32.out has 255 heads and 63 sectors per track,
hidden sectors 0x0000;
logical sector size is 512,
using 0xf8 media descriptor, with 2048000 sectors;
drive number 0x80;
filesystem has 2 32-bit FATs and 8 sectors per cluster.
FAT size is 2000 sectors, and provides 255496 clusters.
There are 32 reserved sectors.
Volume ID is 1234abcd, volume label TESTFAT32 .
+ echo
+ echo Comparing...
Comparing...
+ limitarg=
+ [ -n 10M ]
+ limitarg=--bytes=10M
+ cmp --bytes=10M referenceFAT32.out referenceFAT32.refimg
+ success=0
+ [ 0 -eq 0 ]
+ echo
+ echo Testing fsck...
Testing fsck...
+ run_fsck -n referenceFAT32.out
+ ../src/fsck.fat -n referenceFAT32.out
fsck.fat 4.1+git (2017-01-24)
/
Bad short file name ().
Auto-renaming it.
Renamed to
referenceFAT32.out: 1 files, 1/255496 clusters
+ success=0
+ rm -f referenceFAT32.out referenceFAT32.refimg
+ [ 0 -eq 2 ]
+ exit 0
Apparently fsck.fat
with the -n
option attempts to 'fix' the issue without reflecting the fact that it detected an error in the program's exit code.
from dosfstools.
e9a7460 makes "Bad short file name" go away for me.
from dosfstools.
@fstirlitz Are you going to prepare a pull request with this fix?
from dosfstools.
I guess @andreasbombe can already cherry-pick it without involving GitHub pull requests:
$ git fetch [email protected]:fstirlitz/dosfstools.git
$ git cherry-pick --no-commit e9a7460
$ git commit --amend --no-edit
$ git push --force
(Yes, git push --force
is frowned upon, but I think it's justifiable in this case, while the faulty commit is still the tip of the branch and relatively fresh.)
from dosfstools.
@andreasbombe Can you fix it?
from dosfstools.
I will take that fix once I figured out the reason for the test suite failure to fail. It's not supposed to return zero when it sees an error, fixed or not.
Edit: Ok that could be because it isn't actually "fixing" it by changing anything and if nothing is changed, fsck
returns 0 (i.e. it is not recording whether an error was detected, only whether something was or would be changed).
from dosfstools.
It relates to issue #89 (Use standard fsck exit codes in fsck.fat).
from dosfstools.
Not quite, the error codes that are there should have made the test fail the same that all other checks in the test suite work.
The thing is that the error is code is set on whether there were changes at the end rather than on when errors were detected. And the error was detected and "fixed" yet no changes were made.
from dosfstools.
I pushed the fix. I couldn't get at the commit to cherry-pick so I created the commits myself.
Also, the reason the error was not showing up in the test suite is because the when the rename functions were called to "fix" the issue, they would detect they are called on the root directory and return without doing anything. Since the filesystem wasn't changed, fsck
returned success.
from dosfstools.
Related Issues (20)
- mkfs.fat, issue with boot AM335x from SD-Card. (answer the total_sect differs between 4.2 and 4.1) HOT 25
- fsck.fat does not repair badly named file called `..` or `.` HOT 13
- The FAT_NO_83NAME flag conflicts with encryption metadata HOT 8
- fsck.fat destroys volume label from busybox mkfs.vfat HOT 15
- fsck.fat does not repair directory entries starting with 0x00 - HOT 2
- The user cannot access a file directory, with the message of "Contains a cluster (xxx). Assuming EOF"
- Alignment warning on modern GCC HOT 1
- does not compile on latest FreeBSD
- Relink directories to Main directory? HOT 1
- Release including SOURCE_DATE_EPOCH patch HOT 5
- Add support for --rootdir option HOT 1
- Properly repair filesystems with corrupted 3 byte headers, unrecognized by Windows? HOT 1
- -l option with a file of zero size HOT 12
- [fsck.fat] Falsely detects non-ASCII chars in volume label as below 0x20 HOT 2
- SD card optimized formatting HOT 7
- When going from windows to a hibernated Linux , my files were lost from USB stick HOT 2
- Tool for dumping list of bad blocks from existing FAT partition
- Improve bad block handling in mkfs.fat
- malloc : Cannot allocate memory HOT 3
- A question about "lfn_fix_checksum" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dosfstools.