1209513Simp#!/bin/sh 2209513Simp#- 3209552Simp# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4209513Simp# 5209513Simp# Redistribution and use in source and binary forms, with or without 6209513Simp# modification, are permitted provided that the following conditions 7209513Simp# are met: 8209513Simp# 1. Redistributions of source code must retain the above copyright 9209513Simp# notice, this list of conditions and the following disclaimer. 10209513Simp# 2. Redistributions in binary form must reproduce the above copyright 11209513Simp# notice, this list of conditions and the following disclaimer in the 12209513Simp# documentation and/or other materials provided with the distribution. 13209513Simp# 14209513Simp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15209513Simp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16209513Simp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17209513Simp# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18209513Simp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19209513Simp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20209513Simp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21209513Simp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22209513Simp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23209513Simp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24209513Simp# SUCH DAMAGE. 25209513Simp# 26209513Simp# $FreeBSD$ 27209513Simp 28211489SimpARGS=$1 29211730SimpFLAGS_MD="" 30212337SimpFLAGS_CD="" 31211730SimpFLAGS_VERBOSE="" 32211489Simp 33211730Simpshift 34211730Simpwhile [ -n "$1" ] 35211730Simpdo 36211730Simp case "$1" in 37211730Simp -m) 38211730Simp FLAGS_MD=1 39211730Simp ;; 40211730Simp -v) 41211730Simp FLAGS_VERBOSE=1 42211730Simp ;; 43212337Simp -c) 44212337Simp FLAGS_CD=1 45212337Simp ;; 46211730Simp esac 47211730Simp shift 48211730Simpdone 49211730Simp 50209513Simp# Create our device listing 51209513SimpSYSDISK=$(sysctl -n kern.disks) 52211730Simpif [ -n "${FLAGS_MD}" ] 53211489Simpthen 54211730Simp MDS=`mdconfig -l` 55211730Simp if [ -n "${MDS}" ] 56211730Simp then 57211730Simp SYSDISK="${SYSDISK} ${MDS}" 58211730Simp fi 59211489Simpfi 60209513Simp 61233222Sjpaetzel# Add any RAID devices 62233222Sjpaetzelif [ -d "/dev/raid" ] ; then 63233222Sjpaetzel cd /dev/raid 64233222Sjpaetzel for i in `ls` 65233222Sjpaetzel do 66233573Sjpaetzel SYSDISK="${SYSDISK} ${i}" 67233222Sjpaetzel done 68233222Sjpaetzelfi 69233222Sjpaetzel 70209513Simp# Now loop through these devices, and list the disk drives 71209513Simpfor i in ${SYSDISK} 72209513Simpdo 73209513Simp 74209513Simp # Get the current device 75209513Simp DEV="${i}" 76209513Simp 77209513Simp # Make sure we don't find any cd devices 78212337Simp if [ -z "${FLAGS_CD}" ] 79212337Simp then 80212337Simp case "${DEV}" in 81212337Simp acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;; 82212337Simp esac 83212337Simp fi 84209513Simp 85218975Sjpaetzel # Try and find some identification information with camcontrol or atacontrol 86233572Sjpaetzel NEWLINE=$(camcontrol identify $DEV 2>/dev/null | sed -ne 's/^device model *//p') 87209513Simp if [ -z "$NEWLINE" ]; then 88218975Sjpaetzel # Now try atacontrol 89233222Sjpaetzel NEWLINE=$(atacontrol list 2>/dev/null | sed -n "s|^.*$DEV <\(.*\)>.*|\1|p") 90218975Sjpaetzel 91218975Sjpaetzel if [ -z "$NEWLINE" ]; then 92218975Sjpaetzel NEWLINE=" <Unknown Device>" 93218975Sjpaetzel fi 94209513Simp fi 95211730Simp 96211730Simp if [ -n "${FLAGS_MD}" ] && echo "${DEV}" | grep -E '^md[0-9]+' >/dev/null 2>/dev/null 97211489Simp then 98211489Simp NEWLINE=" <Memory Disk>" 99211489Simp fi 100209513Simp 101211730Simp if [ -n "${FLAGS_VERBOSE}" ] 102211730Simp then 103211730Simp : 104211730Simp fi 105211730Simp 106209513Simp # Save the disk list 107209513Simp if [ ! -z "$DLIST" ] 108209513Simp then 109209513Simp DLIST="\n${DLIST}" 110209513Simp fi 111209513Simp 112209513Simp DLIST="${DEV}:${NEWLINE}${DLIST}" 113209513Simp 114209513Simpdone 115209513Simp 116209513Simp# Echo out the found line 117209513Simpecho -e "$DLIST" | sort 118