Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time deserialization loses high bit of minutes field #26

Closed
dcoshea opened this issue Apr 15, 2022 · 1 comment
Closed

Time deserialization loses high bit of minutes field #26

dcoshea opened this issue Apr 15, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dcoshea
Copy link

dcoshea commented Apr 15, 2022

With pyfatfs checked out from the bugfix/dentry_ordering branch as at 96ae6bc, I found that PyFatFS.setinfo(path, {"details": {"modified": value}}) seemed to work despite the "Not yet properly implemented." docstring, but only partly.

While investigating that, I found this, which I think is the root cause of the issue I was seeing:

>>> pyfatfs.DosDateTime.DosDateTime.deserialize_time(31 << 5)
datetime.time(0, 31)
>>> pyfatfs.DosDateTime.DosDateTime.deserialize_time(32 << 5)
datetime.time(0, 0)

The most significant bit of the minutes field is lost. https://wiki.osdev.org/FAT says that the minutes field is stored in 6 bits, so the bit mask used is wrong, and this trivial fix seems to help:

-        minute = (tm >> 5) & ((1 << 5) - 1)
+        minute = (tm >> 5) & ((1 << 6) - 1)
@nathanhi
Copy link
Owner

Fixed with v1.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants