First, the easy question:
A3) FltQueryInformation will be able to get you the size of the file.
A2) Yes, you can use KeGetCurrentIrql. However, it’s not necessary in
the minifilter model - PostCreate runs at PASSIVE_LEVEL.
A1) You probably CAN’T read the file in PreCreate unless you
FltCreateFile and get a handle yourself. If it hasn’t gone down to the
FSD, the file object that’s the subject of the create won’t be usable
yet.
Ordinarily, if you need to do something at low IRQL in a post-op, you
need to setup a workitem, or call FltDoCompletionProcessingWhenSafe.
Because the create postop happens at PASSIVE_LEVEL, that’s not necessary
for what you’re trying to do.
All that said, if you’re planning to read the whole file into one
buffer, you’re going to have to account for the situation of having a
file larger than the amount of memory you can allocate from either the
Paged or NonPaged pool. If you just need to read the file one buffer at
a time, you should be able to do so without knowing the file size
beforehand.
~Eric
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@netcleantech.com
Sent: Monday, January 21, 2008 10:04 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Where shall I read a file, in PreCreate or PostCreat?
Hello!
I will read a file in kernel mode, shall I do that in PreCreate or
PostCreat and can I know the length of the file before I begin to read?
Allocation in PostCreate must be nonpaged pool memory and when I read
about nonpeged pool allocations it says:
Nonpaged pool can be accessed from any IRQL, but it is a scarce resource
and drivers should allocate it only when necessary.
Q1: Therefore I wonder shall I read the file in PreCreate and use paged
pool instead?
When I read about paged pool it says:
Paged pool can only be allocated and accessed at IRQL < DISPATCH_LEVEL.
Q2: Can I know which IRQL the I/O operation has in Pre or Post Create?
Q3: When I read the file I must allocate enough buffer size, can I know
the size of the file before I start to read it?
Regards
Mattias Bergkvist
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@edsiohio.com To
unsubscribe send a blank email to xxxxx@lists.osr.com