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

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

More Info on Driver Writing and Debugging

The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.

Check out The OSR Learning Library at:

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,152

    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
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Internals & Software Drivers 30 Nov 2020 LIVE ONLINE
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Developing Minifilters Early 2021 LIVE ONLINE