/* Common handling for a write to a "cpus" or "mems" file.  */
static int cpuset_write_resmask(struct cgroup *cgrp, struct cftype *cft, const char *buf)
/* Common handling for a write to a "cpus" or "mems" file.  */
static int cpuset_write_resmask(struct cgroup *cgrp, struct cftype *cft, const char *buf)
{
	int retval = 0;
	struct cpuset *cs = cgroup_cs(cgrp);
	struct cpuset *trialcs;
	if (!cgroup_lock_live_group(cgrp))
		return -ENODEV;
	trialcs = alloc_trial_cpuset(cs);
	if (!trialcs)
		return -ENOMEM;
	switch (cft->private) {
	case FILE_CPULIST:
		retval = update_cpumask(cs, trialcs, buf);
		break;
	case FILE_MEMLIST:
		retval = update_nodemask(cs, trialcs, buf);
		break;
	default:
		retval = -EINVAL;
		break;
	}
	free_trial_cpuset(trialcs);
	cgroup_unlock();
	return retval;
}