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 SYMLINKS
DragonFly supports a special kind of dynamic symbolic link called a
variant symlink. The source_file of a variant symlink may contain one or
more variable names. Each of these variable names is enclosed in braces
and preceded by a dollar sign in the style of variable references in
sh(1) and csh(1).
Whenever a variant symlink is followed, each variable found in
source_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. Regular
environ(7) environment variables are not used to resolve variant sym-
links.
EXAMPLE
sysctl -w vfs.varsym_enable=1
ln -s 'a${fubar}b' test
echo 'Hello' > axxb
echo 'Goodbye' > ayyb
varsym fubar=xx; cat test
varsym fubar=yy; cat test