diff options
| -rw-r--r-- | interfaces/builtin/gpio.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/interfaces/builtin/gpio.go b/interfaces/builtin/gpio.go index 766d0ff8c7..2f723d0fff 100644 --- a/interfaces/builtin/gpio.go +++ b/interfaces/builtin/gpio.go @@ -23,6 +23,7 @@ import ( "fmt" "os" "strconv" + "time" "github.com/snapcore/snapd/interfaces" "github.com/snapcore/snapd/interfaces/apparmor" @@ -117,6 +118,16 @@ func (iface *gpioInterface) AppArmorConnectedPlug(spec *apparmor.Specification, return err } } + // give the kernel/mock a bit of time to export the device + for i := 0; i < 100; i++ { + if osutil.FileExists(path) { + break + } + time.Sleep(100 * time.Millisecond) + } + if !osutil.FileExists(path) { + return fmt.Errorf("%q was not created", path) + } } // Entries in /sys/class/gpio for single GPIO's are just symlinks |
