return lxc_write_openat(h->path_lim, filename, value, strlen(value));
}
+/*
+ * Return the list of cgroup_settings sorted according to the following rules
+ * 1. Put memory.limit_in_bytes before memory.memsw.limit_in_bytes
+ */
+static void sort_cgroup_settings(struct lxc_conf *conf)
+{
+ LIST_HEAD(memsw_list);
+ struct lxc_cgroup *cgroup, *ncgroup;
+
+ /* Iterate over the cgroup settings and copy them to the output list. */
+ list_for_each_entry_safe(cgroup, ncgroup, &conf->cgroup, head) {
+ if (!strequal(cgroup->subsystem, "memory.memsw.limit_in_bytes"))
+ continue;
+
+ /* Move the memsw entry from the cgroup settings list. */
+ list_move_tail(&cgroup->head, &memsw_list);
+ }
+
+ /*
+ * Append all the memsw entries to the end of the cgroup settings list
+ * to make sure they are applied after all memory limit settings.
+ */
+ list_splice_tail(&memsw_list, &conf->cgroup);
+
+}
+
__cgfsng_ops static bool cgfsng_setup_limits_legacy(struct cgroup_ops *ops,
struct lxc_conf *conf,
bool do_devices)
ERROR("lxc.idmap = g 0 %u %u", gid, grange);
}
-/* Return the list of cgroup_settings sorted according to the following rules
- * 1. Put memory.limit_in_bytes before memory.memsw.limit_in_bytes
- */
-void sort_cgroup_settings(struct lxc_conf *conf)
-{
- struct lxc_cgroup *cgroup, *memsw_limit, *ncgroup;
-
- /* Iterate over the cgroup settings and copy them to the output list. */
- list_for_each_entry_safe(cgroup, ncgroup, &conf->cgroup, head) {
- if (strequal(cgroup->subsystem, "memory.memsw.limit_in_bytes")) {
- /* Store the memsw_limit location */
- memsw_limit = cgroup;
- } else if (memsw_limit && strequal(cgroup->subsystem, "memory.limit_in_bytes")) {
- /*
- * lxc.cgroup.memory.memsw.limit_in_bytes is found
- * before lxc.cgroup.memory.limit_in_bytes, swap these
- * two items.
- */
- list_swap(&memsw_limit->head, &cgroup->head);
- }
- }
-}
-
int lxc_set_environment(const struct lxc_conf *conf)
{
struct environment_entry *env;
__hidden extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
__hidden extern void suggest_default_idmap(void);
__hidden extern FILE *make_anonymous_mount_file(struct lxc_list *mount, bool include_nesting_helpers);
-__hidden extern void sort_cgroup_settings(struct lxc_conf *conf);
__hidden extern int run_script(const char *name, const char *section, const char *script, ...);
__hidden extern int run_script_argv(const char *name, unsigned int hook_version, const char *section,
const char *script, const char *hookname, char **argsin);