File/Directory moving

Hi,

I am looking for some elegant solution for my task to prevent file/directory moving by renaming on same disk volume.
How do you know if you move the file or directory to some area on same disk volume as source the default system behaviour is to rename this file or directory. In opposite to the case when moving the file to the different disk volume. In this case will be created new file, will be copied data from the source file and source file will be removed.
How can I configure or tweak the default behaviour for same disk volume or volume folder. I want to acheive the create->copy->delete sequence (not rename) for the files or folders in same disk volume.
I know that I can set the SetFileInformation callback in my minifilter and to implement routine create->copy->delete secuence by myself, but perhaps it can be done simpler.

Thanks in advance,
Roman

>How can I configure or tweak the default behaviour for same disk volume or

volume folder.

This is really up to the component performing the rename. It’s been a long
known implementation detail of kernel32!MoveFileW that if you return
STATUS_NOT_SAME_DEVICE for the rename operation MoveFile will turn the
rename into a copy. However, with the introduction of MoveFileEx this
behavior is actually optional. Also, not all renames need be triggered by a
MoveFile(Ex) call.

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntfsd…

Hi,

I am looking for some elegant solution for my task to prevent file/directory
moving by renaming on same disk volume.
How do you know if you move the file or directory to some area on same disk
volume as source the default system behaviour is to rename this file or
directory. In opposite to the case when moving the file to the different
disk volume. In this case will be created new file, will be copied data from
the source file and source file will be removed.
How can I configure or tweak the default behaviour for same disk volume or
volume folder. I want to acheive the create->copy->delete sequence (not
rename) for the files or folders in same disk volume.
I know that I can set the SetFileInformation callback in my minifilter and
to implement routine create->copy->delete secuence by myself, but perhaps it
can be done simpler.

Thanks in advance,
Roman

Hi Scott,

Sorry for the late response and thanks for your advice. The STATUS_NOT_SAME_DEVICE status setting in PreSetFileInformation callback for rename operation works. Of cause the function must return FLT_PREOP_COMPLETE. After it set the MoveFile/Ex function begins to proceed the move operation as for the differnt disk volumes.

Best Regards,
Roman

Cool. Just remember that, as I mentioned, this is a user mode implementation
detail and *only* works with MoveFile or MoveFileEx with the appropriate
flag set. So, there’s no guarantee that you won’t find cases that won’t work
(the Recycle Bin on Win7 is an example of something that doesn’t call
MoveFileEx with the “copy OK” bit set).

-scott


Scott Noone
Consulting Associate and Chief System Problem Analyst
OSR Open Systems Resources, Inc.
http://www.osronline.com

wrote in message news:xxxxx@ntfsd…

Hi Scott,

Sorry for the late response and thanks for your advice. The
STATUS_NOT_SAME_DEVICE status setting in PreSetFileInformation callback for
rename operation works. Of cause the function must return
FLT_PREOP_COMPLETE. After it set the MoveFile/Ex function begins to proceed
the move operation as for the differnt disk volumes.

Best Regards,
Roman

Thanks Scott. Currently I am working on solution for known file managers as Win Explorer or
Totalcommander. These applications “behaves” OK. For other UM applications I just fail the rename operation with UI event.

Thanks,
Roman