Coder Social home page Coder Social logo

MSDOS fs buffer hang & more about elks HOT 80 CLOSED

ghaerr avatar ghaerr commented on June 11, 2024
MSDOS fs buffer hang & more

from elks.

Comments (80)

georgp24 avatar georgp24 commented on June 11, 2024

I tried to reproduce this and cannot. ELKS shows the right file sizes on my FAT16 image and I did not get your buffer error.

Is the wina20.38_ a compressed file or what type of file? Why is there an underscore at the end of the file extension?

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

I can see on your photo that the file sizes are wrong. If your FAT16 hard disk image is smaller than 10 MB you may attach it to your post so I can test it.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

I found images of the old DOS 6 installation disks on the net. So I copied these files on the FAT16 image I generated with the script in the elkscmd/test/fat directory. (After modifying to FAT16) The files show up correctly then. So the problem is difficult to reproduce.

However, I also found that ELKS hangs after you deleted a file on the FAT16 disk.

dos-disk

dos-disk2

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

I did not test these issues. Since I came up with the FAT file system I did look into the issues related to that.

Maybe you can run Qemu on the RPI, Qemu is usually used by the ELKS developers.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

Here is the DOS image. The 'offending' files are in the TMP directory. This is just the partition, not the entire disk image.
dos286.img.gz

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

Helge,

I could not mount you disk image in Qemu with ELKS. When I looked at it with fdisk on Linux, the partition table seemed to be corrupted.

This is what sudo fdisk -l dos286.img lists:

'Befehl (m für Hilfe): p
Festplatte dos286.img: 15,2 MiB, 15925248 Bytes, 31104 Sektoren
Einheiten: Sektoren von 1 * 512 = 512 Bytes
Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes
E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes
Festplattenbezeichnungstyp: dos
Festplattenbezeichner: 0x6f727265

Device Boot Start End Sectors Size Id Type
dos286.img1 ? 1684955424 3386954047 1701998624 811,6G 6c unbekannt
dos286.img2 ? 1998616933 2542722764 544105832 259,5G 6e unbekannt
dos286.img3 ? 538988361 1077964648 538976288 257G 79 unbekannt
dos286.img4 ? 1394614304 1394635640 21337 10,4M 53 OnTrack DM6 Aux3'

This does not look good and I can understand that ELKS has problems with that.

Georg

from elks.

jbruchon avatar jbruchon commented on June 11, 2024

That is because there is no partition table; this is a filesystem image as you'd see on a floppy, not an MBR-partitioned hard disk image. The boot sector is a MS-DOS 6.22 boot sector. This is not an unusual configuration for small flash drives nor for floppy drives, so it should be handled. All block devices should have some sort of partition table detection and partition sub-device handling.

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

I made a script to write the partition image provided by Helge to a hard disk which can be mounted with ELKS:

#!/bin/bash

echo "ELKS FAT Hard Drive Image Builder"
echo

set +x
#Hard drive image file name
HD_IMAGE=fat16_hdd

if [ $UID != 0 ]
then echo -e "\nThis script must be run with root permissions\n" >&2
exit 1
fi

#makes flat hard disk image of 32 MB - sfdisk needs 32.2 MB image for that
echo -e "\nGenerating 32 MB disk image:"
dd if=/dev/zero of=$HD_IMAGE bs=1024 count=32200

#put partition table on this disk - id=0x80, =bootable first partition
echo -en "\nMaking partition table:"
echo ',,0E,
' | sfdisk --quiet -D $HD_IMAGE 2>/dev/null

#write dos286.img partition image to sector 0 in partition 1 of the image
echo "Writing partition image"
dd if="./dos286.img" of="$HD_IMAGE" seek=63 bs=512 count=34000 conv=notrunc

#make user owner of HD image (if using sudo)
if env | grep -q SUDO_USER
then
USERNAME=$(env | grep SUDO_USER | cut -d= -f 2)
chown $USERNAME:users "$HD_IMAGE"
fi
#allow all to read, owner to write
chmod 644 "$HD_IMAGE"

set +x
test -e "$HD_IMAGE" &&
echo -e "\nRun $HD_IMAGE with qemu.sh\n"

This way I can reproduce the error reported by Helge. However, I currently do not know how to fix this.

Georg

helge1

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

