Re: Hardlink support feasible?

Greg Troxel <[email protected]> Fri, 16 Jan 2026 19:20:24 -0500
Newsgroups gmane.network.unison.general
Message-ID <[email protected]>
Alan Savage <[email protected]> writes:

> Is it feasible to add hardlink support to Unison?
>
> My use case is an unstructured downloads folder used to seed torrents and a 
> structured folder containing hardlinks back to the downloads folder for use 
> with Jellyfin.
>
> E.g.
> /data/downloads/SomeMovie-1999.mkv
> /data/media/Movies/Some Movie (1999)/SomeMovie-1999.mkv # hardlinked with 
> downloads
>
> The /data folder would be synced with Unison between two computers over a 
> fairly slow WAN.
>
> I can potentially contribute code if the developers support the feature in 
> theory.

I'm not opposed in concept, but I don't understand exactly what you
mean.

I don't deal with movies or torrents, so it would be good to frame the
discussion purely in terms of hardlinked files :-)



It seems clear that if you have within the replica two directory entries
that are hard links to the same file (traditional unix hard link, not
trying to be complicated here), and on the other replica neither exist,
then propagation could create hardlinks to one file.

It would be good to analzye how rsync, syncthing and other programs do
or don't address this now.  Just running rsync -av, source NetBSD zfs,
dest NetBSD tmpfs, converted two names for one inode

  -rw-r--r--  2 gdt  wheel  1048576 Aug  2  2019 foo
  -rw-r--r--  2 gdt  wheel  1048576 Aug  2  2019 random.1M

into two files

  -rw-r--r--  1 gdt  wheel  1048576 Aug  2  2019 foo
  -rw-r--r--  1 gdt  wheel  1048576 Aug  2  2019 random.1M

adding H got me

  -rw-r--r--  2 gdt  wheel  1048576 Aug  2  2019 foo
  -rw-r--r--  2 gdt  wheel  1048576 Aug  2  2019 random.1M

so it may be instructive to understand rsync's edge cases.




I suspect that the first hard part is saying what should happen, in all
the edge cases.  Includes discussion of if hardlinks are specified by
POSIX and if real implementations follow POSIX.  Includes discussion of
what happens on filesystems without this facility.  And if A and B being
hardlinks on one side is a conflict vs A and B being independent files
on the other side (I vote yes, without thinking).  Then there's
hardlinks to out of the replica.

The second hard part is extending the sync protocol to represent
hardlinks and decomposing the rules for what happens into rules for the
two sides.

And finally the third part, to write code to do this.

I'd say the first part belongs here and the second two on unison-hackers.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].