h_funcs.subr revision 272343
150476Speter#!/bin/sh 21987Swollman# 31987Swollman# $NetBSD: h_funcs.subr,v 1.3 2010/06/23 11:19:17 pooka Exp $ 41987Swollman# 5156813Sru# Copyright (c) 2007 The NetBSD Foundation, Inc. 6156813Sru# All rights reserved. 7100346Sru# 8100346Sru# Redistribution and use in source and binary forms, with or without 9100346Sru# modification, are permitted provided that the following conditions 10248484Sneel# are met: 11100346Sru# 1. Redistributions of source code must retain the above copyright 12233429Seadler# notice, this list of conditions and the following disclaimer. 13100346Sru# 2. Redistributions in binary form must reproduce the above copyright 14100346Sru# notice, this list of conditions and the following disclaimer in the 15100346Sru# documentation and/or other materials provided with the distribution. 16100346Sru# 17100346Sru# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18204076Spjd# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19100346Sru# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20206996Savg# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21100346Sru# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22214309Sjulian# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23100346Sru# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24238603Sjoerg# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25100346Sru# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26100346Sru# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27100346Sru# POSSIBILITY OF SUCH DAMAGE. 28100346Sru# 29100346Sru 30100346Sru# 31100346Sru# require_fs name 32100346Sru# 33100346Sru# Checks that the given file system is built into the kernel and 34132211Sscottl# that its corresponding mount(8) utility is available. Otherwise 354257Sphk# skips the test. 36100346Sru# 37100346Srurequire_fs() { 38100346Sru local name 39100346Sru local autoload 40100346Sru name="${1}" 41100346Sru 42100346Sru atf_require_prog mount 43100346Sru atf_require_prog mount_${name} 44100346Sru atf_require_prog umount 45100346Sru 46248484Sneel # if we have autoloadable modules, just assume the file system 47100346Sru atf_require_prog sysctl 48100346Sru autoload=$(sysctl -n kern.module.autoload) 49100346Sru [ "${autoload}" = "1" ] && return 0 50100346Sru 51100346Sru set -- $(sysctl -n vfs.generic.fstypes) 52100346Sru found=no 53100346Sru while [ ${#} -gt 1 ]; do 54233429Seadler if [ ${1} = ${name} ]; then 55100346Sru found=yes 56100346Sru break 57100346Sru fi 58100346Sru shift 59100346Sru done 60100346Sru [ ${found} = yes ] || \ 61100346Sru atf_skip "The kernel does not include support the " \ 62100346Sru "\`${name}' file system" 63100346Sru} 64100346Sru