Giter Site home page Giter Site logo

Comments (15)

dmo2118 avatar dmo2118 commented on June 16, 2024

git bisect says it first showed up in 4d01db7.

from dosfstools.

pali avatar pali commented on June 16, 2024

@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.

fstirlitz avatar fstirlitz commented on June 16, 2024

Here's the fix. I'd squash it on top of my last commit.

from dosfstools.

pali avatar pali commented on June 16, 2024

https://github.com/fstirlitz/dosfstools/blob/3fc495c68b59fdfbbf8e1ac53307cb4393ab86cb/src/check.c#L158-L160

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.

fstirlitz avatar fstirlitz commented on June 16, 2024

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.

pali avatar pali commented on June 16, 2024

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.

fstirlitz avatar fstirlitz commented on June 16, 2024

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.

dmo2118 avatar dmo2118 commented on June 16, 2024

e9a7460 makes "Bad short file name" go away for me.

from dosfstools.

pali avatar pali commented on June 16, 2024

@fstirlitz Are you going to prepare a pull request with this fix?

from dosfstools.

fstirlitz avatar fstirlitz commented on June 16, 2024

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.

pali avatar pali commented on June 16, 2024

@andreasbombe Can you fix it?

from dosfstools.

andreasbombe avatar andreasbombe commented on June 16, 2024

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.

pali avatar pali commented on June 16, 2024

It relates to issue #89 (Use standard fsck exit codes in fsck.fat).

from dosfstools.

andreasbombe avatar andreasbombe commented on June 16, 2024

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.

andreasbombe avatar andreasbombe commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.