Copy on rename

I am writing a filter driver. In some cases when I
see a RENAME request, I would like to do a COPY
operation instead, but make it look like a rename to
everyone above me. I only want to do this if the
rename would have succeeded.

I think I know how to do the copy when the src file is
already open (by rolling read irps). But how can I
tell if the rename would work?

Should I let the rename work (or not) and then copy
back?

Just wondering what people have been able to get
working.

Thanks,

Randy


Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

Although I’ve never had to implement such functionality, it’s been
suggested on this list that you return STATUS_NOT_SAME_DEVICE to hint to
the caller that the file should be copied. Since it’s up to the caller
to take this hint (apparently they must pass the MOVEFILE_COPY_ALLOWED
flag to the MoveFileEx API), there’s no guarantee this will always work,
so if I were you I’d just perform the copy myself.

Rolling your own copy routine is an unholy bitch, however - you have to
copy the data, file attributes, file times, all 4 categories of security
information, alternate streams, extended attributes, etc. The CopyFile
API in user-mode handles all this ugliness for you - you may want to
consider having a user-mode app perform the copy on the driver’s behalf
(but watch out for potential deadlocks if you do this while blocking the
rename).

  • Nicholas Ryan

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Randy Cook
Sent: Tuesday, February 25, 2003 4:54 PM
To: File Systems Developers
Subject: [ntfsd] Copy on rename

I am writing a filter driver. In some cases when I
see a RENAME request, I would like to do a COPY
operation instead, but make it look like a rename to
everyone above me. I only want to do this if the
rename would have succeeded.

I think I know how to do the copy when the src file is
already open (by rolling read irps). But how can I
tell if the rename would work?

Should I let the rename work (or not) and then copy
back?

Just wondering what people have been able to get
working.

Thanks,

Randy


Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/


You are currently subscribed to ntfsd as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Randy,

For most scenarios, returning STATUS_NOT_SAME_DEVICE works. Not
always, though! For example, it won’t allow direct rename of a directory
in Explorer, but doing Cut&Paste will simulate a move even though a
Rename would work. That was sufficient for me.

Randy Cook wrote:

I am writing a filter driver. In some cases when I see a RENAME
request, I would like to do a COPY operation instead, but make it look
like a rename to everyone above me. I only want to do this if the
rename would have succeeded.

I think I know how to do the copy when the src file is already open
(by rolling read irps). But how can I tell if the rename would work?

Should I let the rename work (or not) and then copy back?

Just wondering what people have been able to get working.


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa File Monitor - File monitoring library for Win32 developers.

An application that will not handle a possibility of
STATUS_NOT_SAME_DEVICE is, IMO, broken.
NTFS mount points, and reparse filters make this status a reality, and
applications must be able to handle it

Nicholas Ryan wrote:

Although I’ve never had to implement such functionality, it’s been
suggested on this list that you return STATUS_NOT_SAME_DEVICE to hint to
the caller that the file should be copied. Since it’s up to the caller
to take this hint (apparently they must pass the MOVEFILE_COPY_ALLOWED
flag to the MoveFileEx API), there’s no guarantee this will always work,
so if I were you I’d just perform the copy myself.

Rolling your own copy routine is an unholy bitch, however - you have to
copy the data, file attributes, file times, all 4 categories of security
information, alternate streams, extended attributes, etc. The CopyFile
API in user-mode handles all this ugliness for you - you may want to
consider having a user-mode app perform the copy on the driver’s behalf
(but watch out for potential deadlocks if you do this while blocking the
rename).

  • Nicholas Ryan

> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Randy Cook
> Sent: Tuesday, February 25, 2003 4:54 PM
> To: File Systems Developers
> Subject: [ntfsd] Copy on rename
>
>
> I am writing a filter driver. In some cases when I
> see a RENAME request, I would like to do a COPY
> operation instead, but make it look like a rename to
> everyone above me. I only want to do this if the
> rename would have succeeded.
>
> I think I know how to do the copy when the src file is
> already open (by rolling read irps). But how can I
> tell if the rename would work?
>
> Should I let the rename work (or not) and then copy
> back?
>
> Just wondering what people have been able to get
> working.
>
> Thanks,
>
> Randy
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/


You are currently subscribed to ntfsd as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Kind regards, Dejan M. www.alfasp.com
E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa File Monitor - File monitoring library for Win32 developers.