In the pre-IRP_MJ_CREATE callback, you can’t perform an I/O on the given
FileObject, because it’s not fully initialized yet and the file/folder isn’t
even opened.
If you can wait for the information (whether FILE_OBJECT represents a file
or a directory) to your completion routine (CreateComplete), do that. Just
check IRP’s status code, get FileObject’s FileStandardInformation and check
Directory value.
Input IRP_MJ_CREATE flags don’t tell you if such request opens a file or a
folder, you have to ask file system for additional information to be sure,
it means:
-
if CreateOptions contained FILE_DIRECTORY_FILE or
FILE_NON_DIRECTORY_FILE, you can trust the flags
-
if CreateOptions didn’t contain any of the two flags, you must
perform additional query
o if CreateDispostion contained FILE_CREATE/FILE_OPEN_IF and if a
file/folder with the same name exists (i.e. you MUST ask file-system),
this IRP will fail (STATUS_OBJECT_NAME_COLLISION)
o otherwise, you must open the given file/folder and query for its attrib
-pk
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: 22. ledna 2009 2:28
To: Windows File Systems Devs Interest List
Subject: [ntfsd] determine if the FILE_OBJECT represents a file or a
directory
I read the FAQ on the OSR website. I queried the underneath file system by
querying for FileStandardInformation. But IoCallDriver function call fails
with Invalid Parameter. When i called the same function from CreateComplete,
it succeeded. So i understand that file needs to be opened for this to work.
I need this information in the Create, when the underneath file is not open.
Another trick given in the FAQ is “by examining the attributes within the
directory” which can be done without file being opened.
I did not quite get this statement and how do i examine the attributes
within the directory?
Any sample code would be great help as well.
thanks
Raj
here is the FAQ?
Q58 How do I determine if the FILE_OBJECT represents a file or a directory
from my filter driver? Can I rely upon the FILE_DIRECTORY_FILE bit?
The determination of whether or not a given FILE_OBJECT represents a
directory is the sole domain of the file system driver. Thus, for a file
system filter driver to determine if a file is a directory, it must ask the
file system. This can be done by querying the attributes of the file (e.g.,
after it has been successfully opened by the underlying file system) or by
examining the attributes within the directory, which can be done before the
underlying file has been opened.
NTFSD is sponsored by OSR
For our schedule debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars
You are currently subscribed to ntfsd as: xxxxx@avast.com
To unsubscribe send a blank email to xxxxx@lists.osr.com