Here’s the patches for varsym for FreeBSD 8.0. These have been modified from the Dragonfly sources to work with FreeBSD. Thanks to Matthew Dillon for including varsym in Dragonfly and Andrey V. Elsukov for helping me with creating these patches. This patch set include the fix that allows realpath to work correctly (thanks to John De Boskey for helping debug this).
To apply the patches, and rebuild do the following:
- cd /usr
- patch < varsym.patches.8.0
- cd /usr/src/sys/kern && make sysent
- cd /usr/src/sys/compat/freebsd32 && make sysent
- cd /usr
- then make world and kernel and install both
Patch file is here:
http://www.drqware.com/downloads/varsym.patch.8.0
This is part of the ln manpage from a patched system describing varsym:
VARIANT SYMLINKSDragonFly supports a special kind of dynamic symbolic link called avariant symlink. The source_file of a variant symlink may contain one ormore variable names. Each of these variable names is enclosed in bracesand preceded by a dollar sign in the style of variable references insh(1) and csh(1).Whenever a variant symlink is followed, each variable found insource_file is replaced by its associated value. In this manner, a vari-ant symlink may resolve to different paths based on context. The facil-ity supports per-process, per-user, and system-wide varsyms.Varsym variables can be set with the varsym(1) utility. Regularenviron(7) environment variables are not used to resolve variant sym-links.EXAMPLEsysctl -w vfs.varsym_enable=1ln -s 'a${fubar}b' testecho 'Hello' > axxbecho 'Goodbye' > ayybvarsym fubar=xx; cat testvarsym fubar=yy; cat test