1272343Sngie#!/bin/sh 2272343Sngie# 3272343Sngie# $NetBSD: h_funcs.subr,v 1.3 2010/06/23 11:19:17 pooka Exp $ 4272343Sngie# 5272343Sngie# Copyright (c) 2007 The NetBSD Foundation, Inc. 6272343Sngie# All rights reserved. 7272343Sngie# 8272343Sngie# Redistribution and use in source and binary forms, with or without 9272343Sngie# modification, are permitted provided that the following conditions 10272343Sngie# are met: 11272343Sngie# 1. Redistributions of source code must retain the above copyright 12272343Sngie# notice, this list of conditions and the following disclaimer. 13272343Sngie# 2. Redistributions in binary form must reproduce the above copyright 14272343Sngie# notice, this list of conditions and the following disclaimer in the 15272343Sngie# documentation and/or other materials provided with the distribution. 16272343Sngie# 17272343Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18272343Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19272343Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20272343Sngie# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21272343Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22272343Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23272343Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24272343Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25272343Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26272343Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27272343Sngie# POSSIBILITY OF SUCH DAMAGE. 28272343Sngie# 29272343Sngie 30272343Sngie# 31272343Sngie# require_fs name 32272343Sngie# 33272343Sngie# Checks that the given file system is built into the kernel and 34272343Sngie# that its corresponding mount(8) utility is available. Otherwise 35272343Sngie# skips the test. 36272343Sngie# 37272343Sngierequire_fs() { 38272343Sngie local name 39272343Sngie local autoload 40272343Sngie name="${1}" 41272343Sngie 42272343Sngie atf_require_prog mount 43272343Sngie atf_require_prog mount_${name} 44272343Sngie atf_require_prog umount 45272343Sngie 46272343Sngie # if we have autoloadable modules, just assume the file system 47272343Sngie atf_require_prog sysctl 48313478Sngie # Begin FreeBSD 49313478Sngie if true; then 50313478Sngie if kldstat -m ${name}; then 51313478Sngie found=yes 52313478Sngie else 53313478Sngie found=no 54313478Sngie fi 55313478Sngie else 56313478Sngie # End FreeBSD 57272343Sngie autoload=$(sysctl -n kern.module.autoload) 58272343Sngie [ "${autoload}" = "1" ] && return 0 59272343Sngie 60272343Sngie set -- $(sysctl -n vfs.generic.fstypes) 61272343Sngie found=no 62272343Sngie while [ ${#} -gt 1 ]; do 63272343Sngie if [ ${1} = ${name} ]; then 64272343Sngie found=yes 65272343Sngie break 66272343Sngie fi 67272343Sngie shift 68272343Sngie done 69313478Sngie # Begin FreeBSD 70313478Sngie fi 71313478Sngie # End FreeBSD 72272343Sngie [ ${found} = yes ] || \ 73272343Sngie atf_skip "The kernel does not include support the " \ 74272343Sngie "\`${name}' file system" 75272343Sngie} 76