Author Topic: SD Card Partition Boot Sec & Formatting  (Read 1294 times)

0 Members and 1 Guest are viewing this topic.

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
SD Card Partition Boot Sec & Formatting
« on: March 15, 2018, 07:27:10 am »
Hi Guys :)
I’ve been following this page, among others, to map the FAT32 and FAT16
partition boot sectors in order to parse card information out of them.
https://www.compuphase.com/mbr_fat.htm

So far, all is well, but I’ve noticed something peculiar with the volume label.
When I format or rename the SD Card in MacOS, the label is read as expected.
When I format or rename the SD Card in Windows 7, the label is read as
“NO NAME”, even though both Windows 7, and MacOS can read and display
the expected name. If I rename the same card in MacOS, my routine extracts it fine again.
The issue is the same for SD with FAT16, and SDHC with FAT32.

What does Windows 7 do differently when formatting or renaming SD Cards?

 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
Re: SD Card Partition Boot Sec & Formatting
« Reply #1 on: March 16, 2018, 02:44:17 am »
Well I found the solution :)

MacOS writes the 11 character volume label to the correct offset in the partition boot sector of the SD Card.

Windows 7 (and probably other Win versions) writes a file to the volume root directory, and this file is given the VOLUME attribute.
The VOLUME file attribute is unique, and not the same as HIDDEN, READONLY, ARCHIVE, or any others.
The volume file doesn’t show up in a browser just because it's configured to show hidden files, since HIDDEN is an attribute of it’s own.

The name of the volume file that would normally be an 8.3 file name, can be interpreted as an 11 character ASCII string
that still needs a null termination for copy with sprintf or for display. I assume this file is otherwise useless.

Now I can display the volume label no matter what OS formatted or renamed the CD Card! :)


 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
Re: SD Card Partition Boot Sec & Formatting
« Reply #2 on: March 16, 2018, 04:12:24 am »
Thanks for the link :)
I’ll still have to decide which overrides which.
For now, the file entry overrides the partition sector location.
I assume that will always display the label that both
Win and MacOS would.

Next is to support long file name entries.
The library does this as a compile time option,
but I think I can handle it.
 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
Re: SD Card Partition Boot Sec & Formatting
« Reply #3 on: March 16, 2018, 10:09:30 am »
Windows 7 writes the file entry, but not the partition boot sector. It still says “NO NAME”,
but in that state, MacOS will still read and display the name correctly.
MacOS at least writes the partition boot sector, but may also write the file. I haven’t tested that.
 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
Re: SD Card Partition Boot Sec & Formatting
« Reply #4 on: March 16, 2018, 06:23:58 pm »
Rather than look at the VFAT entries to get long file names,
I opened every MP3 file to extract data from id3 tags.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf