Hard Links
Moderators: fgagnon, nikos, Site Mods
-
Jedimaster
- Member

- Posts: 11
- Joined: 2004 Nov 30, 08:21
Hard Links
Is there any way to distinguish a hard links and the actual file it points to? I've a folder with hard links but I can't tell which are the link files and which are actual files. I might end up deleting the actual file instead of its hard link.
-
nikos
- Site Admin

- Posts: 16402
- Joined: 2002 Feb 07, 15:57
- Location: UK
you don't have to worry about such things
when you hard link a file, you increase a sort of reference counter on the one and only file object. It doesn't matter if you delete the original, as long as there is at least one hard link active, the object persists
there is a column that tells you how many links each object has, too
when you hard link a file, you increase a sort of reference counter on the one and only file object. It doesn't matter if you delete the original, as long as there is at least one hard link active, the object persists
there is a column that tells you how many links each object has, too
-
Jedimaster
- Member

- Posts: 11
- Joined: 2004 Nov 30, 08:21
-
nikos
- Site Admin

- Posts: 16402
- Joined: 2002 Feb 07, 15:57
- Location: UK
are you talking about file details as listed in x2? Sometimes you need to open a file so that its listing is properly updated
if you find that the file content is different, then you are using an editor that destroys hard links. Sadly some big names line the developer studio mess this up... Try editor2 for a program that does it properly!
if you find that the file content is different, then you are using an editor that destroys hard links. Sadly some big names line the developer studio mess this up... Try editor2 for a program that does it properly!
-
JRz
- Gold Member

- Posts: 560
- Joined: 2003 Jun 10, 23:19
- Location: NL
Nikos, I've seen this too. Didn't bother to report it since it is only a display problem. The actual file has been changed of course.
When you alter a file which has hard linked companions, the date & size info of the linked files won't change (the actually changed reference does display changed characteristics).
A refresh via Ctrl+R won't update the size and date info when any of the linked files has been changed. Only a 'real' action on the file will trigger the info to be updated. For instance viewing the file or inspecting its properties using F12.
Any idea what is happening here?
When you alter a file which has hard linked companions, the date & size info of the linked files won't change (the actually changed reference does display changed characteristics).
A refresh via Ctrl+R won't update the size and date info when any of the linked files has been changed. Only a 'real' action on the file will trigger the info to be updated. For instance viewing the file or inspecting its properties using F12.
Any idea what is happening here?
Dumb questions are the ones that are never asked 
-
Jedimaster
- Member

- Posts: 11
- Joined: 2004 Nov 30, 08:21
-
nikos
- Site Admin

- Posts: 16402
- Joined: 2002 Feb 07, 15:57
- Location: UK
here we see all the hard link related problems!
jan: this refresh problem looks like a ntfs limitation. Unless you open the file (eg F3) windows don't really pick up the change, and as a result neither does x2
yoda:
i just confirmed that m$ office is one of "those applications" that were written by monkeys and destroy hard links
I saw the mechanism for this browsing MFC source code, which must be what all these m$ tools were written with. When excel saves a file, instead of writing straight to the file you are editing (which would preserve the hard linking), it saves to a temp file, then deletes the original file and finally renames the temp file to the original filename (!)
i don't know the reason behind this madness but as you can clearly see such a sequence, whether you did that manually or a daft program did it for you, will destroy the link to the original file
there is no workaround or solution. You can only apply hard links to "compatible" programs. Or to files that are "read-only", ie you don't change often
jan: this refresh problem looks like a ntfs limitation. Unless you open the file (eg F3) windows don't really pick up the change, and as a result neither does x2
yoda:
i just confirmed that m$ office is one of "those applications" that were written by monkeys and destroy hard links
i don't know the reason behind this madness but as you can clearly see such a sequence, whether you did that manually or a daft program did it for you, will destroy the link to the original file
there is no workaround or solution. You can only apply hard links to "compatible" programs. Or to files that are "read-only", ie you don't change often
-
A.B.Ames
- Member

