summaryrefslogtreecommitdiffstats
path: root/cmd/zpool/zpool.d/media
blob: 05bc15918bc95b6772466595c25062ff33f38abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
#
# Print out the type of device
#

if [ "$1" = "-h" ] ; then
	echo "Show whether a vdev is a file, hdd, or ssd."
	exit
fi

if [ -b "$VDEV_UPATH" ]; then
	device=$(basename "$VDEV_UPATH")
	val=$(cat "/sys/block/$device/queue/rotational" 2>/dev/null)
	if [ "$val" = "0" ]; then
		MEDIA="ssd"
	fi

	if [ "$val" = "1" ]; then
		MEDIA="hdd"
	fi
else
	if [ -f "$VDEV_UPATH" ]; then
		MEDIA="file"
	fi
fi

echo "media=$MEDIA"