Can I read locked file ?

Hi,
I’m writing a filter driver.
My driver is monitoring a folder and backup file that modified.
I trap IRP_MJ_WRITE and backup origin file to another folder.
Almost all the cases it works well except one case that a file is locked
by FastIOLock or IRP_MJ_LOCK_CONTROL.I got STATUS_FILE_LOCK_CONFLICT. :frowning:
How can I read locked file?

Thanks,

eddie.

You should look at OSR’s FAQ at http://www.osr.com/resources_ifsfaq.shtml

The following excerpt discusses this topic …

Q44 I need to read a range of the file but it has a byte range lock on it. How can I bypass these byte range locks?

Byte range locks are managed by the file system itself and are enforced for user-level IRP_MJ_READ and IRP_MJ_WRITE operations on the file. To avoid these operations, a file system filter driver can perform operations that do not involve byte range locks. Typically, this is done by accessing the file using paging I/O of some type. The simplest way to achieve this is to memory map the file. Memory mapping a file can be done in a user mode application or in the kernel using the ZwCreateSection, ZwMapViewOfSection, and MmMapViewInSystemSpace operations. Subsequent access to the file contents are done using this memory mapped data region; when data must be fetched from the file it is done so.

-----Original Message-----
From: xxxxx@hotmail.com [mailto:xxxxx@hotmail.com]
Sent: Tuesday, October 22, 2002 9:01 AM
To: File Systems Developers
Subject: [ntfsd] Can I read locked file ?

Hi,
I’m writing a filter driver.
My driver is monitoring a folder and backup file that modified.
I trap IRP_MJ_WRITE and backup origin file to another folder.
Almost all the cases it works well except one case that a file is locked
by FastIOLock or IRP_MJ_LOCK_CONTROL.I got STATUS_FILE_LOCK_CONFLICT. :frowning:
How can I read locked file?

Thanks,

eddie.


You are currently subscribed to ntfsd as: xxxxx@inflectionsystems.com
To unsubscribe send a blank email to %%email.unsub%%

hi,

i tried to roll my own read irp in normal reads and writes, setting the
flags with IRP_PAGING_IO|IRP_NOCACHE|IRP_SYNCHRONOUS_PAGING_IO, to try to
read back data prior that currently requested, and that might have been byte
locked, but will still get the STATUS_FILE_LOCK_CONFLICT error.

what is the proper way to avoid lock conflict using the paging io method?

thanks!

Ho Mun Chuen
@@ “Not everything that counts can be counted;
<” )~ and not everything that can be counted counts"
//\ … Albert Einstein
----- Original Message -----
From: “Tom Hansen”
To: “File Systems Developers”
Sent: Tuesday, October 22, 2002 9:11 PM
Subject: [ntfsd] RE: Can I read locked file ?

You should look at OSR’s FAQ at http://www.osr.com/resources_ifsfaq.shtml

The following excerpt discusses this topic …

Q44 I need to read a range of the file but it has a byte range lock on it.
How can I bypass these byte range locks?

Byte range locks are managed by the file system itself and are enforced for
user-level IRP_MJ_READ and IRP_MJ_WRITE operations on the file. To avoid
these operations, a file system filter driver can perform operations that do
not involve byte range locks. Typically, this is done by accessing the file
using paging I/O of some type. The simplest way to achieve this is to memory
map the file. Memory mapping a file can be done in a user mode application
or in the kernel using the ZwCreateSection, ZwMapViewOfSection, and
MmMapViewInSystemSpace operations. Subsequent access to the file contents
are done using this memory mapped data region; when data must be fetched
from the file it is done so.

-----Original Message-----
From: xxxxx@hotmail.com [mailto:xxxxx@hotmail.com]
Sent: Tuesday, October 22, 2002 9:01 AM
To: File Systems Developers
Subject: [ntfsd] Can I read locked file ?

Hi,
I’m writing a filter driver.
My driver is monitoring a folder and backup file that modified.
I trap IRP_MJ_WRITE and backup origin file to another folder.
Almost all the cases it works well except one case that a file is locked
by FastIOLock or IRP_MJ_LOCK_CONTROL.I got STATUS_FILE_LOCK_CONFLICT. :frowning:
How can I read locked file?

Thanks,

eddie.


You are currently subscribed to ntfsd as: xxxxx@inflectionsystems.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@pmail.ntu.edu.sg
To unsubscribe send a blank email to %%email.unsub%%

btw, i have also encountered the error returned when my write completion is
called. and my write completion will only be called if the io was paging.
and it was paging originally as well, ie. i did not change the bits. is the
error possible?

Ho Mun Chuen
@@ “Not everything that counts can be counted;
<” )~ and not everything that can be counted counts"
//\ … Albert Einstein
----- Original Message -----
From: “Ho Mun Chuen”
To: “File Systems Developers”
Sent: Monday, October 28, 2002 2:03 PM
Subject: [ntfsd] RE: Can I read locked file ?

hi,

i tried to roll my own read irp in normal reads and writes, setting the
flags with IRP_PAGING_IO|IRP_NOCACHE|IRP_SYNCHRONOUS_PAGING_IO, to try to
read back data prior that currently requested, and that might have been byte
locked, but will still get the STATUS_FILE_LOCK_CONFLICT error.

what is the proper way to avoid lock conflict using the paging io method?

thanks!

Ho Mun Chuen
@@ “Not everything that counts can be counted;
<” )~ and not everything that can be counted counts"
//\ … Albert Einstein
----- Original Message -----
From: “Tom Hansen”
To: “File Systems Developers”
Sent: Tuesday, October 22, 2002 9:11 PM
Subject: [ntfsd] RE: Can I read locked file ?

You should look at OSR’s FAQ at http://www.osr.com/resources_ifsfaq.shtml

The following excerpt discusses this topic …

Q44 I need to read a range of the file but it has a byte range lock on it.
How can I bypass these byte range locks?

Byte range locks are managed by the file system itself and are enforced for
user-level IRP_MJ_READ and IRP_MJ_WRITE operations on the file. To avoid
these operations, a file system filter driver can perform operations that do
not involve byte range locks. Typically, this is done by accessing the file
using paging I/O of some type. The simplest way to achieve this is to memory
map the file. Memory mapping a file can be done in a user mode application
or in the kernel using the ZwCreateSection, ZwMapViewOfSection, and
MmMapViewInSystemSpace operations. Subsequent access to the file contents
are done using this memory mapped data region; when data must be fetched
from the file it is done so.

-----Original Message-----
From: xxxxx@hotmail.com [mailto:xxxxx@hotmail.com]
Sent: Tuesday, October 22, 2002 9:01 AM
To: File Systems Developers
Subject: [ntfsd] Can I read locked file ?

Hi,
I’m writing a filter driver.
My driver is monitoring a folder and backup file that modified.
I trap IRP_MJ_WRITE and backup origin file to another folder.
Almost all the cases it works well except one case that a file is locked
by FastIOLock or IRP_MJ_LOCK_CONTROL.I got STATUS_FILE_LOCK_CONFLICT. :frowning:
How can I read locked file?

Thanks,

eddie.


You are currently subscribed to ntfsd as: xxxxx@inflectionsystems.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@pmail.ntu.edu.sg
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@pmail.ntu.edu.sg
To unsubscribe send a blank email to %%email.unsub%%