Hi,

Thanks once more, udev works like a charm for what I asked at the first
time. However, I have found one more much trickier problem. 

When a tape drive is attached to the system (just the drive, without any
tape) uevent is generated as it should be, I can easily attach "chccwdev
-e" to that. This generates another uevent and udev creates
/dev/[bnr]tibmN nodes. When I issue:

linux:~ # cat /dev/ntibm0
cat: /dev/ntibm0: No medium found

it says that there is no medium, what a surprise :).

Now I would like to wait until a tape is actually inserted. There is no
uevent generated for that. But in the system log:

kernel: TAPE_CORE: (0.0.0181): Tape has been mounted

message is displayed. Is there a way to track that?

Radek Vlacil


-----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/

Reply via email to