[lxc-devel] [PATCH] cgroupfs: need the full path to setup cpuset

Serge Hallyn serge.hallyn at ubuntu.com
Thu Jan 23 17:21:22 UTC 2014


Quoting Qiang Huang (h.huangqiang at huawei.com):
> Function file_exists() needs a absolute full path, but we are using
> current_entire_path which is not. It will get the wrong result from
> file_exists() and case Segmentation fault when we fopen a non-exist
> file and try to fscanf from it.
> 
> Signed-off-by: Qiang Huang <h.huangqiang at huawei.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/cgroup.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
> index 4da0e07..34bf126 100644
> --- a/src/lxc/cgroup.c
> +++ b/src/lxc/cgroup.c
> @@ -958,12 +958,20 @@ struct cgroup_process_info *lxc_cgroupfs_create(const char *name, const char *pa
>  				goto cleanup_from_error;
>  			} else if (r == 0) {
>  				/* successfully created */
> +				char *full_path = NULL;
>  				r = lxc_grow_array((void ***)&info_ptr->created_paths, &info_ptr->created_paths_capacity, info_ptr->created_paths_count + 1, 8);
>  				if (r < 0)
>  					goto cleanup_from_error;
>  				info_ptr->created_paths[info_ptr->created_paths_count++] = current_entire_path;
> +
> +				full_path = cgroup_to_absolute_path(
> +						info_ptr->designated_mount_point,
> +						current_entire_path, NULL);
> +				if (!full_path)
> +					goto cleanup_from_error;
>  				setup_cpuset_if_needed(info_ptr->hierarchy->subsystems,
> -						current_entire_path);
> +						full_path);
> +				free(full_path);
>  			} else {
>  				/* if we didn't create the cgroup, then we have to make sure that
>  				 * further cgroups will be created properly
> -- 
> 1.8.3
> 


More information about the lxc-devel mailing list