Waiting for ZwRead operation

Hi all,

When I open a file using ZwCreateFile and then do a file read using
ZwReadFile I soetimes get a STATUS_PENDING result from the read operation,
typically when the file is on the network.
Now, according to the DDK, if I opened the file with the ‘SYNCHRONIZE’ flag
I can ‘Wait on the file handle’ for the operation to be completed.
However, when I do the ‘KeWaitForSingleObject’ on the file handle I get a
bug check.
I know I can specify ‘FILE_SYNCHRONOUS_IO_NONALERT’ during file creation so
the system would wait automatically but I’m still curious.

Here is a code sample:

ZwCreateFile(&fileHandle,
GENERIC_READ | SYNCHRONIZE,
&ObjectAttributes,&IoStatusBlock, NULL, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_COMPLETE_IF_OPLOCKED,
NULL, 0);

if(ZwReadFile(fileHandle,NULL,NULL,NULL,&IoStatusBlock,
buffer,FILE_COPY_BUFFER_SIZE,&offsetSrc,NULL) == STATUS_PENDING)
KeWaitForSingleObject(&fileHandle, Executive, KernelMode, FALSE,
NULL);

Rami


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

KeWaitForSingleObject works against the KEVENT structure. Passing a handle
into this function should bugcheck.

If you wish to wait on a HANDLE you need to use an operation that waits for
a handle (e.g., the kernel function ZwWaitForSingleObject).

Regards,

Tony

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

-----Original Message-----
From: xxxxx@aliroo.com [mailto:xxxxx@aliroo.com]
Sent: Wednesday, November 28, 2001 11:28 PM
To: File Systems Developers
Subject: [ntfsd] Waiting for ZwRead operation

Hi all,

When I open a file using ZwCreateFile and then do a file read using
ZwReadFile I soetimes get a STATUS_PENDING result from the read operation,
typically when the file is on the network.
Now, according to the DDK, if I opened the file with the ‘SYNCHRONIZE’ flag
I can ‘Wait on the file handle’ for the operation to be completed.
However, when I do the ‘KeWaitForSingleObject’ on the file handle I get a
bug check.
I know I can specify ‘FILE_SYNCHRONOUS_IO_NONALERT’ during file creation so
the system would wait automatically but I’m still curious.

Here is a code sample:

ZwCreateFile(&fileHandle,
GENERIC_READ | SYNCHRONIZE,
&ObjectAttributes,&IoStatusBlock, NULL, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE | FILE_COMPLETE_IF_OPLOCKED,
NULL, 0);

if(ZwReadFile(fileHandle,NULL,NULL,NULL,&IoStatusBlock,
buffer,FILE_COPY_BUFFER_SIZE,&offsetSrc,NULL) == STATUS_PENDING)
KeWaitForSingleObject(&fileHandle, Executive, KernelMode, FALSE,
NULL);

Rami


You are currently subscribed to ntfsd as: xxxxx@osr.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com