CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How does FAT32 calculate free and used disk space ?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
andreluizeng



Joined: 04 Apr 2006
Posts: 117
Location: Brasil

View user's profile Send private message Send e-mail MSN Messenger

How does FAT32 calculate free and used disk space ?
PostPosted: Tue Mar 10, 2009 7:27 pm     Reply with quote

Hi,

I have this struct (FAT32 diskinfo)
Code:

typedef struct _diskinforec
{
   char      hJumpCode[3];
   char     OEMName[8];
   int16      hBytesPerSector;
   char      bSectorsPerCluster;
   int16    Reserved1;
   char      FATCopies;
   int16    hMaxRootEntries;
   int16    hSectors;
   char      Descriptor;
   int16    holdSectorsPerFat;
   int16    hSectorsPerTrack;
   int16    hNumberofHeads;
   int32     hNumberofHidden;
   int32    hNumberofSectors;
   int32    hSectorsPerFat;
   int16    hFlags;
   int16    hFAT32Version;
   int32    hRootStartCluster;
   
} diskinforec;


Anyone knows how to use it to calculates disk free and used space ??

Thanks in advance.

regards
_________________
Andre
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: How does FAT32 calculates free and used disk space ?
PostPosted: Tue Mar 10, 2009 7:32 pm     Reply with quote

andreluizeng wrote:

anyone knows how to use it to calculates disk free and used space ??

thanks in advance.

regards


Its a painful process. You have to analyze the FAT to see how many clusters are unused then multiple by the number of sectors per cluster * 512

Used depends on you definition - if you want to know how much cannot be allocated then = total clusters - clusters used * sectors per cluster * 512

If you want to know how is used by files then you need to take into account clusters allocated and the unused sectors in the cluster.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
andreluizeng



Joined: 04 Apr 2006
Posts: 117
Location: Brasil

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Tue Mar 10, 2009 7:52 pm     Reply with quote

asmallri

Were those calculations that I was talking about.

thanks a lot.

best regards
_________________
Andre
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group