#!/bin/sh # If /tmp isn't backed by a ZFS file system, change it to something that is. _base=/tmp if [ -z "$(zfs list -H -o mountpoint | grep ^$_base)" ]; then echo error: \'$_base\' is not backed by ZFS exit 1 fi _python=$(which python 2> /dev/null) _test() { local _file _symlink _py _file=$1 _mode=$2 if [ -z "$_mode" ]; then _mode=0007 fi _symlink=$_file.lnk _py="import os; print(repr(os.readlink('$_symlink')))" rm -rf $_file $_symlink echo file > $_file ln -s $_file $_symlink echo before chmod -h $_mode: ls -l $_file | awk '{ print $1 " " $9 };' ls -l $_symlink | awk '{ print $1 " " $9 $10 $11 };' if [ -f "$_python" ]; then echo "python os.readlink($_symlink): " eval "$_python" -c \""$_py"\" fi chmod -h $_mode $_symlink echo after chmod -h $_mode: ls -l $_file | awk '{ print $1 " " $9 };' ls -l $_symlink | awk '{ print $1 " " $9 $10 $11 };' if [ -f "$_python" ]; then echo "python os.readlink($_symlink): " eval "$_python" -c \""$_py"\" fi } _quick_test() { local _file _symlink _file=$1 _mode=$2 if [ -z "$_mode" ]; then _mode=0007 fi _symlink=$_file.lnk rm -rf $_file $_symlink echo file > $_file ln -s $_file $_symlink chmod -h $_mode $_symlink echo after chmod -h $_mode: ls -l $_symlink | awk '{ print $1 " " $9 $10 $11 };' } echo echo "****** TEST 1: link/target length less than 24 ******" _test $_base/lt24 echo " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" echo "target is padded out with NULLs to 24" echo; echo for _ in 1 2 ; do echo; done echo "****** TEST 2: link/target length longer than 24 ******" _test $_base/definitelywaylongerthantwentyfour echo " ^^^^^^^^^^^^^^^^^^^^^^^^" echo "target gets truncated to 24" echo; echo echo echo "****** Other modes... ******" _quick_test $_base/definitelywaylongerthantwentyfour 0006 _quick_test $_base/definitelywaylongerthantwentyfour 0005 _quick_test $_base/definitelywaylongerthantwentyfour 0004 _quick_test $_base/definitelywaylongerthantwentyfour 0000 echo; echo # vim:set ts=8 sw=4 sts=4 tw=78 et: