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 lists...@vm.marist.edu 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 lists...@vm.marist.edu 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