#!/bin/sh
#
# MAKEDEV
#
# Create just needed static '/dev/*' items.
# Minimal set needed for booting. 
# Adtec static items are in usr/local/sbin/MAKEDEV  
# Rest are created by udev
# Adtec Digital, Inc. (c) 2003-2013
# Andre G Ancelin
# Mike Goins


##############################################################################
# Make sure running as root.
#
  if [ "$UID" -ne 0 ] ; then
   echo "Must run this script as root."
	exit $E_NOT_ROOT
  fi    


##############################################################################
# Make a "dev" directory and move to it.
#
${RFSDIR}/bin/chown 0:0 dev
${RFSDIR}/bin/chmod 775 dev   # just in case
cd dev

##############################################################################
# Miscellaneous odds and ends devices.
#
${RFSDIR}/bin/mknod -m666 null    c 1  3
${RFSDIR}/bin/mknod -m666 zero    c 1  5
${RFSDIR}/bin/mknod -m600 initctl p
${RFSDIR}/bin/mknod -m600 rtc     c 10 135
${RFSDIR}/bin/mknod -m666 ptmx    c 5  2
${RFSDIR}/bin/mknod -m444 random  c 1  8
${RFSDIR}/bin/mknod -m444 urandom c 1  9

##############################################################################
# Terminals and consoles.
#
owner_group="0:0"
permission="666"

# Basic terminals and serial ports.
${RFSDIR}/bin/mknod -m$permission tty   c 5 0
for ((device=0; device <= 1; device++)) ; do
  ${RFSDIR}/bin/mknod -m$permission tty$device  c 4 $device
  ${RFSDIR}/bin/mknod -m$permission ttyS$device c 4 $(($device+64))
done

# Console is on the first serial port.
${RFSDIR}/bin/ln -s ttyS0 console

