return 0;
}
+static int process_group_get_comm_list(const struct resource *res,
+ const struct resource_attribute *attr,
+ void *data)
+{
+ struct process_group_context *ctx;
+ struct array_value *list = data;
+ struct process_info *pi;
+ char **data_array;
+ int i;
+
+ if (!res || !res->priv || !attr || !data)
+ return -EINVAL;
+
+ ctx = res->priv;
+
+ if (!ctx->pi_list)
+ return -EINVAL;
+
+ if (list->data) {
+ data_array = list->data;
+ for (i = 0; data_array[i] != NULL; i++)
+ free(data_array[i]);
+ free(data_array);
+ }
+
+ /* last item will be null for boundary check */
+ data_array = list->data = calloc(ctx->pi_list->len + 1, sizeof(char *));
+ if (!data_array)
+ return -ENOMEM;
+
+ list->type = DATA_TYPE_STRING;
+ list->length = ctx->pi_list->len;
+
+ for (i = 0; i < list->length; i++) {
+ pi = g_ptr_array_index(ctx->pi_list, i);
+ data_array[i] = strdup(pi->comm);
+ if (!data_array[i]) {
+ while (i > 0)
+ free(data_array[--i]);
+ free(data_array);
+ list->data = NULL;
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
static const struct resource_attribute process_group_attrs[] = {
{
.name = "PROCESS_GROUP_ATTR_PID_LIST",
.is_supported = resource_attr_supported_always,
},
},
+ {
+ .name = "PROCESS_GROUP_ATTR_COMM_LIST",
+ .id = PROCESS_GROUP_ATTR_COMM_LIST,
+ .type = DATA_TYPE_ARRAY,
+ .ops = {
+ .get = process_group_get_comm_list,
+ .is_supported = resource_attr_supported_always,
+ },
+ },
};
static int process_group_setup_root_pid(const struct resource *res,