/**
* Returns path where is mounted given controller. Applications should rely on
* @c libcgroup API and not call this function directly.
+ * Only the first mount point is returned, use
+ * cgroup_get_subsys_mount_point_begin(), cgroup_get_subsys_mount_point_next()
+ * and cgroup_get_subsys_mount_point_end() to get all of them.
* @param controller Name of the controller
* @param mount_point The string where the mount point location is stored.
* Please note, the caller must free the mount_point.
*/
int cgroup_get_all_controller_end(void **handle);
+/**
+ * @}
+ *
+ * @name List all mount points of a controller.
+ * Use following functions to list all mount points of a hierarchy with given
+ * controller.
+ */
+
+/**
+ * Read the first mount point of the hierarchy with given controller.
+ * The first is the same as the mount point returned by
+ * cgroup_get_subsys_mount_point().
+ * @param handle Handle to be used for iteration.
+ * @param controller Controller name.
+ * @param path Buffer to fill the path into. The buffer must be at least
+ * FILENAME_MAX characters long.
+ */
+int cgroup_get_subsys_mount_point_begin(const char *controller, void **handle,
+ char *path);
+/**
+ * Read next mount point of the hierarchy with given controller.
+ * @param handle Handle to be used for iteration.
+ * @param path Buffer to fill the path into. The buffer must be at least
+ * FILENAME_MAX characters long.
+ */
+int cgroup_get_subsys_mount_point_next(void **handle,
+ char *path);
+
+/**
+ * Release the iterator.
+ */
+int cgroup_get_subsys_mount_point_end(void **handle);
+
/**
* @}
* @}
*/
+
__END_DECLS
#endif /* _LIBCGROUP_ITERATORS_H */
*handle = NULL;
}
+int cgroup_get_subsys_mount_point_begin(const char *controller, void **handle,
+ char *path)
+{
+ int i;
+
+ if (!cgroup_initialized)
+ return ECGROUPNOTINITIALIZED;
+ if (!handle || !path || !controller)
+ return ECGINVAL;
+
+
+ for (i = 0; cg_mount_table[i].name[0] != '\0'; i++)
+ if (strcmp(controller, cg_mount_table[i].name) == 0)
+ break;
+
+ if (cg_mount_table[i].name[0] == '\0') {
+ /* the controller is not mounted at all */
+ *handle = NULL;
+ *path = '\0';
+ return ECGEOF;
+ }
+
+ /*
+ * 'handle' is pointer to struct cg_mount_point, which should be
+ * returned next.
+ */
+ *handle = cg_mount_table[i].mount.next;
+ strcpy(path, cg_mount_table[i].mount.path);
+ return 0;
+}
+
+int cgroup_get_subsys_mount_point_next(void **handle,
+ char *path)
+{
+ struct cg_mount_point *it;
+
+ if (!cgroup_initialized)
+ return ECGROUPNOTINITIALIZED;
+ if (!handle || !path)
+ return ECGINVAL;
+
+ it = *handle;
+ if (!it) {
+ *handle = NULL;
+ *path = '\0';
+ return ECGEOF;
+ }
+
+ *handle = it->next;
+ strcpy(path, it->path);
+ return 0;
+}
+
+int cgroup_get_subsys_mount_point_end(void **handle)
+{
+ return 0;
+}
+
+
cgroup_read_value_end;
cg_chmod_recursive;
} CGROUP_0.36;
+
+CGROUP_0.38 {
+ cgroup_get_subsys_mount_point_begin;
+ cgroup_get_subsys_mount_point_next;
+ cgroup_get_subsys_mount_point_end;
+} CGROUP_0.37;
+