Feature: Preserve symlinks, hard links, and special files (-l, -H, -D) #177
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Corresponding rsync flags/behavior:
-l, --links— copy symlinks as symlinks-H, --hard-links— preserve hard links-D— preserve device and special files (same as--devices --specials)Current FastSync behavior:
scanner.c:102usesstat()(notlstat()), so symlinks are followed transparently and never preserved as symlinks. Hard links are not tracked, so each link target is transferred independently. Device/special files are skipped becauseS_ISDIR/S_ISREGchecks only handle directories and regular files.Proposed changes:
-l/--links,-H/--hard-links,-D/--devices --specialsbool preserve_symlinks,bool preserve_hard_links,bool preserve_devicesFileMetadatawith a file-type field (regular, symlink, directory, device, fifo, socket)lstat()when any preserve flag is setst_rdevsymlink(), devices withmknod(), and hard links withlink()Priority: high
Rationale: Preserving symlinks and hard links is fundamental for backups, build-artifact sync, and POSIX fidelity. Following symlinks can also be a security risk.
Acceptance criteria:
client -l /src /dstrecreates symlinks with the correct targetsclient -H /src /dsttransfers a hard-linked file only once and links the restclient -D /src /dstrecreates device/special files when running as root