FAT and Physical Disk Information

This is a discussion on FAT and Physical Disk Information within the Tech Board forums, part of the Community Boards category; Hi, whats up there? I went through something that I really didn't have enough information about it. It was about ...

  1. #1
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231

    Question FAT and Physical Disk Information

    Hi, whats up there?

    I went through something that I really didn't have enough information about it. It was about a flash drive that Windows displayed a wrong size for it. I had some research about that but what I've got is not well classified and I'm kinda confuzed. It seemed that the physical information is stored in MBR and each partition's FAT. I found some texts about it. I used a hex editor and found that bytes in their positions. There I could change them.

    My problem is that if the FAT has wrong info then Windows doesn't see the memory correctly. For example windows may see only a portion of memory 60 MBs of a 256MB flash memory for instance. How can this be solved? Am I correct that Windows reads size info from FAT?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    Reformat the drive.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    Of course reformating the drive wont solve the problem. As Windows reads the size info wrongly, it formats the disk using wrong size. Or for some corrupted disks it can't format the drive. You can test it using a disk editor. Change some FAT data and try to format the disk. It wont format it.

    [Disk == Flash Memory == Memory Device]
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,656
    Quote Originally Posted by siavoshkc View Post
    Of course reformating the drive wont solve the problem. As Windows reads the size info wrongly, it formats the disk using wrong size. Or for some corrupted disks it can't format the drive. You can test it using a disk editor. Change some FAT data and try to format the disk. It wont format it.

    [Disk == Flash Memory == Memory Device]
    AFAIK Windows doesn't use the MBR or FAT system to determine the size of the drive. Drives have "direct" commands that are accessed by the driver to gather that information, so the problem is with the driver being used, most likely.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    'Windows' does use the MBR, 'Format' however uses the actual disk specifications it retrieves from the BIOS. BIOS gets the data from the hard drives controller.


    Partition Table - OSDev Wiki
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  6. #6
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    What I mean is there is no ACTUAL specifications. Its only FAT. There is no special place in a flash memory to keep such data.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    Quote Originally Posted by siavoshkc View Post
    What I mean is there is no ACTUAL specifications. Its only FAT. There is no special place in a flash memory to keep such data.
    But flash drives do contain a driver controller with a ROM where this information could be stored, I think. On the other hand, to my knowledge standard flash drives all use 512 bytes of memory per sector. So the full drive size can be inferred from there.

    Another option is for you to use ScanDisk which does a much better job at identifying and fixing these issues.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Windows cannot possibly use some FAT data in the way the OP claims since you can reformat and partition flash drives in non-FAT formats, but I am sure after you do that windows will still be willing to erase the whole thing and re-format it using FAT, altho originally there was no FAT partition at all.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by siavoshkc View Post
    What I mean is there is no ACTUAL specifications. Its only FAT. There is no special place in a flash memory to keep such data.
    Its not limited to FAT, I have thumb drives that are formatted in NTFS as well as several others. Sector 0 on flash devices is usually treated specially with more redundancy and hard coded locations than generic sectors. So I'm not sure exactly what you are trying to say/ask.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  10. #10
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    Its not limited to FAT, I have thumb drives that are formatted in NTFS as well as several others. Sector 0 on flash devices is usually treated specially with more redundancy and hard coded locations than generic sectors. So I'm not sure exactly what you are trying to say/ask.
    I know. But when I saw Windows read the wrong info from FAT in format dialog box. I concluded that Windows sees FAT as the most reliable disk info source. I used an Ontrack product for repairing disks. That software saw it wrong too. Windows can format the disk in whatever format possible. But before that it should know the physical info of drive like size, cylinder, sector count, etc.

    You can test these things by yourself. Using DeviceIo() API and a disk editor you can do some actions.

    But flash drives do contain a driver controller with a ROM where this information could be stored.
    How can that ROM be accessed programmatically?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    Quote Originally Posted by siavoshkc View Post
    How can that ROM be accessed programmatically?
    Maybe this will help?
    Flash memory - low level access

    This is borderline knowledge to me. I'm not comfortable speaking much more about it. I'm not even sure the flash controller ROM contains the information you are after. I'd assume so. Same as it containing the driver that gets installed to your system during first install.

    I'm also a little confused... Do you want to fix a flash drive that somehow started to misbehave? Or do you want to programatically force a flash drive to display a different size than its real one?
    Last edited by Mario F.; 08-16-2009 at 07:34 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    I'm also a little confused... Do you want to fix a flash drive that somehow started to misbehave? Or do you want to programatically force a flash drive to display a different size than its real one?
    I already have the flash displaying different size. But I really get mad when I don't know something I want to know. I am really curious. I always had an idea that there is a place in the disk that keeps its info like that ROM, but never really thought about it.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  13. #13
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Are you sure windows is misreading it or are you just getting confused with the difference between 1 megabyte and 1 million bytes (they aren't the same).
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  14. #14
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,167
    There are many scam USB drives from China (less than reputable vendors) that intentionally mislabel flash drives. It would say, for example, 4GB on the box and the drive, and Windows would detect it as a 4GB drive, and it will work fine until you try to write, say, more than 128MB of data to it. Then bad things start to happen.

  15. #15
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,656
    Quote Originally Posted by cyberfish View Post
    There are many scam USB drives from China (less than reputable vendors) that intentionally mislabel flash drives. It would say, for example, 4GB on the box and the drive, and Windows would detect it as a 4GB drive, and it will work fine until you try to write, say, more than 128MB of data to it. Then bad things start to happen.
    Really? Wow, that sucks!

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Where is my file on disk
    By Salem in forum Windows Programming
    Replies: 7
    Last Post: 10-28-2007, 04:41 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21