The hardware-observe interface¶
The hardware-observe interface allows for getting hardware information from the system.
hardware-observe grants read-only access to many files and directories, primarily in /sys and /proc. Additionally, it provides access to many utility files and binaries such as lspci, lsusb, and hwinfo.
hardware-observe is a more general and broad interface. If more specific hardware access is required, such as for GPIO or I2C devices, See the gpio and i2c interfaces.
Tip
See Interface management and Supported interfaces for further details on how interfaces are used.
Developer details¶
Auto-connect: no
Path access¶
hardware-observe grants read access to the following paths:
For tools like
hwinfo --shortto get hardware information:/proc/ioports/proc/dma/proc/tty/driver/{,*}/proc/sys/dev/cdrom/infoFor tools like
lshw -quietto get hardware information:/proc/devices/proc/ide/{,**}/proc/scsi/{,**}/proc/device-tree/{,**}/sys/kernel/debug/usb/devices/proc/sys/abi/{,*}For tools like
lspci -A linux-sysfsto get information on files in/sys:/sys/{block,bus,class,devices,firmware}/{,**}For tools like
lspci -A linux-procto get information on/proc:/bus/pci/{,**}/{,usr/}lib/modprobe.d/{,*}For tools like
lspci -kto get information on loaded modules: Examples:/etc/modprobe.d/{,*},For tools like
lsusbto get USB information:/var/lib/usbutils/usb.ids/dev//dev/bus/usb/{,**/}/etc/udev/udev.confNote: lsusb and its database have to be shipped in the snap if not on classicFor tools like
sensorsto get sensor information:/etc/sensors3.conf/etc/sensors.d/{,*}For tools like
udevadmto get device information:/run/udev/data/**For hugepage and transparent_hugepage statuses (but not the pages themselves):
/sys/kernel/mm/{hugepages,transparent_hugepage}/{,**}For information on available input devices:
/proc/bus/input/devicesFor power information:
/sys/power/{,**}/run/udev/data/+power_supply:*For interrupts:
/proc/interruptsFor loaded kernel module information:
/proc/modulesFor VM information:
/proc/cpuinfo/proc/sysinfo/proc/xen/capabilities/proc/1/sched/sys/hypervisor/properties/features/sys/hypervisor/typeFor container information:
/run/systemd/container
Binary access¶
hardware-observe grants executable access to the following binaries:
For tools provided by
util-linux:/{,usr/}bin/lsblk/{,usr/}bin/lscpu/{,usr/}bin/lsmemFor tools like
lsusb:/{,usr/}bin/lsusbFor tools like
systemd-detect-virt:/{,usr/}bin/systemd-detect-virt
Capability access¶
hardware-observe grants the following capabilities:
For tools like
lscpuandlspci -Ato inspect specific PCI access methods:capability sys_rawiocapability sys_admin
Socket access¶
hardware-observe grants the following socket access:
For udevadm to read netlink:
network netlink raw
The test code for the interface is in the snapd repository: https://github.com/canonical/snapd/blob/master/interfaces/builtin/hardware_observe_test.go
The source code for the interface is in the snapd repository: https://github.com/canonical/snapd/blob/master/interfaces/builtin/hardware_observe.go