- Posts: 33
- Joined: 2004 Aug 07, 20:10
By modify file with Hard link you are referring to files contents only or does renaming change all too?
I ask this because i like the idea of using hard links but It seems that if i rename one hoping they all change it doesn't work.
Also another problem is if I do a dulicate search it finds the hard links aswell so i can't tell if they are hard links or actual copies using unneccisary hard drive space. Is there a way to prevent Duplicate finder from seeing Hard links?
Thanks Much
Tak Care
A.B.Ames
I ask this because i like the idea of using hard links but It seems that if i rename one hoping they all change it doesn't work.
Also another problem is if I do a dulicate search it finds the hard links aswell so i can't tell if they are hard links or actual copies using unneccisary hard drive space. Is there a way to prevent Duplicate finder from seeing Hard links?
Thanks Much
Tak Care
A.B.Ames
-
JRz
- Gold Member

- Posts: 560
- Joined: 2003 Jun 10, 23:19
- Location: NL
-
A.B.Ames
- Member

- Posts: 33
- Joined: 2004 Aug 07, 20:10
Thx JRz thats neat and allows a lot more flexability but...
Now it only adds to my problem, how does one know copies of files from hard links. I can understand that once files are hard linked they are all actually the same but there has to be a way to see the relationship.
I found a Cmd-line tool called hlscan from MS resource kit, it's handy but very time consuming with lots of files on a drive. Using the files' ID It finds all Hard links and displays them and their path. Now is there anyway to view the file ID's in Xplorer2 so one can compare Hard links and file copies?
Sorry for the trouble but maybe someone has an idea.
Thx Much
A.B.Ames
Now it only adds to my problem, how does one know copies of files from hard links. I can understand that once files are hard linked they are all actually the same but there has to be a way to see the relationship.
I found a Cmd-line tool called hlscan from MS resource kit, it's handy but very time consuming with lots of files on a drive. Using the files' ID It finds all Hard links and displays them and their path. Now is there anyway to view the file ID's in Xplorer2 so one can compare Hard links and file copies?
Sorry for the trouble but maybe someone has an idea.
Thx Much
A.B.Ames
-
nikos
- Site Admin

- Posts: 16402
- Joined: 2002 Feb 07, 15:57
- Location: UK
-
A.B.Ames
- Member

- Posts: 33
- Joined: 2004 Aug 07, 20:10
Hi nikos,
Thx for showing me the obvious i feel dumb talking about being able to rename them and not even thinking about renaming them so i can tell.
sorry bout that.
In regard to using the hard link column, I was aware of that but i wouldn't be able to tell which were which if some how I had 10 copies each with 10 hard links. Al I would see in the column would be 100 duplicates showing 10 hard links each.
Sorry i didn't explain that better, but thx again for giving me a good solution that I should have seen.
Take Care
A.B.Ames
Thx for showing me the obvious i feel dumb talking about being able to rename them and not even thinking about renaming them so i can tell.
sorry bout that.
In regard to using the hard link column, I was aware of that but i wouldn't be able to tell which were which if some how I had 10 copies each with 10 hard links. Al I would see in the column would be 100 duplicates showing 10 hard links each.
Sorry i didn't explain that better, but thx again for giving me a good solution that I should have seen.
Take Care
A.B.Ames
-
nikos
- Site Admin

- Posts: 16402
- Joined: 2002 Feb 07, 15:57
- Location: UK
-
A.B.Ames
- Member

