Example udev rule
The udev rules that process CP special messages identify particular messages and define one or more specific actions as a response.
The following example shows how to process CP special messages by using udev rules. The example contains rules for actions, one for all senders and one for the MAINT, OPERATOR, and LNXADM senders only.
The rules are contained in a block that matches uevents from the smsgiucv_app device driver. If there is no match, processing ends:
#
# Sample udev rules for processing CP special messages.
#
#
DEVPATH!="*/smsgiucv_app", GOTO="smsgiucv_app_end"
# ---------- Rules for CP messages go here --------
LABEL="smsgiucv_app_end"
The example uses the vmur command. If the vmur kernel module has been compiled as a separate module, this module must be loaded first. Then, the z/VM virtual punch device is activated.
# --- Initialization ---
# load vmur and set the virtual punch device online
SUBSYSTEM=="module", ACTION=="add", RUN+="/sbin/modprobe --quiet vmur"
SUBSYSTEM=="module", ACTION=="add", RUN+="/sbin/chccwdev -e d"
The following rule accepts messages from all senders. The message text must match the string UNAME. If it does, the output of the uname command (the node name and kernel version of the Linux® instance) is sent back to the sender.
# --- Rules for all senders ----
# UNAME: tell the sender which kernel is running
ACTION=="change", ENV{SMSG_TEXT}=="UNAME", \
PROGRAM=="/bin/uname -n -r", \
RUN+="/sbin/vmcp msg $env{SMSG_SENDER} '$result'"
In the following example block rules are defined to accept messages from certain senders only. If no sender matches, processing ends. The message text must match the string DMESG. If it does, the environment variable PATH is set and the output of the dmesg command is sent into the z/VM reader of the sender. The name of the spool file is LINUX DMESG.
# --- Special rules available for particular z/VM user IDs ---
ENV{SMSG_SENDER}!="MAINT|OPERATOR|LNXADM", GOTO="smsgiucv_app_end"
# DMESG: punch dmesg output to sender
ACTION=="change", ENV{SMSG_TEXT}=="DMESG", \
ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin", \
RUN+="/bin/sh -c 'dmesg |fold -s -w 74 |vmur punch -r -t -N LINUX.DMESG -u $env{SMSG_SENDER}'"