Opened 10 years ago

Last modified 6 months ago

#11119 new bug

FAT: wrong file times

Reported by: MatejHorvat Owned by: nobody
Priority: normal Milestone: R1
Component: File Systems/FAT Version: R1/Development
Keywords: Cc:
Blocked By: Blocking: #14069, #18632
Platform: All

Description

I created a text file on a FAT partition today (August 12, 2014) at 2:06 PM on hrev47617. Its time of modification was set to August 4, 2014, 2:32 AM. Modifying the file a few minutes later did not change it.

Making a copy of an existing file gave the duplicate the same modification time as the original. Modifying the duplicate did not change it there either.

My timezone is that of Slovenia. The time is synchronized with NTP.

Change History (14)

comment:1 by diver, 10 years ago

Milestone: R1/alpha5R1

comment:2 by pulkomandy, 3 years ago

Blocking: 14069 added

comment:3 by Jim906, 21 months ago

I'll see if I can fix this or at least gather some information about the problem and post it here.

comment:4 by waddlesplash, 21 months ago

Honestly the FAT driver needs a major overhaul in general. Perhaps a major rewrite wouldn't even be a bad idea, with code borrowed from or referenced from FreeBSD or elsewhere.

comment:5 by MatejHorvat, 21 months ago

Sure, as long as it gets fixed. Though theirs isn't perfect either:
https://bugs.freebsd.org/bugzilla/buglist.cgi?bug_status=__open__&order=Importance&query_format=advanced&short_desc=msdosfs&short_desc_type=allwordssubstr

Microsoft has released the source code of their FAT driver under MS-PL, which I think is MIT-compatible. Even if it's too hard to adapt, it may be useful as a reference:
https://github.com/Microsoft/Windows-driver-samples/tree/main/filesys/fastfat

comment:6 by Jim906, 20 months ago

I will see if I can adapt one of these drivers. I'm sure I would learn a lot from the process. It would take me a while though.

It would nice if I could get the Microsoft driver to work. Microsoft does have online documentation that explains many of the Windows types/functions that would need to be substituted for, to compensate for absent Windows headers, so it might be possible.

comment:7 by Jim906, 18 months ago

I am still a long way from submitting any major updates to the fat driver.

In the meantime, this is a suggested patch to fix the failure to update the time of modification: https://review.haiku-os.org/c/haiku/+/5798.

I could not reproduce the other problem from the bug report: the incorrect modification time being set when a file is created. MatejHorvat, does this problem still occur for you when using a more recent version of Haiku?

I will continue to study the FreeBSD and MS drivers to see if parts of either could be ported to Haiku.

comment:8 by Jim906, 10 months ago

I haven't forgotten about this and am working on adapting the FreeBSD FAT driver.

I focused on that over the Microsoft driver because the MS-PL does not apply to the Windows interface that the driver is built around. If using a large portion of the Microsoft driver code, I think it would be hard to avoid basically replicating some non-MS-PL Windows headers for compatibility.

comment:9 by waddlesplash, 10 months ago

It's worth noting that the Haiku bootloader also has a FAT implementation with partially implemented write support (just enough to create the "SYSLOG00" files), maybe you can use this also as a basis, in tandem with the FreeBSD driver sources.

comment:10 by pulkomandy, 6 months ago

Blocking: 18632 added

comment:11 by bbjimmy, 6 months ago

Interestingly, I copied foles from a usb mounted sd card to a usb stick, both reported 1887 for the creation date year. After mounting the usb stick in Windows, it showed the corect date. I then mounted the same usb stick in haiku hrev56838 x86_64 running in a VirtualBox on Windows 10. The file dates showed properly! To get the foile dates proper on my bare metal install, I zipped the contents of the usb stick in the virtual Haiku install, moved the stick to my main install, and copied the zip file to my BFS partition to unzip it, now I have all the file creation dates reporting properly on my main bfs partition.

  • note I had to use my sneaker network ( manually moving media from one computer to another) as neither FTP, NETFS nor PoorMan could seem to stay connected long enoughh to transfer the zip file from the virtual machine Haiku install.

Maybe the date issue is really a usb driver issue and not a FAT issue?

Last edited 6 months ago by bbjimmy (previous) (diff)

comment:12 by waddlesplash, 6 months ago

If the problem was really with the USB driver, a lot more would be corrupted on the FAT partition than just the dates. Something else must be different between these environments causing the FAT driver to mishandle the dates.

But as noted above, the FAT driver really needs a major overhaul...

comment:13 by bbjimmy, 6 months ago

The FAT systm was used to read the SD card and used to write to the USB stick. When Windows was used, either natively or with haiku in a Virtual box, The files showed the proper date on the usb stick. Only when haiku is used natively do the file dates show badly.

Last edited 6 months ago by bbjimmy (previous) (diff)

comment:14 by Jim906, 6 months ago

I should have an updated FAT driver (a port of the FreeBSD driver) ready to submit soon, which should fix the reported problem with file dates. At this point the updated driver can perform basic functions but it needs more testing and debugging.

Note: See TracTickets for help on using tickets.