Hi all,
I got a similar error in my snap when using i2c plug.
The gadget snap with the following slot:
i2c0:
interface: i2c
path: /dev/i2c-0
The snap using the i2c plug as following:
apps:
iio-event-monitor:
command: iio_generic_buffer
plugs:
- iio
- hardware-observe
- i2c
After connection of the plug and slot:
$ snap connect demo-iio-tools:hardware-observe
$ snap connect demo-iio-tools:i2c name_of_gadget:i2c0
$ snap connect demo-iio-tools:iio name_of_gagdet:iio1
When the command issued, the error outputs from snap as:
$ sudo demo-iio-tools.iio-generic-buffer -a -N 1 -g
iio device number being used is 1
trigger-less mode selected
Enabling all channels
Enabling: in_accel_x_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_accel_x_en
Failed to enable/disable in_accel_x_en
Enabling: in_accel_y_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_accel_y_en
Failed to enable/disable in_accel_y_en
Enabling: in_accel_z_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_accel_z_en
Failed to enable/disable in_accel_z_en
Enabling: in_timestamp_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_timestamp_en
Failed to enable/disable in_timestamp_en
Still no channels after auto-enabling, giving up
Disabling: in_accel_x_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_accel_x_en
Failed to enable/disable in_accel_x_en
Disabling: in_accel_y_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_accel_y_en
Failed to enable/disable in_accel_y_en
Disabling: in_accel_z_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_accel_z_en
Failed to enable/disable in_accel_z_en
Disabling: in_timestamp_en
failed to open /sys/bus/iio/devices/iio:device1/scan_elements/in_timestamp_en
Failed to enable/disable in_timestamp_en
The apparmor denied as:
[ 136.627749] audit: type=1400 audit(1503654228.739:311): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_accel_x_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.627863] audit: type=1400 audit(1503654228.739:312): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_accel_y_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.627953] audit: type=1400 audit(1503654228.739:313): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_accel_z_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.628042] audit: type=1400 audit(1503654228.739:314): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_timestamp_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.628749] audit: type=1400 audit(1503654228.739:315): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_accel_x_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.628838] audit: type=1400 audit(1503654228.739:316): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_accel_y_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.628926] audit: type=1400 audit(1503654228.739:317): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_accel_z_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
[ 136.629012] audit: type=1400 audit(1503654228.739:318): apparmor=“DENIED” operation=“open” profile=“snap.demo-iio-tools.iio-generic-buffer” name="/sys/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/scan_elements/in_timestamp_en" pid=3278 comm=“iio_generic_buf” requested_mask=“wc” denied_mask=“wc” fsuid=0 ouid=0
The iio sysfs path is symlink to i2c sysfs path:
/sys/bus/iio/devices/iio:device1 -> …/…/…/devices/platform/80860F41:00/i2c-0/i2c-SMO8A90:00/iio:device1/
I checked the code of snapd i2c interface. The apparmor profile using:
/sys/devices/platform/**.i2c/%s/** rw,
On my system, the sysfs of i2c path is not match this condition which as:
/sys/devices/platform/80860F41:00/i2c-0/
I had tried to manually update the apparmor profile of my snap with:
/sys/devices/platform/**/%s/** rw,
This rule works well for my snap.
I think my profile rule is not a good one.
Any suggestion for snapd to support the this case of i2c sysfs?
Thanks