Skip to content

Commit eddb23a

Browse files
fix VFAT LFN checksum generation
1 parent 93808c4 commit eddb23a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

system/libstm32l4_dragonfly/dosfs_core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ static int dosfs_volume_lock(dosfs_volume_t *volume)
961961

962962
if (volume->state != DOSFS_VOLUME_STATE_MOUNTED)
963963
{
964-
if (volume->context == NULL)
964+
if (volume->state == DOSFS_VOLUME_STATE_NONE)
965965
{
966966
status = F_ERR_INITFUNC;
967967
}
@@ -1036,7 +1036,7 @@ static int dosfs_volume_lock_nomount(dosfs_volume_t *volume)
10361036
armv7m_core_yield();
10371037
}
10381038

1039-
if (volume->context == NULL)
1039+
if (volume->state == DOSFS_VOLUME_STATE_NONE)
10401040
{
10411041
status = F_ERR_INITFUNC;
10421042
}
@@ -5991,7 +5991,7 @@ static uint8_t dosfs_name_checksum_dosname(const uint8_t *dosname)
59915991

59925992
for (chksum = 0, n = 0; n < 11; n++)
59935993
{
5994-
chksum = ((chksum >> 1) | (chksum << 7)) + *dosname++;
5994+
chksum = (((chksum >> 1) & 0x7f) | (chksum << 7)) + *dosname++;
59955995
}
59965996

59975997
return chksum & 0xff;
@@ -6003,7 +6003,7 @@ static uint16_t dosfs_name_checksum_uniname(const dosfs_unicode_t *uniname, unsi
60036003

60046004
for (chksum = 0, n = 0; n < unicount; n++)
60056005
{
6006-
chksum = ((chksum >> 1) | (chksum << 15)) + *uniname++;
6006+
chksum = (((chksum >> 1) & 0x7fff) | (chksum << 15)) + *uniname++;
60076007
}
60086008

60096009
return chksum & 0xffff;
32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)