Udev
   HOME

TheInfoList



OR:

udev (userspace ) is a device manager for the
Linux kernel The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ...
. As the successor of
devfsd devfsd is a device manager for the Linux kernel. Primarily, it creates device nodes in the directory when kernel drivers make the underlying hardware accessible. The nodes exist in a virtual device file system named devfs. In systems that suppor ...
and hotplug, udev primarily manages device nodes in the directory. At the same time, udev also handles all user space events raised when hardware devices are added into the system or removed from it, including
firmware In computing, firmware is a specific class of computer software that provides the low-level control for a device's specific hardware. Firmware, such as the BIOS of a personal computer, may contain basic functions of a device, and may provide h ...
loading as required by certain devices.


Rationale

It is an
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
's kernel that is responsible for providing an abstract interface of the hardware to the rest of the software. Being a monolithic kernel, the
Linux kernel The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ...
does exactly that:
device driver In computing, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabling operating systems and o ...
s are part of the Linux kernel, and make up more than half of its source code. Hardware can be accessed through system calls or over their device nodes. To be able to deal with peripheral devices that are
hotplug Hot swapping is the replacement or addition of components to a computer system without stopping, shutting down, or rebooting the system; hot plugging describes the addition of components only. Components which have such functionality are said ...
-capable in a user-friendly way, a part of handling all of these hotplug-capable hardware devices was handed over from the kernel to a daemon running in user-space. Running in user space serves security and stability purposes.


Design

Device driver In computing, a device driver is a computer program that operates or controls a particular type of device that is attached to a computer or automaton. A driver provides a software interface to hardware devices, enabling operating systems and o ...
s are part of the Linux kernel, in which their primary functions include device discovery, detecting device state changes, and similar low-level hardware functions. After loading a device driver into memory from the kernel, detected events are sent out to the userspace daemon udevd. It is the device manager, , that catches all of these events and then decides what shall happen next. For this, has a very comprehensive set of configuration files, which can all be adjusted by the computer administrator, according to their needs. * In case a new storage device is connected over USB, is notified by the kernel and itself notifies the udisksd-daemon. That daemon could then mount the file systems. * In case a new Ethernet cable is plugged into the Ethernet NIC, is notified by the kernel and itself notifies the NetworkManager-daemon. The NetworkManager-daemon could start dhclient for that NIC, or configure according to some manual configuration. The complexity of doing so forces application authors to re-implement hardware support logic. Some hardware devices also require privileged helper programs to prepare them for use. These must often be invoked in ways that can be awkward to express with the Unix permissions model (for example, allowing users to join
wireless network A wireless network is a computer network that uses wireless data connections between network nodes. Wireless networking is a method by which homes, telecommunications networks and business installations avoid the costly process of introducing ...
s only if they are logged into the video console). Application authors resort to using setuid binaries or run service daemons to provide their own access control and privilege separation, potentially introducing security holes each time.
HAL HAL may refer to: Aviation * Halali Airport (IATA airport code: HAL) Halali, Oshikoto, Namibia * Hawaiian Airlines (ICAO airline code: HAL) * HAL Airport, Bangalore, India * Hindustan Aeronautics Limited an Indian aerospace manufacturer of figh ...
was created to deal with this, but is now deprecated in most Linux distributions.


Overview

