Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

NTFS Error on rename operation with replace if its hardlink is opened

bastien_thonnatbastien_thonnat Member Posts: 26
edited December 2018 in NTFSD

Hello Guys,

I've read "A file cannot be renamed if a file with the same name exists and has open handles", from "FILE_RENAME_INFORMATION structure" documentation, in "Special rules for renaming open files" section.

So I have tried to create one hardlink on the file "with the same name" before the rename, and surprise, if the hardlink is opened, the rename operation fail.

May someone explain me why ?


  • rod_widdowsonrod_widdowson Member - All Emails Posts: 1,088

    Not sure I understand the question.

    You should think of rename as "Create hard link to new location, remove hardlink from old location". So if there is a restriction on the new name for rename it is likely to hold for creating a hard link.

    In general in Win32 you cannot delete a directory entry which is open. I would suspect that this extends to deleting files as well their DIRENTs (but I have never done the nature study).

    The WSL has introduced all sorts of funk "Posix" ways of deleting dir entries but let's not go there - mostly they don't matter unless you are implementing a real file system.

  • bastien_thonnatbastien_thonnat Member Posts: 26

    Thank you @rod_widdowson for this precision.

    I think I understand rename better.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Writing WDF Drivers 21 Oct 2019 OSR Seminar Space & ONLINE
Internals & Software Drivers 18 Nov 2019 Dulles, VA
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 27 Apr 2020 OSR Seminar Space & ONLINE