lithoxs avatar lithoxs commented on June 11, 2024

The problem is deeper than a simple bug.
First, msdosfs does not have the notion of inodes, much less inode numbers. All information is stored at the msdos directory entry.

In ELKS, the VFS insists on having an inode and its inode number. Then, for msdosfs, there has to be a mapping between every directory entry and a number (to be used as an inode number). This mapping is simply a combination the sector number of the directory entry and the offset of the directory entry (see file fs/msdos/misc.c, line 247).
Now, this number can be greater than 16 bits. In Linux this is no problem, but in ELKS only the 16 least significant bits are taken, resulting in the inode number pointing to somewhere else on the disk for inode information.

A solution can be to use 32 bit inode numbers (see file include/linuxmt/types.h, line #28), but this needs changes at many places.

from elks.

jbruchon avatar jbruchon commented on June 11, 2024

Assuming we're not currently worried about supporting FAT32, the starting cluster number could be used as the inode number. Hard linking is not permitted on FAT filesystems, so the starting cluster number is always unique between files and is always 16 bits wide or less.

from elks.

lithoxs avatar lithoxs commented on June 11, 2024

Might work. The idea of the inode number is to easily locate the inode information (directory information for msdos) on disk. It can be added the sector and offset of the directory entry in the section specific for msdos in the inode structure.
The change needs a clear understanding of the functions in fs/msdos directory

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

I took a closer look at the data (on the partition), and sure enough - the directory blocks giving offending data are further out on the volume than the ones giving correct results. And there is never a mix, correct and wrong data coming from the same directory block. Adding a new dir (using DOS) and copying data to it, gives all wrong metadata. Isn't it weird though that the file names come out correct all the time? Since the file names and the metadata are stored together, shouldn't we be able to get the correct metadata along with the name?

from elks.

lithoxs avatar lithoxs commented on June 11, 2024

When the VFS looks for a file, searches the file name in directories. If all directories traversed have 16 bits inodes, there will not be problem to find it. You are right when you say that all metadata is readily available at this moment, but instead function msdos_get_entry() creates a 32 bit inode number and truncates it to 16 bits, without reading any metadata.
The function which reads the metadata is msdos_read_inode(). It locates the directory entry using the inode number. First locates the sector (see file fs/msdos/inode.c, line 243) and then the directory entry within the sector (line 246). Size and time are read in lines 271 and 274.
But if the original inode number was larger than 16 bits, the inode number got truncated to 16 bits, so the original sector number was lost and the sector to read will be something else. This explains why the names are correct but metadata is garbage.
I tracked this as the cause of the directory listing problem, but there may be additional problems.
At the very least this is a bug.

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

Even if it does not solve completely the problem, why not improving the current code by not using the sector number, but the FAT cluster number as suggested by Jody, as the first part of the pseudo-inode, and not the sector offset, but the directory entry index, as the second part of that pseudo-inode ? This puts limitations below FAT16 capabilities, but it could work for a small FS.

A complete solution would be to implement a full map between the pseudo-inode and the pair (cluster, directory entry). It could also support FAT32, but would have a higher impact on existing code and memory consumption.

The choice of the solution is driven by the actual need : still targeting legacy HW where FAT16 was above capabilities (so no big cluster number and no many directory entries, that both can fit in 16 bits), or targeting emulators and recent HW where we can reach easily the FAT16 limits ?

@georgp24 : before adding features to ELKS by copying/pasting existing code, it would be nice to think a bit about the requirements... and understand deeper what is done in that code against that requirements before merging it...

from elks.

jbruchon avatar jbruchon commented on June 11, 2024

Generate a synthetic 16-bit inode number starting at 1 for every entry in any directory that's read e.g. with readdir() and store in a table the 16-bit cluster number for that directory on disk and a 16-bit directory index. For large numbers of files it would run out of memory quickly (64K = 10922 of these entries) but it would work for smaller volumes.

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

To see if the first solution could work for @Mellvik, I decoded the BPB he provided in his dump:

  • formatter: MSDOS5.0
  • 512 bytes / sector
  • 4 sectors / cluster (= 2048 bytes / cluster)
  • 1 reserved sector for boot
  • 2 FATs
  • 512 entries in root directory
  • disk type: HD
  • 34 sectors by FAT (= 8702 clusters max)
  • 17 sectors / track
  • 5 heads
  • hidden sectors: 49215
  • total sectors: 34000 (= 16 MB)
  • disk identifier: 80h (HD)
  • signature: 29h (OK)
  • disk serial number: 213011EEh
  • disk name: DOS622

It is not possible to pack the cluster number (up to 8702) and the directory index (up to 512) into a 16 bits inode number. The FS is too large for the first solution to work for that issue.

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

I am surprised to read mentioned here that FAT32 is not supported. It IS supported and that has been documented in the fat_fs.txt file. In the elkscmd/test/fat directory there is a s script to generate a FAT32 hard disk image which I used for testing.

Probably FAT32 support only works for a few files on the disk as well. However, using Qemu you can also access flash disks formatted with FAT32 from ELKS. I did access a 480 MB partition on the flash disk with a few files on it.

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

As Juan mentioned I tried to changed to 32 bit inode numbers but did not get it to work. So I left it as it is for a start. I think it is important to be able to copy files from and to a FAT disk to ELKS and that can be done with the existing code.

from elks.

jbruchon avatar jbruchon commented on June 11, 2024

Though not necessarily the best solution, the 16-bit variant of jodyhash (I have built and tested that variant with ELKS) might work for building a 16-bit hash table of directory entries for "touched" inodes that is purged on umount. That way a 16-bit inode number could be used even with FAT32.

from elks.

lithoxs avatar lithoxs commented on June 11, 2024

Writing code for a table to relate a 16 bit inode number with the corresponding sector and offset will require more effort and code size than simply increasing the inode number to 32 bits. Besides, the romfs also needs 32 bit inode numbers.
Regarding support for msdos:
FAT12 is fully supported.
FAT16 and FAT32 are supported as long as:
1. All directory entries are within the first 2 Mbytes from the start of partition.
2. Maximum partition size is 64 Mbytes.

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

@Mellvik : do you need any more action on that issue, or could we close it now ?

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

Latest fixes merged in #128 and #129.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

Thank you @Mellvik for this latest round of testing ! It confirms my opinion about the FAT support in ELKS : it was introduced last year in #111 in somewhat a rush, with a poor quality level in both design & implementation.

Despite this matter of fact, I think it is worth to improve it, because today FAT is the de facto standard to load a boot image (UEFI...). So I will come back to this issue after the current round (i.e. building the kernel with a full GNU tool chain), and I keep it open until then.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

A few physical machine tests (compaq 286) (I did a git fetch last night, assuming it's reasonably current):

  • Unrelated to the FAT issues, and probably recorded somewhere else: ls after login shows no files, pwd shows '/', ls -a shows . .. .profile, cd /; ls shows the expected directories. So pwd is reporting wrong right after login.

-- FAT: The metadata issues are gone, ls -l reports correct data, wrong year (as reported elsewhere).
-- ls in a big FAT directory (130 files) is somewhat slow initially (like before), then noticeably slower as it proceeds. ls -l does not show this effect.
-- any operation that writes to the FAT filesystem, hangs the system - mkdir, cp, ...

More testing later this week.

H

from elks.

georgp24 avatar georgp24 commented on June 11, 2024

I also think it is not user friendly to end up in an empty directory. I suggest to put a file in there so the user gets an orientation and does not feel lost.

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

A few physical machine tests (compaq 286) (I did a git fetch last night, assuming it's reasonably current):

Thank you @Mellvik for your testing!

  • Unrelated to the FAT issues, and probably recorded somewhere else: ls after login shows no files, pwd shows '/', ls -a shows . .. .profile, cd /; ls shows the expected directories. So pwd is reporting wrong right after login.

This isn't a bug: you're sitting in /root/.profile, where there are no files. Only ls -a shows .profile, as expected. Things are normal after you cd /.

-- FAT: The metadata issues are gone, ls -l reports correct data, wrong year (as reported elsewhere).

My testing shows proper 2020 dates on `ls -l'.

I would like to know more information about the type of FAT filesystem mounted, can you report what the FAT: line says immediately after mount?

-- ls in a big FAT directory (130 files) is somewhat slow initially (like before), then noticeably slower as it proceeds. ls -l does not show this effect.
-- any operation that writes to the FAT filesystem, hangs the system - mkdir, cp, ...

Any chance of sending over an image of this FAT filesystem you are using to test?
I have not tested speed, so there's likely improvement to be made there, but am wondering
about the FAT filesystem type for these other hangs (none of which I've seen after my fixes).

@mfld-fr: Can we move this out of #123 and into a new FAT filesystem testing issue?

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

@ghaerr : I prefer to keep this old thread as one piece, because there are still some problems today that were discussed earlier in that thread, to keep all the information in one place.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

The bug is that pwd reports the wrong directory.

I see, which directory is it reporting?

[MSDOS-FS 0.3 FAT16]

That mount message is before I fixed the hang problem and create file crash problem.

The current kernel message should read 'FAT: 1440k fat16', so it looks like you're running at least one ELKS source rev behind.

@mfld-fr: I figured we might run into issues without knowing the exact ELKS build being run. That would be a nice addition, but for the time being, I'll submit a PR that 1) shows detailed mounted FAT superblock information, and 2) a temporary FATFS version number incremented on each patch to FAT for ease of understanding user test results.

from elks.

mfld-fr avatar mfld-fr commented on June 11, 2024

@ghaerr : more simple: just get the current commit SHA and append it to the ELKS version 😄

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

-- FAT: The metadata issues are gone, ls -l reports correct data, wrong year (as reported elsewhere).

@Mellvik: I found and corrected a longstanding date bug - MSDOS dates start with 1980. Since ELKS boots without the date being properly set, it defaults to Jan 1 1970, which resulted in a negative year value. Long story short, this was converted and displayed as a date with a year like 2096, instead of 1970. Fixed on mkdir. If you see more date problems, run date and report that too, thanks!

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

New test using a fresh download of the entire tree and the default config:
mount -t msdos /dev/bda4 /mnt
mount failed: No such device

Tried with the same config as used yesterday, when the mount worked: No difference.
cat /dev/bda4 > /dev/null works fine

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

New test using a fresh download of the entire tree and the default config:
mount -t msdos /dev/bda4 /mnt
mount failed: No such device

@mfld-fr: I have only tested the FAT filesystem with /dev/fd0 and /dev/fd1 mounts. I have not looked into what the FAT BPB might need to be for hard disks, and need input for that. We may need code for handling a MBR boot partition.

@Mellvik: Can you test using /dev/fd1 as the mount point point (or test floppies rather than hard drives)? Please send a screenshot for any floppy mount or filesystem failures, and thanks for your testing!

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

More test results related to FAT file system and dates: [from commit dc3baae]

  • The date (year) problem is still there, and my claim that it also pertains to the rest of the date, is incorrect. This is indeed a year-only issue.
  • I believe the speed (directory listing) issue is worth looking into at some point, maybe open it as its own issue (non-urgent).
  • There are other date issues - which do not belong here.
    IMG_5847
    IMG_5846

from elks.

ghaerr avatar ghaerr commented on June 11, 2024
  • The date (year) problem is still there, and my claim that it also pertains to the rest of the date, is incorrect. This is indeed a year-only issue.

Thanks for the screenshots. However, they each show different filenames. Can you capture an example of the same file, under ELKS and MSDOS, which will shows the year handled incorrectly? That will allow me to understand what the problem is. I'm glad to hear its only the year, and not the time, although I'm unable to get ELKS ls to show a file time, only the date.

  • I believe the speed (directory listing) issue is worth looking into at some point, maybe open it as its own issue (non-urgent).

Yes, there are still number of improvements that could/should be made to the FAT filesystem. It was enough work to just get it to operate bug-free, which is the aim of this release.

  • There are other date issues - which do not belong here.

Other than the date not being set at boot, and date not able to set a new date? Let us know, thanks!

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

Sorry @ghaerr; I sent the wrong picture. Here is the correct pair.

No pictures were attached!

And I'm including a 3rd picture — demonstrating (at the bottom)(a well known problem???) how ELKS bombs when running out of memory. After the error message, the system is dead.

I'm aware that there isn't much memory to run programs, for instance bc won't run at all anymore.

The kernel source is ancient and needs to be gone over to pair down overly-large data and code segment uses, such as miscellaneous printk's, panic messages, and other things I've noticed.

However, issue #241 (configurable process heap + stack size) would possibly help greatly here, for possibly /bin/init and various important system utilities. I was thinking of diving into that, but it won't be for this next release.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

IMG_5846
IMG_5839
IMG_5847

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@Mellvik: I see the problem now - the year is off by exactly 100! That is going to be an easy fix and I think I know why. I'll look into this after skiing today and submit a PR. A picture is worth a thousand words! :)

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

@ghaerr,
the problem in date.c (not busyelks/cmd/date.c but elkscmd/sh_utils/date.c - why are there two?) is that strtok() has changed. The second parameter is now expected to be a string, not a char. so if you change the line
p = strtok(datestring, "-");
to doublequotes like above, date works.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

Also, just in case you missed it, @ghaerr, it may be useful to take a look at the memory error on the bottom of the last picture.
sys_brk failed; len 27972 > endseg 19792 Not enough memory. Use chmem to allocate more : Out of memory

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

Also, just in case you missed it, @ghaerr, it may be useful to take a look at the memory error on the bottom of the last picture.
sys_brk failed; len 27972 > endseg 19792 Not enough memory. Use chmem to allocate more : Out of memory

No I didn't miss that, thanks: I mentioned that working on #241 might help fix our ELKS application memory problems.

I'll fix the off-by-100 date problem as well as the date.c strtok() bug. Nice catch - maybe you better join the programming team!? :)

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@Mellvik: I've fixed the date -s problem, but I've looked into the displayed year off-by-100 problem in your screenshot and can't get it to duplicate. See attached pictures, they show the correct dates in years from 1998-2014 in ELKS and a DOS system! I'm not sure why your system is showing differently yet.

Screen Shot 2020-02-13 at 6 48 20 PM

Screen Shot 2020-02-13 at 6 48 25 PM

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@Mellvik : Also set your system date using the fixed date -s to Jan 1 1998, then do a "cat > file" and "ls -l file" to see what it shows. You can also try varying the date set to try to frame this very strange problem!

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@ghaerr, indeed strange. I set the date to 1997, 1998, 1999 - varying dates, and they all come out correctly with ls -l.

Yes, that's what I figured would happen, after looking at the source.

And here’s the real weirdo: The machine starts with date zero (1970…) I create a (FAT)file and the date is 1-1-1980 !!!!! Looks like the bug may be somewhere else than expected?

No - this is normal: FAT date 0 = 1980 while UNIX date 0 = 1970. This has not to do with the bug.

I need to look at the actual raw data in the directory — but before that I’d like to add whatever code is necessary to get ELKS to pull and set the date&time from the hardware.

Absolutely, the very best method would be to somehow get a copy of the disk or at least its directory contents. Do you have any other systems that can read MSDOS and ELKS-created floppies? That would help.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

New FAT mount/access test (ELKS as of this afternoon):
mount -t msdos /dev/fd1 /mnt
/dev/fd1 is a 1.2M 5.25 FAT12 floppy
This system (compaq portable 386/20) has a bad screen - barely readable, so I can't send images, so here's a summary:
Just after mount, a
ls -l /mnt
which goes like this
/mnt:
/mnt/<garbled chars>: Invalid argument
/mnt/<garb>ibm.3.3: Invalid argument
/mnt/<garbled>: Invalid argument
/mnt/ failure.$co: Invalid argument (The space is literal)
/mnt/$.<garbage>: No such file or directory
/mnt/2.m<garb>: Invalid argument
Then a normal listing of files, equivalent to what I get in DOS for the same disk, except that the hidden files are included and there is one more of the 'Invalid argument' entries further down. My guess is that the 'Invalid argument' entries are deleted files that for some reason show up.

I'll make a copy of the floppy image and test on VirtualBox tomorrow.

--Mellvik

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

New FAT mount/access test (ELKS as of this afternoon):
mount -t msdos /dev/fd1 /mnt
/dev/fd1 is a 1.2M 5.25 FAT12 floppy

Please send over or take a picture of the two "FAT: " kernel messages displayed directly after the mount. This will give an indication of exactly what the kernel thinks the FAT disk parameters are.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

@ghaerr,
Correction: The image is 360k, not 1.2M.

The screen is still barely readable, but with some effort - here's what I get:
FAT: me=fd,csz=2,#f=2,floc=1,fsz=2, rloc=5,#d=112,dloc=12,#s=720,ts=0
FAT: 360k, fat12 format

I guess the ts= is the only 'abnormal' here ...??

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

The screen is still barely readable, but with some effort - here's what I get:
FAT: me=fd,csz=2,#f=2,floc=1,fsz=2, rloc=5,#d=112,dloc=12,#s=720,ts=0
FAT: 360k, fat12 format

I guess the ts= is the only 'abnormal' here ...??

No, ts=0 is normal for FAT12 disks. The two big differences with your disk that have not been tested are that the cluster size is 2 (1k blocks), and number of root dir entries is 112, half of normal. There's obviously a big bug in FAT's handling of one of these two items.

Is there any way you could send a disk image to me for testing?

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

FWIW - and while waiting for a transfer of the image, I ran ELKS (from this morning) on VirtualBox, mounted a (random) 360 FAT12 image, and the ts= is a big number. Plus -
touch /mnt/abc.xyz
hangs ELKS - hard hang.
Skjermbilde 2020-02-17 kl  17 20 26

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

This does not happen when the images is 1.2M. I guess we're closing in.

Link to the 360K image (the one from the message above, not the one from yesterday):
https://www.dropbox.com/s/f80kb418w877wbm/atdg207.img?dl=0

Skjermbilde 2020-02-17 kl  17 23 57

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

FWIW - and while waiting for a transfer of the image, I ran ELKS (from this morning) on VirtualBox, mounted a (random) 360 FAT12 image, and the ts= is a big number. Plus -
touch /mnt/abc.xyz
hangs ELKS - hard hang.

This disk also has 1k clusters and 112 root dirs. Note, that it might be dangerous to your disks to run any application that tries to write to the FAT filesystem, when ls shows incorrect kernel FAT reading... this could permanently damage the FAT integrity of the floppy, depending on whether and where anything was written.

If a disk image can be sent over, I'll look into it. You might also try running minfo or mshowfat on the disks, to see what a standard tool thinks of them (especially after writing and hang).

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

This does not happen when the images is 1.2M. I guess we're closing in.

Your 1.2M image uses a 512 byte cluster size, the 360k version uses 1k cluster size...

Link to the 360K image (the one from the message above, not the one from yesterday):

Got it.

Well @Mellvik, with all your historical equipment, you've really pulled up an oldie here: it's a properly-formatted IBM 2.0 disk! 1k cluster size, 112 directory entries. The FAT BPB is short, and doesn't yet include the ts= (total size field). Confirmed with minfo.

I'll use this image to debug the FAT filesystem. I suspect it has something to do with either 1k cluster size or 112 root dir entries. Thank you!

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@Mellvik: The 360k image you sent me works fine, can't get any failures, including using touch. This disk is verified as having 1k cluster size and 112 root dir entries... Are you sure you sent me the proper failing disk image?

Screen Shot 2020-02-17 at 10 13 01 AM

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

What can I say? I have the same file in two different places and indeed they have a different checksum.
Let's try again:
https://www.dropbox.com/s/qswhzej42yw0teo/atdg207.img?dl=0
This is definitely the one I mounted and reported on ...

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

What can I say? I have the same file in two different places and indeed they have a different checksum.
Let's try again:
https://www.dropbox.com/s/qswhzej42yw0teo/atdg207.img?dl=0
This is definitely the one I mounted and reported on ...

Ok - this one displays all the directory contents properly, but fails on touch. I'll look into it.
Are you fairly sure this is a working MSDOS disk that hasn't been written to by ELKS in the past, including touch? ELKS could have corrupted a directory or the FAT table, for instance, on any failure/crash while writing.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@Mellvik, I've got thetouch bug reproducing, please send over the DOS 3.31 disk image with the invalid argument messages, if you can.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

OK; here i is - symptoms verified reproducible in emulator:
https://www.dropbox.com/s/3lupqz5mnneyae0/fd1.img?dl=0

Comments:

  1. This may not be the most important issue given all that is pending right now, so feel free to put it on the back burner. On the other hand I guess it's efficient to get it resolved while fresh - and it would indeed be nice to get it out of the way.
  2. I had a crash on the system demonstrating the FAT date problem, will get back to that.
  3. The floppy probing works but is extremely slow (and noisy) compared to what any other OS is doing. It may be a good idea to open an improvement issue on the one (5+ seconds, 5 full seeks back and forth, ...)

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

OK; here i is - symptoms verified reproducible in emulator:
https://www.dropbox.com/s/3lupqz5mnneyae0/fd1.img?dl=0

Thanks. I'll take a look at it.

I've found the problem with your previous disk image :)

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

Update:
Here's a floppy image with the directory that triggers the date problem. Turns out it triggers the other problems too - in VirtualBox, presumably in other emu's. Some consolation maybe, Raspbian has problems with this image too, and reports the date like this:

-rwxr-xr-x 1 root root 12065 Nov 25 1961 FC.EX_
-rwxr-xr-x 1 root root 29336 Nov 25 1961 FDISK.EXE
-rwxr-xr-x 1 root root 4879 Nov 25 1961 FIND.EX_
-rwxr-xr-x 1 root root 22974 Nov 25 1961 FORMAT.COM
-rwxr-xr-x 1 root root 11376 Nov 25 1961 GRAPHICS.CO_

It even has some of the other problems/symptoms:

helge@raspberrypi:~ $ ls -l /mnt/x
ls: cannot access '/mnt/x/?'$'\016''?'$'\a''.<$u': Input/output error
ls: cannot access '/mnt/x/ failure.$co': Input/output error
total 7959922
d????????? ? ? ? ? ? failure.$co
-rwxr-xr-x 1 root root 772195871 Jan 11 1980 $.???
drwxr-xr-x 13 root root 2048 Jul 23 1999 2.m??
d????????? ? ? ? ? ? ????.<$u
-rwxr-xr-x 1 root root 3469790928 Dec 25 1941 ?&?.??&
-rwxr-xr-x 1 root root 0 Jan 18 1980 ?(?IBM.3.3
-rwxr-xr-x 1 root root 6261 Nov 25 1961 ANSI.SY_

https://www.dropbox.com/s/39wrfterzow1eum/testimg144.img?dl=0

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

I've looked closer into the FAT date representation problem - discussed a number of times on this thread. Here's the problem summary & verdict:

  • Problem: ELKS reports the date of some files 100 years off - 2098 instead of 1998.
  • If we set the date (in ELKS) to 1.1.1998 and create a file in the same directory, the date is correct in DOS and ELKS
  • In the first case, the date entry in the directory is 21ec (118 years after 1980), in the latter it is 2124 (18 years after 1980).
    So, per the book, ELKS is right on both accounts and DOS is using +100 as some kind of flag (these files are coming off of a DOS installation floppy).

@ghaerr, I'll leave the rest to you.

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

@Mellvik, regarding the above 100 year off date problem: The standard mdir tool also shows the dates on your 3rd disk as being in 2098 as well:

Gregs-MBP2:elks-gh greg$ mdir -i fd3-fat-bad.img 
 Volume in drive : has no label
Directory for ::/

ANSI     SY_      6261 2098-01-01   0:04 
APPEND   EX_      7467 2098-01-01   0:04 
ATTRIB   EXE     11208 2098-01-01   0:04 
AUTOEXEC BAT        38 2098-01-01   0:04 

So, per the book, ELKS is right on both accounts and DOS is using +100 as some kind of flag (these files are coming off of a DOS installation floppy).

Thus, I am not going to try any further date changes to FAT at this point. Should you find other date bugs in FAT, lets open a new issue, so this one can be closed, provided that my latest PR fixes the 3 disk images you uploaded.

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

from elks.

Mellvik avatar Mellvik commented on June 11, 2024

Testing build 398ef39 - no new FAT related issues.
I agree the this issue may be closed.

One observation FWIW: Filesystem type 6, FAT16B, mounts and works fine. The debug message at mount reports FAT: 0k. If that's suspicious, now it has been reported.
Skjermbilde 2020-02-23 kl  15 41 58

from elks.

ghaerr avatar ghaerr commented on June 11, 2024

One observation FWIW: Filesystem type 6, FAT16B, mounts and works fine. The debug message at mount reports FAT: 0k.

@Mellvik: Yes, looks like the size reporting is only working for FAT12 images. Do you have a FAT16 image you could upload for my testing on this?

from elks.

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.