tom93 has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to create a perl script that creates a pseudo-device that shuffles data to-and-from /dev/sg0, making some minor tweaks to the data along the way.

I can't find the CPAN module that does this.

A friend has shown me how to use ioctl to talk to things like /dev/sg0 with perl, but I don't see how to make perl listen to something as if it were a device.

I'm guessing the pseudo-device would be a FIFO, lets call it /dev/psg0. I'd like to be able to do "sg_ses -p 2 /dev/psg0", and have a perl script listen to what sg_ses sends via /dev/psg0, tweak it a bit and send it on to /dev/sg0, take the response from /dev/sg0 and send it back to sg_ses via /dev/psg0.

Replies are listed 'Best First'.
Re: device I/O interceptor
by oko1 (Deacon) on Nov 13, 2008 at 01:01 UTC

    You may be asking the wrong question. Devices have a specific function - be it storage, redirection, hardware interfacing, whatever - and your notional device would do nothing more than hold the data for a while and return it. If that's the case, then why not just use a named pipe? You could write to it and read from it at your leisure, and all you need to know is what already know (at least I assume you do) about reading from/writing to filehandles.


    --
    "Language shapes the way we think, and determines what we can think about."
    -- B. L. Whorf