Re: IRP_MJ_CLEANUP and FileObject->FsContext is NULL? ?

Not a stupid question – A better question here is “Why does
IoCreateStreamFile issue a CLEANUP?” My guess is that a handle was created
then closed – hence the CLEANUP. Or, perhaps it was supposed to signal the
FSD that a StreamFileObject was created. Of course, there may be some other
historic significance to this behavior better answered by the MS folks. Note
that if one calls IoCreateStreamFileLite, you do not get the gratuitous
CLEANUP.

Go figure… /ted

-----Original Message-----
From: Lyndon J. Clarke [mailto:xxxxx@neverfailgroup.com]
Sent: Thursday, October 23, 2003 10:38 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Re: IRP_MJ_CLEANUP and FileObject->FsContext is NULL? ?

Thanks Ted. Stupid question here … what is the meaning of a
IRP_MJ_CLEANUP, and indeed a FILE_OBJECT, for an “unopened” file? I thought
we got IRP_MJ_CLEANUP when the last hande tied to the file object was
closed.


You are currently subscribed to ntfsd as: xxxxx@livevault.com To unsubscribe
send a blank email to xxxxx@lists.osr.com

It really is just the close on the handle. The function of
IoCreateStreamFileObjectLite is to eliminate the extra IRP_MJ_CLEANUP.

The FSD doesn’t need to know about this creation since (normally) it is the
file system that CREATES this stream file object in the first place!

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: Ted Hess [mailto:xxxxx@livevault.com]
Sent: Thursday, October 23, 2003 11:45 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Re: IRP_MJ_CLEANUP and FileObject->FsContext is NULL? ?

Not a stupid question – A better question here is “Why does
IoCreateStreamFile issue a CLEANUP?” My guess is that a handle was created
then closed – hence the CLEANUP. Or, perhaps it was supposed to signal the
FSD that a StreamFileObject was created. Of course, there may be some other
historic significance to this behavior better answered by the MS folks. Note
that if one calls IoCreateStreamFileLite, you do not get the gratuitous
CLEANUP.

Go figure… /ted

-----Original Message-----
From: Lyndon J. Clarke [mailto:xxxxx@neverfailgroup.com]
Sent: Thursday, October 23, 2003 10:38 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Re: IRP_MJ_CLEANUP and FileObject->FsContext is NULL? ?

Thanks Ted. Stupid question here … what is the meaning of a
IRP_MJ_CLEANUP, and indeed a FILE_OBJECT, for an “unopened” file? I thought
we got IRP_MJ_CLEANUP when the last hande tied to the file object was
closed.


You are currently subscribed to ntfsd as: xxxxx@livevault.com To unsubscribe
send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Tony, thanks. I understand the function of IoCreateStreamFileObjectLite
here, and why the FSD dont need to know about the Create its doing itself.

I am still completely puzzled about why I see the IRP_MJ_CLEANUP with
FileObject->FsContext as NULL.

FSD calls IoCreateStreamFileObject. This causes the I/O Manager to create a
new file object as well as a handle on the file object. The I/O Manager
then closes the file handle which causes the handle count to drop to zero,
which triggers the IRP_MJ_CLEANUP call - but keep in mind, this file object
has NEVER been seen by the FSD at that point. The file object is then sent
down the FSD stack (including filters). The FSD ignores it. Here is the
code from FAT:

TypeOfOpen = FatDecodeFileObject( FileObject, &Vcb, &Fcb, &Ccb );

//
// Special case the unopened file object. This will occur only when
// we are initializing Vcb and IoCreateStreamFileObject is being
// called.
//

if (TypeOfOpen == UnopenedFileObject) {

DebugTrace(0, Dbg, “Unopened File Object\n”, 0);

FatCompleteRequest( IrpContext, Irp, STATUS_SUCCESS );

DebugTrace(-1, Dbg, “FatCommonCleanup -> STATUS_SUCCESS\n”, 0);
return STATUS_SUCCESS;
}

There you go!

FYI: NTFS uses stream file objects much more extensively than FAT, so you
will see far more of these on NTFS than on FAT. But the logic is the same.

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
http://www.osronline.com

-----Original Message-----
From: Lyndon J. Clarke [mailto:xxxxx@neverfailgroup.com]
Sent: Thursday, October 23, 2003 12:46 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Re: IRP_MJ_CLEANUP and FileObject->FsContext is NULL? ?

Tony, thanks. I understand the function of IoCreateStreamFileObjectLite
here, and why the FSD dont need to know about the Create its doing itself.

I am still completely puzzled about why I see the IRP_MJ_CLEANUP with
FileObject->FsContext as NULL.


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Tony. I think I understand this now! Would I be right if I guessed
that this was a case where IoCreateStreamFileObject had been called with
the FileObject parameter value NULL?