\documentclass[11pt]{beamer}

%\usepackage{ngerman}
\usepackage{times}
\usepackage{graphicx}
\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps}
\usepackage{amsmath,amssymb}
\usepackage[latin1]{inputenc}
\usepackage{listings,color}
\definecolor{lbcolor}{RGB}{255,210,150}
\lstset{
	language=C,
	numbers=left,
	stepnumber=1,
	numbersep=5pt,
	numberstyle=\tiny,
	breaklines=true,
	breakautoindent=true,
	postbreak=\space,
	tabsize=2,
	basicstyle=\ttfamily\footnotesize,
	showspaces=false,
	showstringspaces=false,
	extendedchars=true,
	backgroundcolor=\color{lbcolor},
	keywordstyle=\bf ,
	commentstyle=\color{green},
	stringstyle=\color{red}
}

\mode<presentation>
{
	\usetheme{linutronix}
}

% on the following slides, include icon in the left sidebar
\def\lximg{/usr/share/lx/icons/fueller.png}

\title{The UDEV Daemon}
\institute{Linutronix GmbH}

\begin{document}

\frame{ \titlepage }

% stop displaying 'fueller.png' on the following slides
\def\lximg{none}

\begin{frame}
\frametitle{What is UDEV?}
\begin{itemize}
\item UDEV is responsible for dynamic device management
\item It receives so called uevents from the kernel via a netlink socket
\item Based on the rules defined in the UDEV configuration, specific tasks can
be performed (e.g. creating device nodes)
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{How to perform actions on ''missed'' uevents}
\begin{itemize}
\item Since udev is a userspace process, it is started when the system is already up
and running. To perform actions on the events, which have been generated
during the kernel boot-up, there's a trigger functionality
\item So, usually the first thing after starting udev is to trigger the missed events
\item This can be done by calling ''udevadm trigger''
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Monitoring udev events}
\begin{verbatim}
jan@bender:~$ sudo udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out
       after rule processing
KERNEL - the kernel uevent
KERNEL[129.916] add [...]usb1/1-3/1-3.1 [...]
KERNEL[129.917] add [...]usb1/1-3/1-3.1 [...]
KERNEL[129.918] add [...]usb1/1-3/1-3.1 [...]
KERNEL[129.918] add [...]usb1/1-3/1-3.1 [...]
UDEV  [129.922] add [...]usb1/1-3/1-3.1 [...]
UDEV  [129.922] add [...]usb1/1-3/1-3.1 [...]
[...]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{UDEV: important commands}
Starting the UDEV Daemon:
\begin{verbatim}
udevd --daemon
\end{verbatim}
Triggering UDEV events:
\begin{verbatim}
udevadm trigger
\end{verbatim}
Monitoring UDEV events:
\begin{verbatim}
udevadm monitor
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{Writing UDEV rules}
\begin{itemize}
\item Rules are usually kept in /etc/udev/rules.d
\item Rules are constructed using series of KEY-VALUE pairs
\item The pairs are separated by commas
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Basic keywords}
\begin{itemize}
\item KERNEL\\
The kernel name of a device
\item SUBSYSTEM\\
The name of the subsystem which caused the event
\item DRIVER\\
Name of the driver which caused the event
\item NAME\\
Name of the device node
\item SYMLINK\\
Name of a symlink pointing to the node
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Simple example for device node creation}
\begin{verbatim}
# Some basic rule
KERNEL=="ttyS0", NAME="my_serial_port"

# A more complex rule using SysFS attributes
# and regular expressions
SUBSYSTEM=="net", ACTION=="add", \
DRIVERS=="?*", \
ATTR{address}=="00:19:d1:12:0d:d2", \
KERNEL=="eth*", NAME="eth0"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Operators}
\begin{verbatim}
Comparisons:
== equal
!= not equal

Assignments:
=  Assign a value
+= Add a value
:= Finally assign a value
   (disallow any later changes)
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Substitutions}
\begin{verbatim}
%k kernel name
%n number for this device
%d driver name
%M major number of this device
%m minor number of this device
[...]
\end{verbatim}
\end{frame}

\section*{sources}
\begin{frame}
\begin{thebibliography}{1}
\bibitem{udev} http://reactivated.net/writing\_udev\_rules.html
\bibitem{manudev} man udev
\end{thebibliography} 
\end{frame}
\end{document}
