From 4b58c573a591f52bf8ece98088d5fbe3f460380c Mon Sep 17 00:00:00 2001
From: Patrick Bellasi <patrick.bellasi@arm.com>
Date: Tue, 26 Apr 2016 15:33:23 +0100
Subject: [PATCH] cgroups: make probe method more robust

In case a target does not report a configuration file, we can still check
the user-space API to verify it CGroups are supported.

NOTE: a rooted target is still a mandatory requirement because some commands
are still dependant on the possibility to run them with root permissions.

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
---
 devlib/module/cgroups.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/devlib/module/cgroups.py b/devlib/module/cgroups.py
index fd908e1..942ed2c 100644
--- a/devlib/module/cgroups.py
+++ b/devlib/module/cgroups.py
@@ -235,7 +235,11 @@ class CgroupsModule(Module):
 
     @staticmethod
     def probe(target):
-        return target.config.has('cgroups') and target.is_rooted
+        if not target.is_rooted:
+            return False
+        if target.file_exists('/proc/cgroups'):
+            return True
+        return target.config.has('cgroups')
 
     def __init__(self, target):
         super(CgroupsModule, self).__init__(target)