If you face the udev as the last resort, as dread crazy, then they really
will scare you. If you look to a simple rule, and try to expand it, you will
see udev is simple, more simple than bash scripting.

In http://www.reactivated.net/writing_udev_rules.html there is a complete
(and long) tutorial on the matter.

Enjoy!

Mauro
http://mauro.limeiratem.com - registered Linux User: 294521
Scripture is both history, and a love letter from God.


On Thu, Sep 2, 2010 at 5:20 AM, Vlacil, Radek <[email protected]> wrote:

> Thanks very much for your answer.
>
> I thought it is possible to do it by udev. I was just little bit scared of
> that crazy udev rules :D and I had that as the last resort.
>
> Radek Vlacil
>
>
> CA CZ, s.r.o.  Prague 4, Chodov, V Parku 2316/12, postal code 148 00,
> Identification No. 25694073, registered in the Commercial Register
> maintained by the Municipal Court in Prague in Section C, Insert No. 61808"
>
> -----Original Message-----
> From: Linux on 390 Port [mailto:[email protected]] On Behalf Of
> Sebastian Ott
> Sent: Wednesday, September 01, 2010 18:44
> To: [email protected]
> Subject: Re: Tapes 34xx detection
>
> Hi,
>
> On Wed, 1 Sep 2010, Vlacil, Radek wrote:
> > Is there any way how to detect in an application that 34xx tape was
> > attached through ccw. In other words, detect that new directory for that
> > tape appeared in /sys/bus/ccw/devices/ and that it is ready for
> > "chccwdev -e". I would like to have a program that tracks whether any
> > tape was attached or detached and I was wondering whether there is
> > another option than "try-to-open and wait" loop.
>
> when a device is added/removed to/from linux the kernel will create
> "uevents" to inform userspace about these events. a daemon called
> udevd receives these events and triggers some actions. the actions
> can be specified by udev scripts.
>
> so it should be possible to extend your distributors udev scripts
> (or write your own) to e.g. write a logfile if a tape device is attached.
>
> if i monitor uevents i get:
> # udevmonitor --env
> ...
> UEVENT[1283357379.294644] add      /devices/css0/0.0.0014/0.0.1001 (ccw)
> ACTION=add
> DEVPATH=/devices/css0/0.0.0014/0.0.1001
> SUBSYSTEM=ccw
> CU_TYPE=3990
> CU_MODEL=E9
> DEV_TYPE=3390
> DEV_MODEL=0A
> MODALIAS=ccw:t3990mE9dt3390dm0A
> SEQNUM=1643
> ...
> UEVENT[1283357406.102060] remove   /devices/css0/0.0.0014/0.0.1001 (ccw)
> ACTION=remove
> DEVPATH=/devices/css0/0.0.0014/0.0.1001
> SUBSYSTEM=ccw
> CU_TYPE=3990
> CU_MODEL=E9
> DEV_TYPE=3390
> DEV_MODEL=0A
> MODALIAS=ccw:t3990mE9dt3390dm0A
> SEQNUM=1644
>
> for attaching/detaching devices (no tape, but you should get
> the idea...)
>
> regards
> sebastian
> >
> > These are messages in the system log which describes events I'd like to
> > trap:
> >
> >
> >
> > kernel: crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=1,
> > erc=4, rsid=5
> >
> > kernel: TAPE_CORE: tape device 0.0.0186 found
> >
> > kernel: TAPE_CORE: (0.0.0186): Tape has been mounted
> >
> > kernel: TAPE_BLOCK: Detecting media size...
> >
> > kernel: TAPE_BLOCK: Found 2 blocks on media
> >
> > kernel: TAPE_CORE: (0.0.0186): Tape is unloaded
> >
> > kernel: crw_info : CRW reports slct=0, oflw=0, chn=0, rsc=3, anc=1,
> > erc=4, rsid=5
> >
> >
> >
> > Radek Vlacil
> >
> >
> >
> >
> > ----------------------------------------------------------------------
> > For LINUX-390 subscribe / signoff / archive access instructions,
> > send email to [email protected] with the message: INFO LINUX-390 or
> visit
> > http://www.marist.edu/htbin/wlvindex?LINUX-390
> > ----------------------------------------------------------------------
> > For more information on Linux on System z, visit
> > http://wiki.linuxvm.org/
> >
>
> ----------------------------------------------------------------------
> For LINUX-390 subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO LINUX-390 or
> visit
> http://www.marist.edu/htbin/wlvindex?LINUX-390
> ----------------------------------------------------------------------
> For more information on Linux on System z, visit
> http://wiki.linuxvm.org/
>
> ----------------------------------------------------------------------
> For LINUX-390 subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO LINUX-390 or
> visit
> http://www.marist.edu/htbin/wlvindex?LINUX-390
> ----------------------------------------------------------------------
> For more information on Linux on System z, visit
> http://wiki.linuxvm.org/
>

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

Reply via email to