#!/bin/sh
# this script depends on /lib/udev/vol_id from the udev package

# usage: un_vol_id <device> <fs_type>
# <device> may be any device that should be checked.
# if no <fs_type> is given, the check fails for any valid filesystem
# if <fs_type> is given, the check fails when a filesystem type <fs_type>
# is found on the device.

if test ! -x "/lib/udev/vol_id"; then
  echo " - WARNING: vol_id from udev is not available, impossible to run checks."
  exit 0
fi

dev=$1
fs=$2

vol_id=`/lib/udev/vol_id -t $dev 2>&1`

if test "$vol_id" != "$dev: unknown volume type" -a -z "$fs"; then
  echo " - The device $dev contains a valid filesystem type $vol_id."
  exit 1
elif test -n "$fs" -a "$vol_id" = "$fs"; then
  echo " - The device $dev contains a filesystem type $fs."
  exit 1
fi
