Hard Links

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

Jedimaster
Member
Member
Posts: 11
Joined: 2004 Nov 30, 08:21

Hard Links

Post by Jedimaster »

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.
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

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
Jedimaster
Member
Member
Posts: 11
Joined: 2004 Nov 30, 08:21

Post by Jedimaster »

Hi Nikos,

I tested the hard link but it seems that whenever the original or link is modified, the other file does not get updated! I'm not sure if this is supposed to happen?
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

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!
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

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?
Dumb questions are the ones that are never asked :turn:
Jedimaster
Member
Member
Posts: 11
Joined: 2004 Nov 30, 08:21

Post by Jedimaster »

The file that I experimented on was just an ordinary Microsoft Excel worksheet. When I modified the link, the original worksheet did not get updated and the "links" column in X2 actually dropped back to 1. Looks like the hard link was destroyed there. Any idea how I can overcome this problem?
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

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
A.B.Ames
Member
Member
Posts: 33
Joined: 2004 Aug 07, 20:10

Post by A.B.Ames »

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
User avatar
JRz
Gold Member
Gold Member
Posts: 560
Joined: 2003 Jun 10, 23:19
Location: NL

Post by JRz »

No, a hard linked files don't have to have the same name! You can think of them as aliases for one file. So renaming one of the references won't change the other linked references!
Dumb questions are the ones that are never asked :turn:
A.B.Ames
Member
Member
Posts: 33
Joined: 2004 Aug 07, 20:10

Post by A.B.Ames »

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
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

just use the hard link column; that will tell you if a file has links or not
to make things easier you can rename all the files you hard link, adding a suffix like _HL that will serve as a reminder
A.B.Ames
Member
Member
Posts: 33
Joined: 2004 Aug 07, 20:10

Post by A.B.Ames »

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
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

if you have 2 files with identical sizes & checksums but otherwise different, there's no easy way to tell them apart in hard link guise. I'm not even sure if there's a programmatic way to find all hard links to a file!
A.B.Ames
Member
Member
Posts: 33
Joined: 2004 Aug 07, 20:10

Post by A.B.Ames »

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.
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

nice tool! i googled it and came up with this good article on links
http://shell-shocked.org/article.php?id=284