MultiDrive – free backup, clone & wipe disk utility from Atola Technology

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: FAT system: How to know the number of entries in a directroy
PostPosted: May 16th, 2014, 12:19 
Offline

Joined: April 18th, 2014, 13:07
Posts: 7
Location: Canada
Hi,

In FAT system, the directory will have a size of 0, in such a case, how to know the number of entries in the directory. There seems no field records the total number of entries in the directory either.

Current I will check all the entries under a directory, and don’t know how to end the loop like below:

While (TRUE)
{
Read an entry from the directory data
Process the entry
Advance the offset to the next entry
}

Thanks

Alan


Top
 Profile  
 
 Post subject: Re: FAT system: How to know the number of entries in a direc
PostPosted: May 16th, 2014, 16:52 
Offline
User avatar

Joined: September 8th, 2009, 18:21
Posts: 16960
Location: Australia
Can you show us what you mean by "directory data"?

I know how to locate all the directory entries manually with a hex editor, but that doesn't appear to be what you want.

_________________
A backup a day keeps DR away.


Top
 Profile  
 
 Post subject: Re: FAT system: How to know the number of entries in a direc
PostPosted: May 16th, 2014, 19:56 
Offline

Joined: April 18th, 2014, 13:07
Posts: 7
Location: Canada
The "directory data" are the data that store the entries for a directory, each entry is 16 byte long


Top
 Profile  
 
 Post subject: Re: FAT system: How to know the number of entries in a direc
PostPosted: May 16th, 2014, 20:05 
Offline
User avatar

Joined: September 8th, 2009, 18:21
Posts: 16960
Location: Australia
You need to locate the entry for the first cluster of the directory in the FAT. This entry will be the first in a chain of clusters. It will point to the next cluster in the chain, and this second entry will point to the third cluster in the chain, and so on until you reach an "end of file" cluster.

The location of the two copies of the FAT will be recorded in the boot sector of the volume, as will the cluster size in sectors.

_________________
A backup a day keeps DR away.


Top
 Profile  
 
 Post subject: Re: FAT system: How to know the number of entries in a direc
PostPosted: May 17th, 2014, 2:22 
Offline
User avatar

Joined: December 4th, 2012, 1:35
Posts: 3903
Location: Adelaide, Australia
cant you do something similar to when we want to program something with an arbitrary number of bytes, words, lines etc?

change your code to something like:

Code:

dir_entries.count = 0;

While (dir_entries.exists)
{
   Read an entry from the directory data
        if (dir_entries.exists)
       {
        dir_entries.count++
   Process the entry
   Advance the offset to the next entry
        }
        else
        {
         output dir_entries.count
        }

}


obviously very rough and ready code, but general principle of an unknown amount if it isn't actually stored anywhere you have to count it.


Top
 Profile  
 
 Post subject: Re: FAT file system: the number of entries in a directory
PostPosted: May 19th, 2014, 6:33 
Offline

Joined: February 8th, 2014, 8:08
Posts: 456
Location: Eastern Europe /recovering worldwide/
chcw wrote:
In FAT system, the directory will have a size of 0

In FAT directory size is always 0.

chcw wrote:
how to know the number of entries in the directory

You need to go through the list until you face a zero record.
If you've reached the end of the cluster, then go to file allocation table to find out whether it's possible to continue.

_________________
• Remote RAID, NAS, SAN, VMware, DVR (CCTV), flash and tape recovery. Data recovery support.


Top
 Profile  
 
 Post subject: Re: FAT system: How to know the number of entries in a direc
PostPosted: May 19th, 2014, 19:35 
Offline
User avatar

Joined: December 4th, 2012, 1:35
Posts: 3903
Location: Adelaide, Australia
depending on what language you want to program in, I would be surprised if many sourcecode examples don't already exist in some open source project. Try sourceforge github search and also asking at stack overflow may be a good idea.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: xmunk and 63 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group