Rename problem

Hi guys!

I met a problem.
I am working on a redirect FS minifilter driver, I redirect files and diectories from system volume to another volume.
It works except rename operation. E.g.:

User mode application rename directory ‘c:\windows\DirA’ to ‘c:\windows\DirB’,
The directory ‘c:\windows\DirA’ is redirected to ‘d:\cache\windows\DirB’, then iomgr send a create irp with ‘SL_OPEN_TARGET_DIRECTORY’ on to open ‘c:\windows’. I don’t know
which directory (‘c:\windows’ or ‘d:\cache\windows’) it really wants to open, so I let it passthrough and fs open ‘c:\windows’.

Here Problem comes, the directory to be renamed and the target directory are not in same volume, so there will be no rename irp. To user mode application, the rename operation is failed, so it exits.

What could I do to fix this problem?

Any help will be appreciate!

Thanks in advance!

Alex.

rename operation consists of these three steps (dirA -> dirB):
irp_mj_create (dirA) with DELETE flag
irp_mj_create (dirB) with SL_OPEN_TARGET_DIRECTORY flag (not dirB is
not accessed - only its parent folder)
irp_mj_set_information (FileRenameInformation class)

So, when you get SL_OPEN_TARGET_DIRECTORY, act as it’s a normal
IRP_MJ_CREATE request and redirect this IRP into your “cache” storage.

Petr

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Tuesday, October 27, 2009 12:36 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Rename problem

Hi guys!

I met a problem.
I am working on a redirect FS minifilter driver, I redirect files and
diectories from system volume to another volume.
It works except rename operation. E.g.:

User mode application rename directory ‘c:\windows\DirA’ to
‘c:\windows\DirB’,
The directory ‘c:\windows\DirA’ is redirected to ‘d:\cache\windows\DirB’,
then iomgr send a create irp with ‘SL_OPEN_TARGET_DIRECTORY’ on to open
‘c:\windows’. I don’t know
which directory (‘c:\windows’ or ‘d:\cache\windows’) it really wants to
open, so I let it passthrough and fs open ‘c:\windows’.

Here Problem comes, the directory to be renamed and the target directory are
not in same volume, so there will be no rename irp. To user mode
application, the rename operation is failed, so it exits.

What could I do to fix this problem?

Any help will be appreciate!

Thanks in advance!

Alex.


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

If you are redirecting request for say x directories you should do that every time. Here in this specific case you are giving called a file object from c: though he is expecting it to be in some other volume and hence encountering this error. redirect this request also and it should work.

Hi Petr,

Thanks for reply!

I make redirection only for special applications I concerned. I don’t
redirect objects for the others, like explorer.exe.
So what if explorer.exe wants to rename directory ‘c:\windows\dirA’ to
‘c:\windows\dirB’? (the former is not redirected by my filer, that is, it is
in 'c:\windows', not in my cache storage.)

On Tue, Oct 27, 2009 at 8:40 PM, Petr Kurtin wrote:

> rename operation consists of these three steps (dirA -> dirB):
> irp_mj_create (dirA) with DELETE flag
> irp_mj_create (dirB) with SL_OPEN_TARGET_DIRECTORY flag (not dirB is
> not accessed - only its parent folder)
> irp_mj_set_information (FileRenameInformation class)
>
> So, when you get SL_OPEN_TARGET_DIRECTORY, act as it’s a normal
> IRP_MJ_CREATE request and redirect this IRP into your “cache” storage.
>
> Petr
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of
> xxxxx@gmail.com
> Sent: Tuesday, October 27, 2009 12:36 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Rename problem
>
> Hi guys!
>
> I met a problem.
> I am working on a redirect FS minifilter driver, I redirect files and
> diectories from system volume to another volume.
> It works except rename operation. E.g.:
>
> User mode application rename directory ‘c:\windows\DirA’ to
> ‘c:\windows\DirB’,
> The directory ‘c:\windows\DirA’ is redirected to ‘d:\cache\windows\DirB’,
> then iomgr send a create irp with ‘SL_OPEN_TARGET_DIRECTORY’ on to open
> ‘c:\windows’. I don’t know
> which directory (‘c:\windows’ or ‘d:\cache\windows’) it really wants to
> open, so I let it passthrough and fs open ‘c:\windows’.
>
> Here Problem comes, the directory to be renamed and the target directory
> are
> not in same volume, so there will be no rename irp. To user mode
> application, the rename operation is failed, so it exits.
>
> What could I do to fix this problem?
>
> Any help will be appreciate!
>
> Thanks in advance!
>
> Alex.
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

I am sorry, my last reply was not accurate.

I make redirection only for special applications I concerned, and only for
objects it creates.

E.g., if it create a directory ‘c:\windows\dirA’, my filter redirects it to
my cache storage. If it open a existing directory, my filter will let it
open that directory.

The problem is, when create irp with SL_OPEN_TARGET_DIRECTORY on arrived, I
don’t know where the source directory is, therefore, I don’t know whether I
should redirect the create to my cache storage, or let it passthrough.

Thanks!

Alex.

>>The problem is, when create irp with SL_OPEN_TARGET_DIRECTORY on arrived, I don’t know where the source directory is

I am not concrete on it but this implementation looks like buggy as SL_OPEN_TARGET_DIRECTORY will be intended for the parent directory which may not be created by your applications and so as per your design you’ll leave them.

* Petr Kurtin wrote, On 27/10/09 12:40:

rename operation consists of these three steps (dirA -> dirB):
irp_mj_create (dirA) with DELETE flag
irp_mj_create (dirB) with SL_OPEN_TARGET_DIRECTORY flag (not dirB is
not accessed - only its parent folder)
irp_mj_set_information (FileRenameInformation class)

