replugging the modern desktop - indico...replugging the modern desktop kay sievers david zeuthen ...
TRANSCRIPT
![Page 1: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/1.jpg)
Replugging the Modern Desktop
Kay Sievers <[email protected]>David Zeuthen <[email protected]>
Linux Plumbers ConferencePortland, OR, Sept 2009
![Page 2: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/2.jpg)
History
● Back in the day● /sbin/hotplug, scan entire /dev, /proc/scsi/scsi,
/proc/partitions● magicdev, supermount, subfs● User conf / passwords stored in /etc or hard-coded● Millions of LOC running as uid 0
![Page 3: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/3.jpg)
History
● Back in the day● /sbin/hotplug, scan entire /dev, /proc/scsi/scsi,
/proc/partitions● magicdev, supermount, subfs● User conf / passwords stored in /etc or hard-coded● Millions of LOC running as uid 0
● Early Desktop Integration● HAL, D-Bus, PolicyKit● Separate Mechanism and Policy● But... Implementation too complex, not scalable, not
focused, too many abstractions
![Page 4: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/4.jpg)
● Cutting the same cake in a different way
● 1st piece: Move device discovery/enumeration, classification, quirks, probing, event propagation to udev
● 2nd piece: Write libudev● 3rd piece: Dedicated system services for major
subsystems – DeviceKit-disks, DeviceKit-power, NetworkManager,
PulseAudio, Bluez, Gypsy, ...
● 4th piece: Port the world to subsystem services– Apps using simple subsystems use libudev (Cheese)
![Page 5: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/5.jpg)
Kernel
udevd
Kernel Space
libudev
Application
libudev
Application
Login Session
![Page 6: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/6.jpg)
Kernel
udevd
libudev
Application
libudev
SubsystemServices
System Space
Kernel Space
Login Session
ApplicationApplication
libdbus
![Page 7: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/7.jpg)
Kernel
udevd
libudev
Application
libudev
Application
libudev
Application
libudev
SubsystemServices
libudev
Application
libudev
Application
Session 1 Session 2
System Space
Kernel Space
ApplicationApplication
libdbus
...
![Page 8: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/8.jpg)
Kernel
udevd
libudev
Application
libudev
Application
libudev
Application
libudev
SubsystemServices
libudev
Application
libudev
Application
Session 1 Session 2
System Space
Kernel Space
Session Tracking(ConsoleKit)
Authority(PolicyKit)
System Message Bus(D-Bus)
...
Other Services:
ApplicationApplication
libdbus
...
![Page 9: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/9.jpg)
kernel devices show up in a device tree in /sys
/sys/devices|-- pci0000:00...| |-- 0000:00:1f.2| | |-- driver -> ../../../bus/pci/drivers/ahci...| | |-- host0| | | |-- subsystem -> ../../../../bus/scsi| | | |-- target0:0:0| | | | |-- subsystem -> ../../../../bus/scsi...| | | | |-- 0:0:0:0| | | | | |-- subsystem -> ../../../../bus/scsi...| | | | | |-- block| | | | | | `-- sda| | | | | | |-- subsystem -> ../../../../../../../../../class/block| | | | | | |-- alignment_offset| | | | | | |-- capability| | | | | | |-- dev
![Page 10: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/10.jpg)
new devices and changes are announced over netlink with uevents:
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000001}, msg_iov(1)=[{"add@/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/...\0 ACTION=add\0 DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/...\0 SUBSYSTEM=block\0 MAJOR=8\0 MINOR=0\0 DEVNAME=sda\0 DEVTYPE=disk\0 SEQNUM=1584\0"}, ...], ...
![Page 11: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/11.jpg)
udev rules to: add properties to store in database create meaningful symlinks run programs to configure/setup the device
SUBSYTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", \ IMPORT{program}="ata_id --export $tempnode"
/lib/udev/ata_id --export /dev/sda ID_TYPE=disk ID_BUS=ata ID_MODEL=SAMSUNG_MMCQE28G8MUP-0VA ID_MODEL_ENC=SAMSUNG\x20MMCQE28G8MUP-0VA ID_REVISION=VAM08L1Q ID_SERIAL=SAMSUNG_MMCQE28G8MUP-0VA_SE837A4759 ID_SERIAL_SHORT=SE837A4759
SUBSYTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", \ ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
![Page 12: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/12.jpg)
send event back to multiple listeners:
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=-4226, groups=00000002}, msg_iov(1)=[{"udev-147\0\0\0\0\0\0\0\0\312\376\35\352 \0m\3\20\306\320B\1\214\272\31 UDEV_LOG=3\0 ACTION=add\0 DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda\0 SUBSYSTEM=block\0 DEVNAME=/dev/sda\0 DEVTYPE=disk\0 SEQNUM=1584\0 MAJOR=8\0 MINOR=0\0 DEVLINKS=/dev/block/8:0 \ /dev/disk/by-id/ata-SAMSUNG_MMCQE28G8MUP-0VA_SE837A4759 \ /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0\0 ID_TYPE=disk\0 ID_BUS=ata\0 ID_MODEL=SAMSUNG_MMCQE28G8MUP-0VA\0 ID_MODEL_ENC=SAMSUNG\\x20MMCQE28G8MUP-0VA\0 ID_REVISION=VAM08L1Q\0 ID_SERIAL=SAMSUNG_MMCQE28G8MUP-0VA_SE837A4759\0 ID_SERIAL_SHORT=SE837A4759\0 ID_PATH=pci-0000:00:1f.2-scsi-0:0:0:0\0 DKD_ATA_SMART_IS_AVAILABLE=1\0}, ...], ...
![Page 13: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/13.jpg)
receive event with libudev:
struct udev_monitor *monitor; struct udev_device *device;
monitor = udev_monitor_new_from_netlink(udev, "udev"); udev_monitor_enable_receiving(monitor); udev_monitor_filter_add_match_subsystem_devtype(monitor, "block", "disk"); device = udev_monitor_receive_device(monitor); message multiplexing in the kernelmessages filtered inside the kernel with berkeley packet filter
![Page 14: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/14.jpg)
libgudev javascript example
![Page 15: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/15.jpg)
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
![Page 16: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/16.jpg)
Kernel
udevd
libudev
Storage Daemon(DeviceKit-disks)
GIO / GVfs
File Manager(Nautilus)
Login Session
System Space
Kernel Space
Session Tracking(ConsoleKit)
Authority(PolicyKit)
Disk Utility(Palimpsest)
System Message Bus (D-Bus)
Authentication Agent(PolicyKit-Gnome)
LoginSession
![Page 17: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/17.jpg)
Palimpsest Demo
(d-feet, fs labels, mkfs, ATA SMART from USB, new-ui)
![Page 18: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/18.jpg)
![Page 19: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/19.jpg)
![Page 20: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/20.jpg)
![Page 21: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/21.jpg)
![Page 22: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/22.jpg)
![Page 23: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/23.jpg)
![Page 24: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/24.jpg)
![Page 25: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/25.jpg)
Kernel /udev
Authority Disk Daemon Disk Utility /File Manager
AuthenticationAgent
Add /sys/class/block/sda1DeviceAdded(sda1)
signal
Mount(sda1, ...)CheckAuthorization()
BeginAuthentication()
AuthenticationAgentResponse()
CheckAuthorization()result
Mount()result
...
![Page 26: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/26.jpg)
Desktop Integration
● GVfs volume monitor● GNOME Power Manager
![Page 27: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/27.jpg)
Formatting
![Page 28: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/28.jpg)
MD RAID
![Page 29: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/29.jpg)
![Page 30: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/30.jpg)
Questions?
![Page 31: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/31.jpg)
Docs / References
● http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/
● http://www.kernel.org/pub/linux/utils/kernel/hotplug/gudev/
● http://hal.freedesktop.org/docs/DeviceKit-disks/
● http://hal.freedesktop.org/docs/DeviceKit-power/
● http://hal.freedesktop.org/docs/polkit/
![Page 32: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/32.jpg)
1
Replugging the Modern Desktop
Kay Sievers <[email protected]>David Zeuthen <[email protected]>
Linux Plumbers ConferencePortland, OR, Sept 2009
![Page 33: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/33.jpg)
2
History
● Back in the day● /sbin/hotplug, scan entire /dev, /proc/scsi/scsi,
/proc/partitions● magicdev, supermount, subfs● User conf / passwords stored in /etc or hard-coded● Millions of LOC running as uid 0
![Page 34: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/34.jpg)
3
History
● Back in the day● /sbin/hotplug, scan entire /dev, /proc/scsi/scsi,
/proc/partitions● magicdev, supermount, subfs● User conf / passwords stored in /etc or hard-coded● Millions of LOC running as uid 0
● Early Desktop Integration● HAL, D-Bus, PolicyKit● Separate Mechanism and Policy● But... Implementation too complex, not scalable, not
focused, too many abstractions
![Page 35: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/35.jpg)
4
● Cutting the same cake in a different way
● 1st piece: Move device discovery/enumeration, classification, quirks, probing, event propagation to udev
● 2nd piece: Write libudev● 3rd piece: Dedicated system services for major
subsystems – DeviceKit-disks, DeviceKit-power, NetworkManager,
PulseAudio, Bluez, Gypsy, ...
● 4th piece: Port the world to subsystem services– Apps using simple subsystems use libudev (Cheese)
![Page 36: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/36.jpg)
5Kernel
udevd
Kernel Space
libudev
Application
libudev
Application
Login Session
![Page 37: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/37.jpg)
6Kernel
udevd
libudev
Application
libudev
SubsystemServices
System Space
Kernel Space
Login Session
ApplicationApplication
libdbus
![Page 38: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/38.jpg)
7Kernel
udevd
libudev
Application
libudev
Application
libudev
Application
libudev
SubsystemServices
libudev
Application
libudev
Application
Session 1 Session 2
System Space
Kernel Space
ApplicationApplication
libdbus
...
![Page 39: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/39.jpg)
8Kernel
udevd
libudev
Application
libudev
Application
libudev
Application
libudev
SubsystemServices
libudev
Application
libudev
Application
Session 1 Session 2
System Space
Kernel Space
Session Tracking(ConsoleKit)
Authority(PolicyKit)
System Message Bus(D-Bus)
...
Other Services:
ApplicationApplication
libdbus
...
![Page 40: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/40.jpg)
9
kernel devices show up in a device tree in /sys
/sys/devices|-- pci0000:00...| |-- 0000:00:1f.2| | |-- driver -> ../../../bus/pci/drivers/ahci...| | |-- host0| | | |-- subsystem -> ../../../../bus/scsi| | | |-- target0:0:0| | | | |-- subsystem -> ../../../../bus/scsi...| | | | |-- 0:0:0:0| | | | | |-- subsystem -> ../../../../bus/scsi...| | | | | |-- block| | | | | | `-- sda| | | | | | |-- subsystem -> ../../../../../../../../../class/block| | | | | | |-- alignment_offset| | | | | | |-- capability| | | | | | |-- dev
![Page 41: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/41.jpg)
10
new devices and changes are announced over netlink with uevents:
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000001}, msg_iov(1)=[{"add@/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/...\0 ACTION=add\0 DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/...\0 SUBSYSTEM=block\0 MAJOR=8\0 MINOR=0\0 DEVNAME=sda\0 DEVTYPE=disk\0 SEQNUM=1584\0"}, ...], ...
![Page 42: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/42.jpg)
11
udev rules to: add properties to store in database create meaningful symlinks run programs to configure/setup the device
SUBSYTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", \ IMPORT{program}="ata_id --export $tempnode"
/lib/udev/ata_id --export /dev/sda ID_TYPE=disk ID_BUS=ata ID_MODEL=SAMSUNG_MMCQE28G8MUP-0VA ID_MODEL_ENC=SAMSUNG\x20MMCQE28G8MUP-0VA ID_REVISION=VAM08L1Q ID_SERIAL=SAMSUNG_MMCQE28G8MUP-0VA_SE837A4759 ID_SERIAL_SHORT=SE837A4759
SUBSYTEM=="block", KERNEL=="sd*", ENV{DEVTYPE}=="disk", \ ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
![Page 43: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/43.jpg)
12
send event back to multiple listeners:
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=-4226, groups=00000002}, msg_iov(1)=[{"udev-147\0\0\0\0\0\0\0\0\312\376\35\352 \0m\3\20\306\320B\1\214\272\31 UDEV_LOG=3\0 ACTION=add\0 DEVPATH=/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda\0 SUBSYSTEM=block\0 DEVNAME=/dev/sda\0 DEVTYPE=disk\0 SEQNUM=1584\0 MAJOR=8\0 MINOR=0\0 DEVLINKS=/dev/block/8:0 \ /dev/disk/by-id/ata-SAMSUNG_MMCQE28G8MUP-0VA_SE837A4759 \ /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0\0 ID_TYPE=disk\0 ID_BUS=ata\0 ID_MODEL=SAMSUNG_MMCQE28G8MUP-0VA\0 ID_MODEL_ENC=SAMSUNG\\x20MMCQE28G8MUP-0VA\0 ID_REVISION=VAM08L1Q\0 ID_SERIAL=SAMSUNG_MMCQE28G8MUP-0VA_SE837A4759\0 ID_SERIAL_SHORT=SE837A4759\0 ID_PATH=pci-0000:00:1f.2-scsi-0:0:0:0\0 DKD_ATA_SMART_IS_AVAILABLE=1\0}, ...], ...
![Page 44: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/44.jpg)
13
receive event with libudev:
struct udev_monitor *monitor; struct udev_device *device;
monitor = udev_monitor_new_from_netlink(udev, "udev"); udev_monitor_enable_receiving(monitor); udev_monitor_filter_add_match_subsystem_devtype(monitor, "block", "disk"); device = udev_monitor_receive_device(monitor); message multiplexing in the kernelmessages filtered inside the kernel with berkeley packet filter
![Page 45: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/45.jpg)
14
libgudev javascript example
![Page 46: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/46.jpg)
15
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
![Page 47: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/47.jpg)
16Kernel
udevd
libudev
Storage Daemon(DeviceKit-disks)
GIO / GVfs
File Manager(Nautilus)
Login Session
System Space
Kernel Space
Session Tracking(ConsoleKit)
Authority(PolicyKit)
Disk Utility(Palimpsest)
System Message Bus (D-Bus)
Authentication Agent(PolicyKit-Gnome)
LoginSession
![Page 48: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/48.jpg)
17
Palimpsest Demo
(d-feet, fs labels, mkfs, ATA SMART from USB, new-ui)
![Page 49: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/49.jpg)
18
![Page 50: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/50.jpg)
19
![Page 51: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/51.jpg)
20
![Page 52: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/52.jpg)
21
![Page 53: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/53.jpg)
22
![Page 54: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/54.jpg)
23
![Page 55: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/55.jpg)
24
![Page 56: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/56.jpg)
25
Kernel /udev
Authority Disk Daemon Disk Utility /File Manager
AuthenticationAgent
Add /sys/class/block/sda1DeviceAdded(sda1)
signal
Mount(sda1, ...)CheckAuthorization()
BeginAuthentication()
AuthenticationAgentResponse()
CheckAuthorization()result
Mount()result
...
![Page 57: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/57.jpg)
26
Desktop Integration
● GVfs volume monitor● GNOME Power Manager
![Page 58: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/58.jpg)
27
Formatting
![Page 59: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/59.jpg)
28
MD RAID
![Page 60: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/60.jpg)
29
![Page 61: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/61.jpg)
30
Questions?
![Page 62: Replugging the Modern Desktop - Indico...Replugging the Modern Desktop Kay Sievers David Zeuthen Linux Plumbers Conference Portland,](https://reader036.vdocuments.us/reader036/viewer/2022071211/60233ca894001f03a8652830/html5/thumbnails/62.jpg)
31
Docs / References
● http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/
● http://www.kernel.org/pub/linux/utils/kernel/hotplug/gudev/
● http://hal.freedesktop.org/docs/DeviceKit-disks/
● http://hal.freedesktop.org/docs/DeviceKit-power/
● http://hal.freedesktop.org/docs/polkit/