tags:

views:

30

answers:

1

I'm trying to trace what is transiting in a raw (character) device on an Unix system (ex: /dev/tty.baseband) for DEBUG purpose.

I am thinking of creating a deamon that would:

  • upon start rename /dev/tty.baseband to /dev/tty.baseband.old.
  • create a raw node /dev/tty.baseband
  • spawn two threads:

  • Thread 1: reading /dev/tty.baseband.old writing into /dev/tty.baseband

  • Thread 2: reading /dev/tty.baseband writing into /dev/tty.baseband.old

This would work a little bit like a MITM process. I wonder if there is not a 'standard' way to do this.

A: 

Nevermind I found how to do it. The way to go was to:

  • create a process
  • create a new pseudo-terminal, opening /dev/ptmx
  • call grantpt and unlockpt on the slave
  • rename the terminal to intecept
  • rename the terminal create the the previous name of the intecepted terminal

I wrote a small article and provided the source code if anyone need it:

http://fabiensanglard.net/cellphoneModem/index2.php

Fabien