Unlike traditional
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, ...
systems, where the device nodes in the directory have been a static set of files, the Linux udev device manager dynamically provides only the nodes for the devices actually present on a system. Although
devfs In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow ...
used to provide similar functionality,
Greg Kroah-Hartman Greg Kroah-Hartman (GKH) is a major Linux kernel developer. he is the Linux kernel maintainer for the branch, the staging subsystem, USB, driver core, debugfs, kref, kobject, and the sysfs kernel subsystems, Userspace I/O (with Hans J. Koch ...
cited a number of reasons for preferring udev over devfs: * udev supports persistent device naming, which does not depend on, for example, the order in which the devices are plugged into the system. The default udev setup provides persistent names for storage devices. Any hard disk is recognized by its unique filesystem id, the name of the disk and the physical location on the hardware it is connected to. * udev executes entirely in user space, as opposed to devfs's
kernel space A modern computer operating system usually segregates virtual memory into user space and kernel space. Primarily, this separation serves to provide memory protection and hardware protection from malicious or errant software behaviour. Kernel ...
. One consequence is that udev moved the naming policy out of the kernel and can run arbitrary programs to compose a name for the device from the device's properties, before the node is created; there, the whole process is also interruptible and it runs with a lower priority. The udev, as a whole, is divided into three parts: *
Library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
''libudev'' that allows access to device information; it was incorporated into the
systemd systemd is a software suite that provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions; Its primary component is a "system and service manag ...
183 software bundle. * User space daemon that manages the virtual . * Administrative command-line utility for diagnostics. The system gets calls from the kernel via
netlink Netlink is a socket family used for inter-process communication (IPC) between both the kernel and userspace processes, and between different userspace processes, in a way similar to the Unix domain sockets available on certain Unix-like oper ...
socket. Earlier versions used
hotplug Hot swapping is the replacement or addition of components to a computer system without stopping, shutting down, or rebooting the system; hot plugging describes the addition of components only. Components which have such functionality are said ...
, adding a link to themselves in with this purpose.


Operation

udev is a generic device manager running as a daemon on a Linux system and listening (via a
netlink Netlink is a socket family used for inter-process communication (IPC) between both the kernel and userspace processes, and between different userspace processes, in a way similar to the Unix domain sockets available on certain Unix-like oper ...
socket) to uevents the kernel sends out if a new device is initialized or a device is removed from the system. The udev package comes with an extensive set of rules that match against exported values of the event and properties of the discovered device. A matching rule will possibly name and create a device node and run configured programs to set up and configure the device. udev rules can match on properties like the kernel subsystem, the kernel device name, the physical location of the device, or properties like the device's serial number. Rules can also request information from external programs to name a device or specify a custom name that will always be the same, regardless of the order devices are discovered by the system. In the past a common way to use udev on Linux systems was to let it send events through a socket to
HAL HAL may refer to: Aviation * Halali Airport (IATA airport code: HAL) Halali, Oshikoto, Namibia * Hawaiian Airlines (ICAO airline code: HAL) * HAL Airport, Bangalore, India * Hindustan Aeronautics Limited an Indian aerospace manufacturer of figh ...
, which would perform further device-specific actions. For example, HAL would notify other software running on the system that the new hardware had arrived by issuing a broadcast message on the
D-Bus In computing, D-Bus (short for "Desktop Bus") is a message-oriented middleware mechanism that allows communication between multiple processes running concurrently on the same machine. D-Bus was developed as part of the freedesktop.org project ...
IPC system to all interested
processes A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management *Business process, activities that produce a specific se ...
. In this way, desktops such as
GNOME A gnome is a mythological creature and diminutive spirit in Renaissance magic and alchemy, first introduced by Paracelsus in the 16th century and later adopted by more recent authors including those of modern fantasy literature. Its characte ...
or
K Desktop Environment 3 K Desktop Environment 3 is the third series of releases of the K Desktop Environment (after that called ''KDE Software Compilation''). There are six major releases in this series. After the release of KDE 4, version 3.5 was forked into the Trini ...
could start the file browser to browse the file systems of newly attached
USB flash drive Universal Serial Bus (USB) is an industry standard that establishes specifications for cables, connectors and protocols for connection, communication and power supply ( interfacing) between computers, peripherals and other computers. A bro ...
s and SD cards. By the middle of 2011 HAL had been deprecated by most Linux distributions as well as by the KDE, GNOME and Xfce desktop environments, among others. The functionality previously embodied in HAL has been integrated into udev itself, or moved to separate software such as udisks and upower. * udev provides low-level access to the linux device tree. Allows programs to enumerate devices and their properties and get notifications when devices come and go. * dbus is a framework to allow programs to communicate with each other, securely, reliably, and with a high-level object-oriented programming interface. * udisks (formerly known as DeviceKit-disks) is a daemon that sits on top of libudev and other kernel interfaces and provides a high-level interface to storage devices and is accessible via dbus to applications. * upower (formerly known as DeviceKit-power) is a daemon that sits on top of libudev and other kernel interfaces and provides a high-level interface to power management and is accessible via dbus to applications. * NetworkManager is a daemon that sits on top of libudev and other kernel interfaces (and a couple of other daemons) and provides a high-level interface to network configuration and setup and is accessible via dbus to apps. udev receives messages from the kernel, and passes them on to subsystem daemons such as Network Manager. Applications talk to Network Manager over D-Bus. :Kernel -> udev -> Network Manager <=> D-Bus <=> Firefox HAL is obsolete and only used by legacy code. Ubuntu 10.04 shipped without HAL. Initially a new daemon DeviceKit was planned to replace certain aspects of HAL, but in March 2009, DeviceKit was deprecated in favor of adding the same code to udev as a package: udev-extras, and some functions have now moved to udev proper.


History

udev was introduced in Linux 2.5. The Linux kernel version 2.6.13 introduced or updated a new version of the uevent interface. A system using a new version of udev will not boot with kernels older than 2.6.13 unless udev is disabled and a traditional directory is used for device access. In April 2012, udev's codebase was merged into the
systemd systemd is a software suite that provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions; Its primary component is a "system and service manag ...
source tree, making systemd 183 the first version to include udev. In October 2012,
Linus Torvalds Linus Benedict Torvalds ( , ; born 28 December 1969) is a Finnish software engineer who is the creator and, historically, the lead developer of the Linux kernel, used by Linux distributions and other operating systems such as Android. He also ...
criticized
Kay Sievers Kay Sievers is a German computer programmer, best known for developing the udev device manager of Linux, systemd and the Gummiboot EFI bootloader. Kay Sievers made major contributions to Linux's hardware hotplug and device management subs ...
's approach to udev maintenance and bug fixing related to
firmware In computing, firmware is a specific class of computer software that provides the low-level control for a device's specific hardware. Firmware, such as the BIOS of a personal computer, may contain basic functions of a device, and may provide h ...
loading, stating: In 2012, the
Gentoo Linux Gentoo Linux (pronounced ) is a Linux distribution built using the Portage package management system. Unlike a binary software distribution, the source code is compiled locally according to the user's preferences and is often optimized for th ...
project created a
fork In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tine (structural), tines with which one ...
of systemd's udev codebase in order to avoid dependency on the systemd architecture. The resulting fork is called ''
eudev systemd is a software suite that provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions; Its primary component is a "system and service manager ...
'' and it makes udev functionality available without systemd. A stated goal of the project is to keep eudev independent of any
Linux distribution A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and, often, a package management system. Linux users usually obtain their operating system by downloading one ...
or
init In Unix-based computer operating systems, init (short for ''initialization'') is the first process started during booting of the computer system. Init is a daemon process that continues running until the system is shut down. It is the direc ...
system. The Gentoo project describes eudev as follows: On May 29, 2014, support for firmware loading through udev was dropped from systemd, as it has been decided that it is the kernel's task to load firmware. Two days later,
Lennart Poettering Lennart Poettering (born 15 October 1980) is a German software engineer working for Microsoft and the original author of PulseAudio, Avahi and systemd. Life and career Poettering was born in Guatemala City but grew up in Rio de Janeiro ...
suggested this patch be postponed until kdbus starts to be utilized by udev; at that point, the plan was to switch udev to use kdbus as the underlying messaging system, and to get rid of the userspace-to-userspace netlink-based transport.


Authors

udev was developed by
Greg Kroah-Hartman Greg Kroah-Hartman (GKH) is a major Linux kernel developer. he is the Linux kernel maintainer for the branch, the staging subsystem, USB, driver core, debugfs, kref, kobject, and the sysfs kernel subsystems, Userspace I/O (with Hans J. Koch ...
and
Kay Sievers Kay Sievers is a German computer programmer, best known for developing the udev device manager of Linux, systemd and the Gummiboot EFI bootloader. Kay Sievers made major contributions to Linux's hardware hotplug and device management subs ...
, with much help from Dan Stekloff, among others.


References


External links

* {{Linux kernel Computer configuration Interfaces of the Linux kernel Linux file system-related software Linux kernel features Unix file system-related software