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 28209513Simp# Query a disk for partitions and display them 29214192Simp############################################################################# 30209513Simp 31214445Simp. ${PROGDIR}/backend/functions.sh 32209513Simp. ${PROGDIR}/backend/functions-disk.sh 33209513Simp 34214192SimpDISK="${1}" 35209513Simp 36214192Simp[ -z "${DISK}" ] && { echo 'Error: No disk specified!'; exit 1; } 37214192Simp[ ! -e "/dev/${DISK}" ] && \ 38214192Simp { echo "Error: Disk /dev/${DISK} does not exist!"; exit 1; } 39209513Simp 40209513Simpget_disk_cyl "${DISK}" 41209513SimpCYLS="${VAL}" 42209513Simp 43209513Simpget_disk_heads "${DISK}" 44209513SimpHEADS="${VAL}" 45209513Simp 46209513Simpget_disk_sectors "${DISK}" 47209513SimpSECS="${VAL}" 48209513Simp 49209513Simp# Now get the disks size in MB 50209513SimpKB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`" 51209513SimpMB=$(convert_byte_to_megabyte ${KB}) 52209513Simp 53209513Simp# Now get the Controller Type 54209513SimpCTYPE="`dmesg | grep "^${1}:" | grep "B <" | cut -d '>' -f 2 | cut -d ' ' -f 3-10`" 55211489Simp 56211489Simpecho "cylinders=${CYLS}" 57211489Simpecho "heads=${HEADS}" 58211489Simpecho "sectors=${SECS}" 59211730Simpecho "size=${MB}" 60211730Simpecho "type=${CTYPE}" 61