move file and target file name exists

I see the following behaviour in my FSD when the user does a move file to
a destination that already contains a file with thesaame name:

OPEN comes thru for the source file and directory.

OPEN comes thru for the destination file and directory, with the
SL_OPEN_TARGET_DIRECTORY flag set.

I tell the OS that “FILE_EXISTS” in the Iosb.Information field, and I set
Iosb.Status to “STATUS_OBJECT_NAME_COLLISION”.

In the DOS box where the user types in

“move \x\somefile.txt \y\somefile.txt”

(and \y\somefile.txt exists), they get prompted to overwrite the file or
quit the move operation. If they say overwrite, my FSD gets another open
for the target file name, and I respond with “FILE_EXISTS” in the
Iosb.Information field, and I set Iosb.Status to
“STATUS_OBJECT_NAME_COLLISION”, just like before.

The system then fails the “move” request with a message to the DOS box
that says “A duplicate file name exists, or the file name cannot be
found”. This DOES make sense to me, because of what the FSD returned.

I can’t seem to detect the difference in the two calls to open. On the
second call, if I set the return code to STATUS_SUCCESS and
FILE_DOES_NOT_EXIST in the Information field, the rename works.

What am I missing here? How do I tell?

This seems like a rather basic question, and I searched around a little in
this newsgroup for the answer, but could not find it. Any pointers to a
previous message thread about this owuld be great.

Thanks

Greg Pearce

Greg

Have you tried returning STATUS_SUCCESS with FILE_EXISTS for both ‘open’?
If I remember right this is what ntfs does.

Cheers
Lyndon

Thanks Lyndon…

No I have not tried that yet, but I will, and I’ll tell about it tomorrow.
Thanks! (it seems pretty obvious, I guess… duh!)

Cheers to you!

Greg

I tried setting status to success and info to file_exists for both calls.
Now I only get the first open, because the system doesn’t warn the user
and prompt for permission to replace the target. It also doesn’t set the
“Parameters.SetFile.ReplaceIfExists” flag, so the target cannot be
overwritten.

If all I do on the first open is to set status to
“status_object_name_collision” and info to “file_exists”, I get the prompt
to overwrite, and I get the second open. Then I use the debugger to
manually reply with status_success, and it works as expected.

I need to be able to tell when that 2nd open comes through and return
“success”, and I need to return “status_objecct_name_collision” on the
first open to get the prompt.

Dazed and confused,

Greg

Greg, I am for sure seeing ntfs is completing with status STATUS_SUCCESS
and information FILE_EXISTS in both of the target ‘open’. I am then seeing
the first rename - with ReplaceIfExists FALSE - fail with
STATUS_OBJECT_NAME_COLLISION - and then joe gets the Yes/No/All prompt,
and when joe says Yes, I am seeing the second rename - with
ReplaceIfExists TRUE - succeed.

Lyndon,

That was it! It’s working correctly now - thanks a lot for your help!

Regards,

Greg