#! /bin/sh
# chkconfig: 2345 04 96
### BEGIN INIT INFO
# Provides:          vchiq
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Creates /dev/vchiq.
# Description        Searches /proc/devices for the vchiq device, and then
#                    creates /dev/vchiq using the found major device number.
#                    It is called from the boot script.
# X-Timesys-Start-Number:  04
# X-Timesys-Stop-Number:  96
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin

case "$1" in
  start)
        rm -f /dev/vchiq
        line=$(grep vchiq /proc/devices)
        major=${line/ vchiq/}
        if [ -z "$major" ]; then
            echo "Error: failed to locate vchiq device in /proc/devices"
            exit 1
        else
            mknod /dev/vchiq c "$major" 0
            chmod a+w /dev/vchiq
        fi
        ;;
  *)
        echo "Usage: $0 [start]"
        ;;
esac
