IRP_MJ_DIRECTORY_CONTROL odd behavior in power shell and CMD Result are missing

I am implementing Filesystem Dispatch routine for IRP_MJ_DIRECTORY_CONTROL.I have seen an odd behavior of my file system.I have a directory which has 69 directories.But for different result of listing is different.
Explore - 69 OK
Power Shell - 65 Why?
CMD - 64 Why?

Please also clearway abou SL_INDEX_SPECIFED. IT is so confusing and no clear documentation is provided on MSND.

In case of CMD
All Flags are disabled.So every time enumeration will resume from last point that is maintained in CCB. Logs for operation are

WUFS: DirectoryControl:FirstQuery

WUFS: DirectoryControl:SearchPattern Given

WUFS: File Name QUERY *

WUFS: SL_RESUME_SCAN 0

WUFS: QueryDirectory
Status-0
Information-592
Index-6
WUFS: SL_RESUME_SCAN 6
WUFS: Complete IRP_MJ_DIRECTORY_CONTROL
WUFS: QueryDirectory
Status-0
Information-5816
Index-69
WUFS: SL_RESUME_SCAN 69
WUFS: Complete IRP_MJ_DIRECTORY_CONTROL
WUFS: QueryDirectory
Status-80000006
Information-0
Index-69

Interesting point is that the five entries that are missing are only those entry that were sent in initial query.And Out of 6 items only one is getting listed that is very first in buffer.Other five are not in listed in dir command output.

Are you paying attention to the SL_RETURN_SINGLE_ENTRY flag? If not, that would explain why the last five entries were skipped. A caller that sets this flag will only look at one entry in the buffer. The typical Win32 API call pattern is to set this option on the FIRST call and then omit it for subsequent calls. But it’s not required to follow that pattern.

SL_INDEX_SPECIFIED is rare - there’s no user API for invoking it so you only see it from KM components. We’ve seen SMB use it (for example) as well as NTVDM (that’s how I originally tested it 15+ years ago…)

Tony
OSR

> Explore - 69 OK

Power Shell - 65 Why?
CMD - 64 Why?

Check your buffer size management, and the path which must return STATUS_BUFFER_OVERFLOW if you are out of buffer space.

Also check the wildcard paths. I think these apps are different in a way they use wildcards for FindFirstFile.

Also, I think HCK has unit tests for FSDs, try to run then too.

Please also clearway abou SL_INDEX_SPECIFED. IT is so confusing and no clear documentation
is provided on MSND.

FASTFAT source is a reference.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

@Tony Mason you are god… You saved my day… You were right i missed SL_RETURN_SINGLE_ENTRY part.Thanks a lot.You OSR guys are awesome you save me second time.This forum is so helpful for me.

@ I got SL_INDEX_SPECIFED uses by rajeev nagar source code and FastFat Source .THanks a lot for your help.