Thursday, October 14, 2010

Tired of ttySx and ttyOx

Recently linux-omap integrated omap-serial patches. Now we dont use ttyS2 anymore but use ttyO2. tired of switching kernel versions and fixing my getty, wrote the following
In my busybox /etc/init.d/rcS file:

proc=`mount|grep "proc"`
if [ -z "proc" ]; then
mount -t procfs none /proc
fi
if [ -f /proc/cmdline ]; then
# grab console from cmdline and use it..
tty=`cat /proc/cmdline|sed -e "s/ /\n/g"|grep console|cut -d '=' -f2|cut -d ',' -f1`
if [ -z "tty" ]; then
echo `cat /proc/cmdline` "does'nt have console?"
else
# remove my previous one if it exists
rm -f /dev/tty-bd
ln -s /dev/$tty /dev/tty-bd
echo "/dev/$tty linked to /dev/tty-bd - using as console"
fi
else
echo "cmdline not found - no console?"
fi

In my inittab:

tty-bd::askfirst:-/bin/sh

1 comment:

Pavan Savoy said...

Yes, good one. Me too tired of ttyS* and ttyO* - Wonder if all the non-busybox shells and applications should have such logic :)