#! /bin/sh
#------------------------------------------------------------------------------
# makedev.ide - recreate ide devices
#
# Creation   :  2007-07-10 knuffel
# Last update:  $Id$
#
# Copyright (c) 2001-2007 the eisfair team, team(at)eisfair(dot)org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#------------------------------------------------------------------------------
# This script creates the proper /dev/ entries for IDE devices
# on the primary, secondary, tertiary, and quaternary interfaces.
# See ../Documentation/ide.txt for more information.
makedev ()
{
  mknod /dev/$1 $2 $3 $4
}
makedevs ()
{
  if [ "$1" = "hde" -o "$1" = "hdf" -o "$1" = "hdg" -o "$1" = "hdh" ]
  then
    for part in 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    do
      rm -f /dev/$1$part
    done
  fi
  if [ ! -b /dev/$1 ]
  then
    makedev $1 b $2 $3
  fi
  chmod 660 /dev/$1
  chown root:root /dev/$1
  for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  do
    if [ ! -b /dev/$1$part ]
    then
      makedev $1$part b $2 `expr $3 + $part`
    fi
    chown root:root /dev/$1$part
    chmod 660 /dev/$1$part
  done
}
makedevs hda  3 0
makedevs hdb  3 64
makedevs hdc 22 0
makedevs hdd 22 64
makedevs hde 33 0
makedevs hdf 33 64
makedevs hdg 34 0
makedevs hdh 34 64
makedevs hdi 56 0
makedevs hdj 56 64
makedevs hdk 57 0
makedevs hdl 57 64
makedevs hdm 88 0
makedevs hdn 88 64
makedevs hdo 89 0
makedevs hdp 89 64
makedevs hdq 90 0
makedevs hdr 90 64
makedevs hds 91 0
makedevs hdt 91 64
for tape in 0 1 2 3 4 5 6 7
do
  if [ ! -c /dev/ht$tape ]
  then
    makedev ht$tape c 37 $tape
  fi
  if [ ! -c /dev/nht$tape ]
  then
    makedev nht$tape c 37 `expr $tape + 128`
  fi
  chown root:root /dev/ht$tape
  chown root:root /dev/nht$tape
  chmod 660 /dev/ht$tape
  chmod 660 /dev/nht$tape
done