topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday April 19, 2024, 10:33 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - namsupo [ switch to compact view ]

Pages: [1]
1
General Software Discussion / Re: keeping/saving cloned files
« on: October 21, 2007, 02:46 PM »
Hard links do work quite reliably on NTFS, the problem is the way Word is saving files.

All files are hard links. A filename in a directory is just a record in the file system of a bunch of data located somewhere on the disk. When you create a hard link to an existing file, all you are doing is creating another filename entry to the same block of data. The two entries are indistinguishable. There is literally no way to tell which one was the original and which one is the hard link.

The problem described above arises because of the way Word saves files. Instead of opening the existing file, clearing out its contents and then writing new data, Word does what is called a "safe save". That is, it write the new document to a temporary file first. Once the file has been safely written to disk, it deletes the original file, and renames the temporary file.

This causes a problem when you have two hard links pointing to the same chunk of data, as deleting one of the links does not delete the data. All it does is delete the duplicate filename record. It is only when the last hard link to a file is deleted that the actual data is removed.

So in the above scenario with Word, one of the hard links is deleted during the safe save process, but the other one is not (since Word doesn't know anything about it.) Word then renames its temporary file back to the name of the original, but this is now a new filename record pointing to a new chunk of data. The remaining hard link to the old data is still present, still works, and still points to the old data.

I think it's reasons like this that explain why Microsoft draw such little attention to the linking abilities of NTFS - it's not that they don't work, it's just that they can easily cause confusion when you don't quite understand how it works.

Pages: [1]