From: ND on

I am writing a virtual disk driver which uses a file as a virtual disk.

The disk file can be mounted with a drive letter and normally used.
Internally,
ZwReadFile and ZwWriteFile in the dispatch routine for IRP_MJ_READ and
IRP_MJ_WRITE do
the job to write on and read from "disk". As far, everything works
fine.

In this ,after mounting in explorer window if i make any file copy
operation,IRP_MJ_WRITE was called.

Also,IRP_MJ_WRITE was called many times after i copied a single file.So my
question is,
How many IRPs will be sent for file copy operation.How the IRPs are formed
by IO manager.
How i can trace start and end of copy operation.

since,in IRP_MJ_WRITE ,I am writing into a file.Also this file is shared
between two driver instances.

Looking forward to get reply.

Thanks ,
ND


From: Don Burn on
You have no way of knowing about copy operations, all you can know is that
something is being read or written. Even if you figured out for the shell
what the copy rules were, they would be different for CMD.EXE and then for
any other program.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



"ND" <ND(a)discussions.microsoft.com> wrote in message
news:1BCB184F-5028-40A1-8B73-885DDF98B0BE(a)microsoft.com...
>
> I am writing a virtual disk driver which uses a file as a virtual disk.
>
> The disk file can be mounted with a drive letter and normally used.
> Internally,
> ZwReadFile and ZwWriteFile in the dispatch routine for IRP_MJ_READ and
> IRP_MJ_WRITE do
> the job to write on and read from "disk". As far, everything works
> fine.
>
> In this ,after mounting in explorer window if i make any file copy
> operation,IRP_MJ_WRITE was called.
>
> Also,IRP_MJ_WRITE was called many times after i copied a single file.So my
> question is,
> How many IRPs will be sent for file copy operation.How the IRPs are formed
> by IO manager.
> How i can trace start and end of copy operation.
>
> since,in IRP_MJ_WRITE ,I am writing into a file.Also this file is shared
> between two driver instances.
>
> Looking forward to get reply.
>
> Thanks ,
> ND
>
>


From: ND on
Hi,

I found following reply.

Yes i can know through IRP_MJ_WRITE..But how to pre-determine number of
IRP_MJ_WRITE requests .Since ,I need to lock a file when write operation
starts and need to free at end of write operation.

Simply,I need to lock a file until copy or write operation ends.Otherwise
how to avoid dispatch routine to be called many times for single copy
operation.

Looking forward to hear from you.

Thanks
ND

"Don Burn" wrote:

> You have no way of knowing about copy operations, all you can know is that
> something is being read or written. Even if you figured out for the shell
> what the copy rules were, they would be different for CMD.EXE and then for
> any other program.
>
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
>
>
> "ND" <ND(a)discussions.microsoft.com> wrote in message
> news:1BCB184F-5028-40A1-8B73-885DDF98B0BE(a)microsoft.com...
> >
> > I am writing a virtual disk driver which uses a file as a virtual disk.
> >
> > The disk file can be mounted with a drive letter and normally used.
> > Internally,
> > ZwReadFile and ZwWriteFile in the dispatch routine for IRP_MJ_READ and
> > IRP_MJ_WRITE do
> > the job to write on and read from "disk". As far, everything works
> > fine.
> >
> > In this ,after mounting in explorer window if i make any file copy
> > operation,IRP_MJ_WRITE was called.
> >
> > Also,IRP_MJ_WRITE was called many times after i copied a single file.So my
> > question is,
> > How many IRPs will be sent for file copy operation.How the IRPs are formed
> > by IO manager.
> > How i can trace start and end of copy operation.
> >
> > since,in IRP_MJ_WRITE ,I am writing into a file.Also this file is shared
> > between two driver instances.
> >
> > Looking forward to get reply.
> >
> > Thanks ,
> > ND
> >
> >
>
>
>
From: Maxim S. Shatskih on
> How many IRPs will be sent for file copy operation.

Nobody knows for sure, this depends, for instance, on what way was used for
file copying.

> How i can trace start and end of copy operation.

You cannot. Reading the source and writing the destination are 2 absolutely
unrelated processes to the kernel, the kernel does not know this is a copy.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim(a)storagecraft.com
http://www.storagecraft.com

From: ND on

Hi Maxim Shantskih,

Thanks for your reply.

We are creating virtual disk within a file and mounts it as a real disk.

Normaly only one user can mount that file as disk, and use it. But now we
want multiple user can mount this file in network, as real disk in there
own PC, and use it.Like NFS.

We did this by giving FILE_SHARE_WRITE access to file ,while file creation
using ZwCreateFile.
With this multiple user(multiple pcs) can mount this file as virtual
disk.And when user updates this virtual volume,the disk file is updated.
Now problem is ,when mutiple users trying to update from different pcs I
could not maintain offset of the diskfile.So the data lost.

I could know user operation through IRP_MJ_XXX.But how i can share this file
among driver instances.


we planned to lock this file for synchronization.or is there any other way
to achieve this.

Waiting for your reply.
Thanks

"Maxim S. Shatskih" wrote:

> > How many IRPs will be sent for file copy operation.
>
> Nobody knows for sure, this depends, for instance, on what way was used for
> file copying.
>
> > How i can trace start and end of copy operation.
>
> You cannot. Reading the source and writing the destination are 2 absolutely
> unrelated processes to the kernel, the kernel does not know this is a copy.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim(a)storagecraft.com
> http://www.storagecraft.com
>
>