1#!/usr/local/bin/ksh93 -p 2# vim: filetype=sh 3# 4# CDDL HEADER START 5# 6# The contents of this file are subject to the terms of the 7# Common Development and Distribution License (the "License"). 8# You may not use this file except in compliance with the License. 9# 10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11# or http://www.opensolaris.org/os/licensing. 12# See the License for the specific language governing permissions 13# and limitations under the License. 14# 15# When distributing Covered Code, include this CDDL HEADER in each 16# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17# If applicable, add the following below this CDDL HEADER, with the 18# fields enclosed by brackets "[]" replaced with your own identifying 19# information: Portions Copyright [yyyy] [name of copyright owner] 20# 21# CDDL HEADER END 22# 23 24# $FreeBSD$ 25 26# 27# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 28# Use is subject to license terms. 29# 30# ident "@(#)cachefile.kshlib 1.1 08/02/29 SMI" 31# 32 33 34# 35# A function to determine if a given pool name has an entry in cachefile 36# returns 1 if the pool is not in the cache, 0 otherwise. 37function pool_in_cache { 38 39 # checking for the pool name in the strings output of 40 # the given cachefile, default is /etc/zfs/zpool.cache 41 typeset cachefile=${2:-$CPATH} 42 43 if [[ -f $cachefile ]]; then 44 RESULT=$($STRINGS $cachefile | $GREP -w $1) 45 if [ -z "$RESULT" ] 46 then 47 return 1 48 fi 49 return 0 50 else 51 return 1 52 fi 53} 54