cgroups: handle noprefix mounts

The cgroups mount might use the names "cpuset.cpus" and "cpuset.mems",
or "cpus" and "mems" (when mounted with "noprefix").  Support both.

BUG=chromium:786506, chromium:647994
TEST=precq still works

Change-Id: I07b5e62b3390426556a7d29599cc36be640bb699
(cherry picked from commit 994fd785b6465efc3eb86e65c57a770954bbeaec)
Reviewed-on: https://chromium-review.googlesource.com/1139242
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/lib/cgroups.py b/lib/cgroups.py
index f219549..d8078f4 100644
--- a/lib/cgroups.py
+++ b/lib/cgroups.py
@@ -380,11 +380,18 @@
         # settings
         self._SudoSet('cgroup.clone_children', '1')
 
+      # Deal with noprefix mount option.  Because Android.
+      # https://crbug.com/647994 & https://crbug.com/786506
+      name_prefix = 'cpuset.'
+      if os.path.exists(os.path.join(self.path, 'cpus')):
+        name_prefix = ''
+
       try:
         # TODO(ferringb): sort out an appropriate filter/list for using:
         # for name in os.listdir(parent):
         # rather than just transfering these two values.
-        for name in ('cpuset.cpus', 'cpuset.mems'):
+        for name in ('cpus', 'mems'):
+          name = name_prefix + name
           if not self._overwrite:
             # Top level nodes like cros/cbuildbot we don't want to overwrite-
             # users/system may've leveled configuration.  If it's empty,