I forgot something. FSCTL_READ_MFT_RECORD will do exactly what you
wish, I think, but it is, to the best of my knowledge, completely
undocumented.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Martin O’Brien
Sent: Friday, August 24, 2007 11:15
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] File Count - ZwQueryDirectoryFile and caching
I would imagine that it is getting the information by processing the
file system metadata. As far as defrag, there is a documented user mode
api (FSCTL) for defragmentation; this is what I would imagine that it
uses, although I don’t think that the information you seek can be
obtained with it.
Search MSDN/SDK help for any of these, all of which are used with
DeviceIoControl:
FSCTL_GET_VOLUME_BITMAP
FSCTL_GET_RETRIEVAL_POINTERS
FSCTL_MOVE_FILE
FSCTL_READ_MFT_RECORD
I believe that this is what’s going on, but I can’t say that I have ever
played around with these, and I don’t think that these particular
(FSCTL_) will do exactly what you wish, but it is a place to start.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.ca
Sent: Friday, August 24, 2007 10:44
To: Windows System Software Devs Interest List
Subject: [ntdev] File Count - ZwQueryDirectoryFile and caching
Hi:
I have been reading for two days about NTFS and all possible ways of
enumerating files. My purpose is to be able to quickly count how many
files there are.
Findings (tested on XP SP2 - 1gig RAM):
I observed that after running an enumeration with ZwQueryDirectoryFile
(or FileFindFirst) once subsequent runs are more than 10 times faster.
In one instance I had 72204 file which took only 1984ms (less than 2
sec). In the first run the actual time is 81094ms
Now if you use Disk Defragmenter and analyze (dfrgntfs.exe) any of your
NTFS partition you can find that it’s consistently fast (it gives you
total file count). What does dfrgntfs.exe do that we don’t know about?
Question:
-
Is there a trick to get the total number of files per partition very
quickly like dfrgntfs.exe?
-
If there is some kind of caching with Windows (I am interested in
2000, XP, Vista) about file system information. How does it work? How is
it related to system memory? How long can it last?
Thanks.
Naer
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer