Vladimir,
The approach you have suggested is the simplest (using another IRP as a
“template”) because once you try to build the entire thing yourself it
is really rather rigid. It sounds much like you’ve been lucky.
It has been many, many years since we wrote code to do this, but I
distinctly remember the reaction when the process was done was amazement
at how rigid the whole process was (there was not much lattitude in what
you could do if you wanted it to work in all situations.) The more
restricted the use you make of your code, the less likely you are to see
problems (my recollection is that the LAST problem we saw was related to
using the same create code over one of the redirectors. Something
subtle, but vital to correct behavior.)
As far as I can tell, IRP_MJ_CREATE comes from one place in the OS,
which also leads to the observation that nobody else is going to expect
anything EXCEPT what that one code path generates.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Vladimir Chtchetkine
Sent: Wednesday, February 25, 2004 10:11 PM
To: ntfsd redirect
Subject: RE: [ntfsd] IoCreateStreamFileObjectLite and create IRP
Thanks, Tony!
Actually, I need to do some more research on “if related FO is really
required for open by ID on my XP-SP1” (I just noticed that some
experiments that I did were not so clean). But, most likely, I will
follow your advice and use one of the FOs that are “around”. Is any FO
good for that? I mean does it matter if this “related FO” is a directory
or file? Has its handle been closed (i.e. cleanup IRP has already been
sent for this file)? Well, after all, I guess, I can use related FO that
I got in the IRP that I’m processing! 
If you don’t mind, can you give some 5 top reasons why rolling create
IRP is “that hard”? I’ve been doing this a lot and have never had any
problems. May be it was just a “luck”? Also my create IRPs are not 100%
pure create IRPs. I do reuse some params (like SecurityContext) that I
receive with the original IRP. Also I never go through the whole
completion process as I free that IRP in the completion routine and
return STATUS_MORE_PROCESSING_REQUIRED.
TIA,
Vladimir
-----Original Message-----
From: Tony Mason [mailto:xxxxx@osr.com]
Sent: Wednesday, February 25, 2004 6:47 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] IoCreateStreamFileObjectLite and create IRP
Vladimir,
Rolling create IRPs is, in my observation, the most difficult IRP to
construct and send. It can be done, but it is a tremendous amount of
work…
Open by ID does require a related file object, but this can be a file
object for any directory (possibly any file, I’d have to verify that) on
the volume. So, if you happen to keep a file object around for the root
directory (for example) then you can just use that. Indeed, more recent
versions of Windows appear to allow absolute file ID paths in NTFS (so
the first ‘character’ of the name is L’\’ and then the next 8 or 16
bytes are the file ID or object ID) so you don’t even need related file
objects in those cases. Older versions of Windows DID require relative
opens, however. And looking at the 3790 CDFS (which supports open by
file ID) it requires the relative file object mechanism, although my
quick glance suggests that it doesn’t look at the related file object -
at least not in CDFS. Did you actually try an IRP_MJ_CREATE with a null
related file object and a valid file ID and have it fail?
The purpose of IoCreateStreamFileObject* is to create a file object so
the file system can use it; if you want to use it for a create IRP you
can do so. See FastFat’s use to represent the mapped directory
(cachesup.c) for an example. There is also a comparable example in CDFS
(cachesup.c again). They really do just get back a pristine, clean file
object and you can use it in the manner you have described.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Vladimir Chtchetkine
Sent: Wednesday, February 25, 2004 9:11 PM
To: ntfsd redirect
Subject: RE: [ntfsd] IoCreateStreamFileObjectLite and create IRP
Thanks, Alexey!
So, I will switch back to “lite” version and roll cleanup IRP.
Shadow device technique is no help here. What I’m trying to do is to get
a path to a file for which I see “open by ID” create IRP. And I need
this path before I call underlying FSD. I tried to “shadow” it but it
doesn’t work for “open by ID”. At least it’s not that easy to make it
work. It looks like “open by ID” requires related FO + ID in
FileObject.FileName. At least that’s the picture I see in my filter for
“open by ID” IRPs. Maintaining related FOs on shadow device seem to be
bigger headache than just rolling cleanup IRP
As far as rolling
create IRP… I never had a single problem with that (well, when once
I’ve got it working). What confuses me, though, is using FO obtained via
IoCreateStreamFileObject in that IRP. Although FO seem to be not
initialized when it comes from IoCreateStream (no FsContexts, no Vpb, no
nothing, basically) but somehow I’m not certain if I can use it in
create IRP.
Regards,
Vladimir
-----Original Message-----
From: Alexey Logachyov [mailto:xxxxx@vba.com.by]
Sent: Wednesday, February 25, 2004 4:02 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] IoCreateStreamFileObjectLite and create IRP
Hate to tell this, but you might be wrong. The IoCreateStreamFileObject
routine creates a file object and then inserts it into process object
table (this is a standard sequense). Upon successful insertion the
routin will get a valid handle for the object. Immediately dfter that
the IoCreateStreamFileObject routine closes the handle. As this is the
only handle for the file object, IRP_MJ_CLEANUP request is sent down to
file system driver stack. But the underlying file system has not
completed IRP_MJ_CREATE operation for this file object yet, so the
cleanup request is ignored (file systems in checked build bark on such
requests). After create request has successfuly completed, you MUST send
clenup request for this
file object.
The IoCreateStreamFileObjectLite routine does not insert created file
object into handle table. So, handle is never created for such an
object.
I worked a lot on rolling IRP_MJ_CREATE requests some time ago. While I
cannot say that it is impossible, it often causes all kinds of problems
with this or that file system (FastFat, NTFS, DFS, SR, redirectors,
etc.).
Besides, some variables and routines neccessary for rolling a create
request are not exported at all. You’d better go with shadow devices
which are much easier and (what’s more important) stable solution.
–htfv
“Vladimir Chtchetkine” wrote in
message news:xxxxx@ntfsd…
Thanks, Ted!
I already figured out that I need to deref it just once. Besides, I
switched to IoCreateStreamFileObject instead of “lite” one so (according
to the doc) cleanup IRP will be sent automatically.
Regards,
Vladimir
-----Original Message-----
From: Ted Hess [mailto:xxxxx@livevault.com]
Sent: Wednesday, February 25, 2004 2:39 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] IoCreateStreamFileObjectLite and create IRP
You only need to call ObDereferenceObject once. However, I do send a
CLEANUP IRP to the FSD if the CREATE succeeded before calling
ObDereferenceObject.
You need to do this to reset sharing info from the successful CREATE.
/ted
-----Original Message-----
From: Vladimir Chtchetkine [mailto:xxxxx@borland.com]
Sent: Wednesday, February 25, 2004 4:40 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] IoCreateStreamFileObjectLite and create IRP
Hi everyone!
I need to roll my own create IRP and I need a FileObject for it. I’m
using IoCreateStreamFileObjectLite to create that object, initialize it
with my data, roll a create IRP and call file system with it. First of
all, I hope that this doesn’t violate any rules and I can do it. Second
question is how many times do I have to call ObDereferenceObject on this
FO (assuming that create has succeeded)? Currently I do it twice (one
for Create IRP and another for IoCreateStream) and system doesn’t
complain (I do use Verifier).
So, am I OK with what I’m doing?
TIA,
Vladimir
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@livevault.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as:
xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as:
xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as:
xxxxx@borland.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com