Return values for MJ_READ and MJ_DIR_CONTROL

Hello,
I have some troubles with my filter.
Its main idea is to emulate the existance
of a directory with subdirs and files.
It hooks the IRP calls to these files and
dirs and process them without calling the
lower driver.
Some file IO functions from
applications are operated correctly -
MJ_CREATE, CLOSE, CLEANUP, QUERY_INFORMATION,
but READ and DIRECTORY_CONTROL sometimes
return error values, though in the log
I see, that filter completed these IRPs.

I need the information on these topics:

I) The return values in Irp->IoStatus for
IRP_MJ_READ in the cases of

  1. Parameters.Read.Offset > (File length)
    (I suppose STATUS_END_OF_FILE and
    Information=0);
  2. (Parameters.Read.Offset +
    Parameters.Read.Length) > (File length)
    (I set STATUS_END_OF_FILE and Info=
    (File length)-Parameters.Read.Offset)
  3. All OK - no read after EOF -
    STATUS_SUCCESS and Parameters.Read.Length

II) return values for DIRECTORY_CONTROL
I set the STATUS_SUCCESS and Inforamation=
(QUERY_DIRECTORY)Parameters.Length

III) How can I determine, which buffer to use,
when my filterrr receive the IRP:
AssociatedIrp->SystemBuffer or from MdlAddress

Do not reference me to any Kits and books. I have
only DDK and its impossible for me to buy IFSKit.
Sincerely Yours,
Andrew

Hi Andrew!

I) 1 and 3) OK
2) Information is OK but the status
in this case should be STATUS_SUCCESS
(no matter the buffer was filled partially)
II) it depends on the operation result:

  • if you fill whole buffer, you’re right
  • if you fill not the whole buffer you must return
    real filled length
  • if you complete the QUERY with STATUS_NO_MORE_FILES
    or STATUS_NO_SUCH_FILE the Information is ignored

III) If the Irp->MdlAddress is non-NULL, the buffer is
described by this MDL.
If the Irp->MdlAddress is NULL and the request is
buffered, the Irp->AssociatedIrp.SystemBuffer is
the buffer.
In any other case the buffer is Irp->UserBuffer.

Paul

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of
andrew@at.pstu.ac.ru
Sent: Tuesday, September 05, 2000 12:00 AM
To: File Systems Developers
Subject: [ntfsd] Return values for MJ_READ and MJ_DIR_CONTROL


From: andrew@at.pstu.ac.ru[SMTP:ANDREW@AT.PSTU.AC.RU]
Sent: Tuesday, September 05, 2000 2:00:00 AM
To: File Systems Developers
Subject: [ntfsd] Return values for MJ_READ and MJ_DIR_CONTROL
Auto forwarded by a Rule

Hello,
I have some troubles with my filter.
Its main idea is to emulate the existance
of a directory with subdirs and files.
It hooks the IRP calls to these files and
dirs and process them without calling the
lower driver.
Some file IO functions from
applications are operated correctly -
MJ_CREATE, CLOSE, CLEANUP, QUERY_INFORMATION,
but READ and DIRECTORY_CONTROL sometimes
return error values, though in the log
I see, that filter completed these IRPs.

I need the information on these topics:

I) The return values in Irp->IoStatus for
IRP_MJ_READ in the cases of

  1. Parameters.Read.Offset > (File length)
    (I suppose STATUS_END_OF_FILE and
    Information=0);
  2. (Parameters.Read.Offset +
    Parameters.Read.Length) > (File length)
    (I set STATUS_END_OF_FILE and Info=
    (File length)-Parameters.Read.Offset)
  3. All OK - no read after EOF -
    STATUS_SUCCESS and Parameters.Read.Length

II) return values for DIRECTORY_CONTROL
I set the STATUS_SUCCESS and Inforamation=
(QUERY_DIRECTORY)Parameters.Length

III) How can I determine, which buffer to use,
when my filterrr receive the IRP:
AssociatedIrp->SystemBuffer or from MdlAddress

Do not reference me to any Kits and books. I have
only DDK and its impossible for me to buy IFSKit.
Sincerely Yours,
Andrew


You are currently subscribed to ntfsd as: xxxxx@sodatsw.cz
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

> I) The return values in Irp->IoStatus for

IRP_MJ_READ in the cases of

  1. Parameters.Read.Offset > (File length)
    (I suppose STATUS_END_OF_FILE and
    Information=0);
  2. (Parameters.Read.Offset +
    Parameters.Read.Length) > (File length)
    (I set STATUS_END_OF_FILE and Info=
    (File length)-Parameters.Read.Offset)
  3. All OK - no read after EOF -
    STATUS_SUCCESS and Parameters.Read.Length

IIRC you must use STATUS_SUCCESS in the second case, but Information field
must be set to the real number of bytes read, not to the requested number.
Paging reads beyound the ValidDataLength (when Parameters.Read.Offset >
ValidDataLength) can be failed with STATUS_END_OF_FILE - MM
(MiWaitForInPageComplete function) will automatically zero pages for you.

II) return values for DIRECTORY_CONTROL
I set the STATUS_SUCCESS and Inforamation=
(QUERY_DIRECTORY)Parameters.Length

Directory control is a complex function - see FASTFAT sample for the details
of it.

III) How can I determine, which buffer to use,
when my filterrr receive the IRP:
AssociatedIrp->SystemBuffer or from MdlAddress

Look in DO_xxx flags of the target device object. BTW - your filter device
object must have the same flag values as the target.

Max