- Posts: 33
- Joined: 2004 Aug 07, 20:10
Just for anyones info:
hlscan actually works well at locating Hard Links and their relationships.
if interested:
http://www.microsoft.com/windows2000/te ... scan-o.asp
Here's a sample using 2 identical files Original.pdf & a copy of it Orig_copy.pdf, then creating several hard links of each.
Both are the same file but the program doesn't know that. It just knows there are 2 files (copies of each other) shown by the ID# and several hard links of each (shown under the apropriate ID#). I even made a Hard Link of a Hard Link for testing. The Missing: refers to any hard links it knows of that were outside of my search path, but as i gave it E: it located all (so 0 missing).
---------------------------------------------------------
c:\hlscan /dir e:
Hard Links Report for \\W2K-DUAL
Report Time: 12/03/2004 15:22:43
Scanned Areas: e:\
Hard Links Found in e:\ (recursive search):
ID: 0x400000000007e - Hard Links Count: 4 - Missing: 0
Creation Time: 12/03/2004 14:27:32
Last Access Time: 12/03/2004 15:15:22
e:\_TEMP\HL test\ORIGINAL.PDF
e:\_TEMP\HL test\hltest2\HL1_of ORIG.PDF
e:\_TEMP\HL test\hltest2\HL2_of ORIG.PDF
e:\_TEMP\HL test\HLtest1\HL of HL1_of ORIG.PDF
ID: 0x26f0000000000080 - Hard Links Count: 3 - Missing: 0
Creation Time: 12/03/2004 14:28:54
Last Access Time: 12/03/2004 15:14:50
e:\_TEMP\HL test\hltest2\HL1_of ORIG_copy.PDF
e:\_TEMP\HL test\hltest2\HL2_of ORIG_copy.PDF
e:\_TEMP\HL test\HLtest1\ORIG_copy.PDF
Summary:
Files scanned: 2060
Physical files with more than one name: 2
Hard links: 7
----------------------------------------------------------
It's Just that it can't see copies, only seperate files and being command line isn't easy viewing lots of files.
If I get time I going to play around and try to create a script that will Use HLscan (and other appz) to display a list of Hard Links that have duplicates.
hlscan actually works well at locating Hard Links and their relationships.
if interested:
http://www.microsoft.com/windows2000/te ... scan-o.asp
Here's a sample using 2 identical files Original.pdf & a copy of it Orig_copy.pdf, then creating several hard links of each.
Both are the same file but the program doesn't know that. It just knows there are 2 files (copies of each other) shown by the ID# and several hard links of each (shown under the apropriate ID#). I even made a Hard Link of a Hard Link for testing. The Missing: refers to any hard links it knows of that were outside of my search path, but as i gave it E: it located all (so 0 missing).
---------------------------------------------------------
c:\hlscan /dir e:
Hard Links Report for \\W2K-DUAL
Report Time: 12/03/2004 15:22:43
Scanned Areas: e:\
Hard Links Found in e:\ (recursive search):
ID: 0x400000000007e - Hard Links Count: 4 - Missing: 0
Creation Time: 12/03/2004 14:27:32
Last Access Time: 12/03/2004 15:15:22
e:\_TEMP\HL test\ORIGINAL.PDF
e:\_TEMP\HL test\hltest2\HL1_of ORIG.PDF
e:\_TEMP\HL test\hltest2\HL2_of ORIG.PDF
e:\_TEMP\HL test\HLtest1\HL of HL1_of ORIG.PDF
ID: 0x26f0000000000080 - Hard Links Count: 3 - Missing: 0
Creation Time: 12/03/2004 14:28:54
Last Access Time: 12/03/2004 15:14:50
e:\_TEMP\HL test\hltest2\HL1_of ORIG_copy.PDF
e:\_TEMP\HL test\hltest2\HL2_of ORIG_copy.PDF
e:\_TEMP\HL test\HLtest1\ORIG_copy.PDF
Summary:
Files scanned: 2060
Physical files with more than one name: 2
Hard links: 7
----------------------------------------------------------
It's Just that it can't see copies, only seperate files and being command line isn't easy viewing lots of files.
If I get time I going to play around and try to create a script that will Use HLscan (and other appz) to display a list of Hard Links that have duplicates.
-
nikos
- Site Admin

- Posts: 16402
- Joined: 2002 Feb 07, 15:57
- Location: UK
nice tool! i googled it and came up with this good article on links
http://shell-shocked.org/article.php?id=284
http://shell-shocked.org/article.php?id=284