Re: /dev/port BUG and possible workaround

Padraig Brady (padraig@antefacto.com)
Wed, 22 May 2002 13:09:50 +0100


Martin Dalecki wrote:
> Uz.ytkownik Nick Kurshev napisa?:
>
> ...
>
>> 800=inl(CFC)
>> 2. Wrong log with using of /dev/port:
>
> ...
>
>> But it seems that nobody uses this device. Then what is goal
>> of implementing of this device?
>
> Basically the goal is that contrary to some silly /proc
> stuff which is "en vouge" nowadays you have the ability to
> controll port access by using normal user permission control
> semantics of unix file access permissions, by giving /dev/port
> a proper group and so on. This is legacy crap of course, since
> the above goal can be reached by using a apache-suexec alike wrapper
> as well... even with more fine grained resolution of access controll.

It also allows you to write a watchdog driver in shell :-)

#!/bin/sh
# Padraig@antefacto.com
# This supports both the Ibase MB700 and Advantech PCM9576

usage() {
echo "Usage: `basename $0` [pat] [playdead]"
exit 1
}

if [ $# != 1 ]; then usage; fi;
if [ $1 != "pat" ]; then
if [ $1 != "playdead" ]; then
usage
fi
fi

HW_VERSION=`cat /var/run/HW_VERSION`

if [ "$HW_VERSION" == "IBASE MB700" ];
ENABLE_PORT=`printf %d 0x443`
DISABLE_PORT=`printf %d 0x441`

if [ $1 == "pat" ]; then
TIMEOUT='\x5' #20 seconds (0=30s, 1=28s, ..., F=0s)
printf "$TIMEOUT" | dd bs=1 seek=$ENABLE_PORT of=/dev/port
else
#write any value to port to disable
printf "\001" | dd bs=1 seek=$DISABLE_PORT of=/dev/port
fi
elif [ "$HW_VERSION" == "Advantech PCM9576" ]; then
DISENABLE_PORT=`printf %d 0x443`

if [ $1 == "pat" ]; then
TIMEOUT='\x14' #20 seconds (1=1s, 2=2s, ..., 3E=62s)
printf "$TIMEOUT" | dd bs=1 seek=$DISENABLE_PORT of=/dev/port
else
#read from port to disable
dd bs=1 count=1 skip=$DISENABLE_PORT if=/dev/port of=/dev/null
fi
fi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/