10696600cSBjoern A. Zeeb#!/bin/sh 20696600cSBjoern A. Zeeb# 30696600cSBjoern A. Zeeb# Copyright (c) 1999 Matt Dillon 40696600cSBjoern A. Zeeb# All rights reserved. 50696600cSBjoern A. Zeeb# 60696600cSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without 70696600cSBjoern A. Zeeb# modification, are permitted provided that the following conditions 80696600cSBjoern A. Zeeb# are met: 90696600cSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright 100696600cSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer. 110696600cSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright 120696600cSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer in the 130696600cSBjoern A. Zeeb# documentation and/or other materials provided with the distribution. 140696600cSBjoern A. Zeeb# 150696600cSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 160696600cSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 170696600cSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 180696600cSBjoern A. Zeeb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 190696600cSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 200696600cSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 210696600cSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 220696600cSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 230696600cSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 240696600cSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 250696600cSBjoern A. Zeeb# SUCH DAMAGE. 260696600cSBjoern A. Zeeb# 270696600cSBjoern A. Zeeb# 280696600cSBjoern A. Zeeb 290696600cSBjoern A. Zeeb# PROVIDE: tmp 307e4eca71SGleb Smirnoff# REQUIRE: mountcritlocal 310696600cSBjoern A. Zeeb 320696600cSBjoern A. Zeeb. /etc/rc.subr 330696600cSBjoern A. Zeeb 340696600cSBjoern A. Zeebname="tmp" 350696600cSBjoern A. Zeebdesc="Configure tmpfs" 360696600cSBjoern A. Zeebstop_cmd=':' 370696600cSBjoern A. Zeeb 380696600cSBjoern A. Zeebload_rc_config $name 390696600cSBjoern A. Zeeb 40*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj: mounting 41*f99f0ee1SAlexander Leidingertmp_svcj="NO" 42*f99f0ee1SAlexander Leidinger 430696600cSBjoern A. Zeebmount_tmpmfs() 440696600cSBjoern A. Zeeb{ 4524f44a44SStefan Eßer while read line; do 4624f44a44SStefan Eßer case $line in 4724f44a44SStefan Eßer /dev/md[0-9]*\ /tmp) 4824f44a44SStefan Eßer return;; 4924f44a44SStefan Eßer esac 5024f44a44SStefan Eßer done <<*EOF 5124f44a44SStefan Eßer$(df /tmp) 5224f44a44SStefan Eßer*EOF 530696600cSBjoern A. Zeeb mount_md ${tmpsize} /tmp "${tmpmfs_flags}" 540696600cSBjoern A. Zeeb chmod 01777 /tmp 550696600cSBjoern A. Zeeb} 560696600cSBjoern A. Zeeb 570696600cSBjoern A. Zeeb# If we do not have a writable /tmp, create a memory 580696600cSBjoern A. Zeeb# filesystem for /tmp. If /tmp is a symlink (e.g. to /var/tmp, 590696600cSBjoern A. Zeeb# then it should already be writable). 600696600cSBjoern A. Zeeb# 610696600cSBjoern A. Zeebcase "${tmpmfs}" in 620696600cSBjoern A. Zeeb[Aa][Uu][Tt][Oo]) 6324f44a44SStefan Eßer _tmpdir=/tmp/.diskless.$(dd if=/dev/random bs=32 count=1 status=none | sha256) 6424f44a44SStefan Eßer if mkdir -m 0700 ${_tmpdir}; then 650696600cSBjoern A. Zeeb rmdir ${_tmpdir} 660696600cSBjoern A. Zeeb else 670696600cSBjoern A. Zeeb if [ -h /tmp ]; then 680696600cSBjoern A. Zeeb echo "*** /tmp is a symlink to a non-writable area!" 690696600cSBjoern A. Zeeb echo "dropping into shell, ^D to continue anyway." 700696600cSBjoern A. Zeeb /bin/sh 710696600cSBjoern A. Zeeb else 720696600cSBjoern A. Zeeb mount_tmpmfs 730696600cSBjoern A. Zeeb fi 740696600cSBjoern A. Zeeb fi 750696600cSBjoern A. Zeeb ;; 760696600cSBjoern A. Zeeb*) 770696600cSBjoern A. Zeeb if checkyesno tmpmfs; then 780696600cSBjoern A. Zeeb mount_tmpmfs 790696600cSBjoern A. Zeeb fi 800696600cSBjoern A. Zeeb ;; 810696600cSBjoern A. Zeebesac 82