VOGONS


Bugfixes for the FAT drive

Topic actions

First post, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Fixes 3 bugs in drive_fat.cpp. One is quite big.

There are 2 more I noticed but they are probably not important.

- can't copy files with system attribute set in Norton Commander (I'm not certain my fix is good)
- Norton Commander can't delete a not empty directory because they do a findnext after a failed findfirst and get a rouge file that way (it does not do a findnext after a failed findfirst on drive_local, I have no fix for that)

Attachments

  • Filename
    fatpatch.txt
    File size
    1.78 KiB
    Downloads
    188 downloads
    File license
    Fair use/fair dealing exception

Reply 1 of 25, by kruwi

User metadata
Rank Member
Rank
Member

Maybe interesting to you:

When I try to run "pc-shell" (the norton commander equivalent of the pctools) in dosbox (today's cvs-build, I downloaded it from "dosbox cafe", your patch already added), there is a message like "fat error" or something. This error message is the same in 0.65. So I think your patch has not yet resolved the problem completely.

Reply 2 of 25, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

This patch is related to disk image mounting only, in case of pc-shell (and scandisk) some dos behavior is missing. I tried to implement a bit of it but it revealed more and more missing stuff 😀

1+1=10

Reply 4 of 25, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Accessing the fat will never work for regularly mounted drives,
only for booted disk images. It might be possible for non-booted
disk images, but that's pointless.

About the patch: thanks for the findings, just the first one
doesn't seem to be neccessary for me. Even if the condition
(curSectOff>0 && loadedSector) is hit, the information is
already written in a previous cycle, or does it occur in some
special situation?

Reply 5 of 25, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Well I wouldn't say it's pointless if I could run scandisk for images in Dosbox directly.
The problem with data not written is a bit deeper inside, if the app does a seek after a write (Norton Commander really likes to do that) then the data in the buffer is lost. Files < 512 bytes will have uninitialized data in them and larger files don't have the tail written.
There are also other bugs, clusters are appended to the file if there isn't a need yet(in case filesize%clustersize==0), so scandisk finds mismatching sizes, and sometimes the MBR gets overwritten.

1+1=10

Reply 6 of 25, by rcblanke

User metadata
Rank Oldbie
Rank
Oldbie
h-a-l-9000 wrote:

...and sometimes the MBR gets overwritten.

I sure hope that can only happen to booted disk images or regularly mounted images... 😜 😁

Ronald

Reply 8 of 25, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

> if I could run scandisk for images in Dosbox directly.

It is highly recommended to not use ANY program that directly
access the disk if no real dos is booted. There are too many
stub tables which gives in almost all cases wrong results for
those type of programs.
The disk image mounting is intended for copying files from
other mounted drives easily.

> Norton Commander can't delete a not empty directory because they
> do a findnext after a failed findfirst and get a rouge file that way

Something with the search IDs gets wrong, they're doing a findfirst,
then a few different findfirsts (for some nc file), and then continue
the first findfirst. This last findnext flags an error for local_drive,
but succeeds for drive_fat for some reason. The dta.SetDirID(0); would
have to be replaced, yet the ID is used to indicate the file position
in that search.

I'll committ the patch by times, thanks again 😀

Reply 9 of 25, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

> The dta.SetDirID(0); would have to be replaced,
This looks like it would be duplicated code with drive_cache...

Here are two mounting sanity checks.

Attachments

  • Filename
    fat2.diff
    File size
    1.3 KiB
    Downloads
    183 downloads
    File license
    Fair use/fair dealing exception

Reply 10 of 25, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

> This looks like it would be duplicated code with drive_cache...

The drive_fat doesn't use the drive cache at all. It can be noticed
in that the files aren't sorted when typing dir on a disk image
(if the files aren't stored in name-sorted order).
The problem seems to be that the searches are done relative to
cwdDirCluster (see the call to FindNextInternal in FindFirst()).
Should be fixed now as well.

> Here are two mounting sanity checks.

Changed them to not cause the image loading to fail, as there
seem to be some images with odd/nonstandard geometry around.

Reply 11 of 25, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I mean the CFileInfo implementation in DOS_Drive_Cache. I assume something similar would be needed in fatDrive.

About the sanity checks: such broken images wouldn't load on a real computer. The BIOS won't touch a MBR that doesn't have the 55AA. If such an image mounted at all then probably because dosbox overwrote the mbr with the partition data as zero and the startSector = 63 was used. (happened to me too)

1+1=10

Reply 14 of 25, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Still there's no reason why there shuldn't exist a bios that ignores the
id like most bioses do for boot sectors.
You'll surely know soon enough if somebody mounted a broken disk image.

Reply 15 of 25, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Does the copying of system files not work, or is it copying
of hidden files? For me the latter is the case, as the hidden
flag is missing in fatDrive::getFileDirEntry and i don't see
any reason why it shouldn't be there (that is at
SetupSearch(0,0x5,findFile))

Reply 16 of 25, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The files in question are io.sys and msdos.sys which have system, read-only and hidden attributes set.

Commenting out in FindNextInternal

/* Always find ARCHIVES even if bit is not set  Perhaps test is not the best test */
if(~attrs & sectbuf[entryoffset].attrib & (DOS_ATTR_DIRECTORY /*| DOS_ATTR_HIDDEN | DOS_ATTR_SYSTEM*/) ) goto nextfile;

lets me copy these files.

1+1=10

Reply 18 of 25, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

btw the mbr overwriting is caused by lines like
currentSector = myDrive->getAbsoluteSectFromBytePos(firstCluster, seekpos);
(especially in seek).
getAbsoluteSectFromBytePos can return 0 on faliure and if a write is done after such a call sector 0 = mbr will be overwritten.

1+1=10

Reply 19 of 25, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

> The files in question are io.sys and msdos.sys which have
> system, read-only and hidden attributes set.

Yes, that's why i asked if you are sure that it's the system
flag, as this one doesn't cause any trouble for me.
See the posting above, and see what happens if you change
the 0x5 into a 0x7 (works for me).

> getAbsoluteSectFromBytePos can return 0 on failure

That's indeed pretty bad, any idea when this happens? Seems to
only affect fatFile::Seek, maybe changing it to the following
would help:
Bit32u sector = myDrive->getAbsoluteSectFromBytePos(firstCluster, seekpos);
if (sector) currentSector = sector;
else return false;
though normally a seek never fails (only the following write/reads).