So, when you get SL_OPEN_TARGET_DIRECTORY, act as it’s a normal
IRP_MJ_CREATE request and redirect this IRP into your “cache” storage.

What about the case where irp_mj_set_information (FileRenameInformation
class) has rootdir of null, but a fully qualified unexpanded path?

rename.exe does this

In such a case FltGetDestinationFileNameInformation() can be used, and
I’m guessing now, after looking at this expanded name, maybe a new name
can be produced and replace the old one, and call FltSetCallbackDataDirty()

Sam

> Here Problem comes, the directory to be renamed and the target directory are not in same volume,

so there will be no rename irp.

You cannot rename/move across volumes.

IO manager has the check for it and fails it in a way your driver cannot alter.

So, user mode hooks are your only chance, AppInit_DLLs is one of the way to do them.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> If you are redirecting request for say x directories you should do that every time. Here in this specific

case you are giving called a file object from c: though he is expecting it to be in some other volume
and hence encountering this error. redirect this request also and it should work.

If he is renaming from non-redirected file to a redirected one, or vice versa - then this will not help and the user-mode hook is the only chance.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Hi, adi,

If the application open a existing directory ‘c:\windows\dirA’, and rename
it to ‘c:\windows\dirB’, I should let it open the real parent 'c:\windows'.
If the application create a new directory (which is redirected to my cache),
and rename it , I should let it open the cache parent ‘d:\cache\windows’.

My problem is, when I get a create irp with SL_OPEN_TARGET_DIRECTORY on, I
don’t know which parent directory should be opened, ‘c:\windows’ or
‘d:\cache\windows’.

Thanks for your reply and patient :slight_smile:

Alex.

Thanks very much, Maxim.

I will try user-mode hook. :slight_smile:

@Maxim

>If he is renaming from non-redirected file to a redirected one, or vice versa - then this will not help and the user-mode hook is the only chance.

What if the driver monitors all renames operations on the source drive? than it can check where this request falls and performs specific operations. in this case operations would be

non-redirected -> redirected
redirected -> non-redirected
re-directed - redirected
non-redirected - non - redirected !No need to handle this

We implemented this (with no hooks) for a encryption driver where the driver use to encrypt files targeted to a specific folder.

Am I missing any thing?

Thanks
Aditya

>>My problem is, when I get a create irp with SL_OPEN_TARGET_DIRECTORY on, I don’t know which parent directory should be opened, ‘c:\windows’ or ‘d:\cache\windows’.

That means you do not have a list of redirected directory/files with you where you can search whether you have re-directed this file or not? Its your driver which is changing the normal system flow and hence it is your driver which has to do the bookkeeping.

Thanks
Aditya

>>Here Problem comes, the directory to be renamed and the target directory are not in same volume, so there will be no rename irp. To user mode application, the rename operation is failed, so it exits.

What do you mean exactly bu this line?

When your application created c:\windows\DirA’ it was redirected to ‘d:\cache\windows\DirA’
Now the app renames c:\windows\DirA to c:\windows\DirB than you should rename d:\cache\windows\DirA to d:\cache\windows\DirB. Correct?

If this is correct than the rename is *not* across volumes? In fact there is no rename if volumes are different as file system’s metadata is different.

Thanks
Aditya

adi,
When and How do you know which the source object is?

On Wed, Oct 28, 2009 at 1:23 PM, wrote:

> @Maxim
> >>If he is renaming from non-redirected file to a redirected one, or vice
> versa - then this will not help and the user-mode hook is the only chance.
>
> What if the driver monitors all renames operations on the source drive?
> than it can check where this request falls and performs specific operations.
> in this case operations would be
>
> non-redirected -> redirected
> redirected -> non-redirected
> re-directed - redirected
> non-redirected - non - redirected !No need to handle this
>
> We implemented this (with no hooks) for a encryption driver where the
> driver use to encrypt files targeted to a specific folder.
>
> Am I missing any thing?
>
> Thanks
> Aditya
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

@Alex

Maxim talks about the issues you will face once you have you rename functionality working. I was confirming wit him that why it can not be done this way.

Adi,

If there is a directory ‘dirA’ in 'c:\windows' and a same name directory in
‘d:\cache\windows’.

When IoMgr open the target parent directory, which one should I open?

>>When IoMgr open the target parent directory, which one should I open?

How can I decide that ;-). Its your architecture and only you know it. I think the problem is that you are re-directing only in case of create and not in case of open. Any special thinking behind the reason?

Hi, adi.

I have to redirect open too.

Application create a file, after a while it would like to open that file. If
I don’t redirect the open, the application will not work :frowning:

You have to keep contexts of redirected (= created) files and folders in
your cache storage. When you create a file/folder you need to redirect
opens/creates into cache storage, if you remove a file/folder you need to
track these changes as well (+ renames) so when someone enumerates dir
content you have to remove the entries which were deleted/renamed and add
entries which exist in your cache storage, etc.

Finally, when you receive create IRP with SL_OPEN_TARGET_* flag, you have to
decide according to FileName (to be more specific: its parent folder’s
filename in this case) + your cache whether this request will be redirected
or not. Note that the same progress is done also for all other create IRPs,
so SL_OPEN_* handling is not something special.

Petr

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Alex
Sent: Wednesday, October 28, 2009 8:03 AM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] Rename problem

Adi,

If there is a directory ‘dirA’ in 'c:\windows' and a same name directory in
‘d:\cache\windows’.

When IoMgr open the target parent directory, which one should I open?

— NTFSD is sponsored by OSR For our schedule of debugging and file system
seminars (including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars To unsubscribe, visit the List Server section of
OSR Online at http://www.osronline.com/page.cfm?name=ListServer