# These names are magic for patch 102209-01.
# Don't change them or / & /usr can't be of type cachefs.
# /usr as cachefs alone isn't supported in the cacheos scripts.
# So we put the cache in /
croot=/.cache
cdir=$croot/rootcache

if [ -d ${newroot}/$croot ]
then
    echo Initing cachefs
    readvfstab $croot && mountfs
    /usr/sbin/cfsadmin -c ${newroot}$cdir
    echo "Converting vfstab for cachefs mounts."
    for mnt in /usr /usr/kvm /opt /usr/local
    do
	if readvfstab $mnt && [ "$fstype" = nfs ]
	then
	    echo "Fixing $mnt"
	    if [ "x$mntopts" = x- ]; then mntopts=; fi
	    opts=cachedir=$cdir,backfstype=$fstype${mntopts:+,$mntopts}
	    nawk -v mnt=$mnt -v opts="$opts" '
		$3 == mnt && $4 == "nfs" { $4="cachefs" ; $7 = opts }
		{ print } ' < ${newroot}/etc/vfstab > /tmp/vfstab.new
	    mv /tmp/vfstab.new  ${newroot}/etc/vfstab
	fi
    done
fi
