0% found this document useful (0 votes)
104 views

Linux Hardware Management

This document discusses Linux hardware management and the evolution from traditional static device files to more dynamic solutions. It covers: 1) Traditional UNIX uses device files to represent hardware but this has issues with too many files and ambiguity. 2) UDEV was introduced to provide dynamic device files only for present hardware using rules and information from sysfs. 3) HAL provided an abstraction layer and standardized API for discovering and configuring hardware but has been deprecated in favor of newer solutions like DeviceKit. 4) DeviceKit aims to replace HAL's functionality through standards-based D-Bus APIs and focuses on specific subsystems like disks, power, and networking.

Uploaded by

Sergey Kryazhev
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views

Linux Hardware Management

This document discusses Linux hardware management and the evolution from traditional static device files to more dynamic solutions. It covers: 1) Traditional UNIX uses device files to represent hardware but this has issues with too many files and ambiguity. 2) UDEV was introduced to provide dynamic device files only for present hardware using rules and information from sysfs. 3) HAL provided an abstraction layer and standardized API for discovering and configuring hardware but has been deprecated in favor of newer solutions like DeviceKit. 4) DeviceKit aims to replace HAL's functionality through standards-based D-Bus APIs and focuses on specific subsystems like disks, power, and networking.

Uploaded by

Sergey Kryazhev
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Linux Hardware Management

2010 Kryazhev Sergey


Agenda

• Traditional UNIX h/w support


• UDEV
• HAL
• What's next ???
Devices on UNIX

UNIX isolates user and applications from


hardware.

Under UNIX almost every hardware device treated


as a file (Device file).

Device file allows software to interact with device


driver using standart system calls.

/dev directory contains device files.


Devices on UNIX

Device files:
• Character devices. Relate to devices through
which the system transmits data one character
at a time.
/dev/ttyS0
• Block devices. Relate to devices through which
the system moves data in the form of blocks.
/dev/sda

o Pseudo devices. Do not have correspond


physical devices.
/dev/null
Devices on UNIX
Each device file has major and minor numbers.
• Major number identifies the device driver.
• Minor number identifies a particular device.

brw-r-----   1 root  disk     8,   0  Май 14 2008 hda


brw-r-----   1 root  disk    8,   1  Май 14 2008 hda1
crw-rw----  1 root  uucp   4,  64  Май 14 2008 ttyS0
crw-rw----  1 root  uucp   4,  65  Май 14 2008 ttyS1
Devices on UNIX

How to create device file ?


mknod  filename [b] [c] major  minor

How to find major number ?


/proc/devices - list of character and block devices
sorted by major number

Minor number ???


Depends on particular driver.
Static /dev issues

• Two many device files

• Deficiency of the major and minor numbers

• Ambiguity
devfs

devfs is a specific implementation of a device


file system on Unix-like operating systems,
used for presenting device files.

Totally in kernel.

Present on Linux till 2.6.15


UDEV

udev - userspace device management

udev provides a dynamic device directory containing


only the files for actually present devices.

Runs as a daemon udevd

udev creates device files according to naming rules.


/lib/udev/rules.d (/etc/udev/rules.d/)
UDEV
Receives directly from the kernel using netlink interface.

Uses sysfs (/sys directory) to get device attributes.


UDEV
How to write naming rule file?

There are two kind of keys, match and assignment keys.

Examples:
KERNEL=="sd[0-9]*",NAME="flash/%n"

KERNEL=="sd[a-z]",PROGRAM="check_cd.sh %M %m",
NAME="%c{1}", SYMLINK="cdrom"

KERNEL=="lp*", SUBSYSTEMS=="usb",
ATTRS{idVendor}=="03f0", ATTRS{product}=="hp
LaserJet 1000", SYMLINK+="hplj1000-%n", RUN+="/
usr/sbin/hplj1000"
D-Bus

• A message bus system (IPC)

• Language independent (C/C++, Python,


Perl, etc)

• Simple way for applications to talk to one

• Provides a system and session bus


D-Bus
Acts as a user-space daemon (bus).

Bus types:
• system
• session

Message types:
• Method calls
• Responces
• Signals
D-Bus

• Service(Application) are found by name


org.gnome.Rhytmbox
• A service can export multiple objects
/org/gnome/Rhytmbox
• Each object implements at least one interface
org.gnome.Rhythmbox.Player
• Interface provides methods
next()
HAL

Hardware Abstraction Layer for UNIX-like


systems.

• A library for enumerating the physical hardware in a


system

• A toolkit for enumerating the physical and logical


devices in a system

• A platform for discovering and configuring hardware


HAL

• HAL is a daemon responsible for discovering,


enumerating and access to hardware on the
computer.
• It aims to allow desktop applications to discover and
use the hardware of the host system through a
simple, portable and abstract API

• Applications communicate with HAL through the


D-Bus IPC mechanism.
HAL
On a formal level, a device object is comprised by
• UDI
This is an identifier, the Unique Device Identifer, that is unique
for a device object , no other device object can have the same UDI
at the same time.
• Properties
Each device object got a set of properties which are key/value
pairs. The key is an ASCII string while the value.

UDI = '/org/freedesktop/Hal/devices/disk1' 
         |---block.device /dev/sda1 
         |---block.is_volume 1
         |---info.capabilities volume,block 
         |---volume.label WORK `
         |---volume.uuid 0717-AD77
HAL
HAL

Device Information Files (.fdi files) - mechanism


for associating information with devices.

How to use HAL ?


• DBUS
• libHal
HAL hardware management overview
HAL Deprecation.

HAL is in maintenance mode - no new


features are added. 

All future development focuses on


• Software/DeviceKit-disks
• Software/DeviceKit-power
• NetworkManager
• PulseAudio
• udev
DeviceKit
DeviceKit – a better HAL

•Designed to deliver same features as HAL


•Provide a D-Bus based API
•Parallel installable with HAL

Another DBUS object


org.freedesktop.DeviceKit
DeviceKit
DeviceKit-disks
Storage Subsystem Daemon

• DeviceKit-disks
• Consumes udev information
• Started on demand
• High-level API w/ progress reporting
Mount, Unmount, Eject, Poll, Fsck
Partitioning, Formatting, FS Label
ATA SMART monitoring
MD-RAID (Create, Start/Stop, Check, …)
Drive spindown
DeviceKit-disks
Comments ???

You might also like