[CRIU] [PATCH 1/4] crtools: preload libraries

Cyrill Gorcunov gorcunov at gmail.com
Sun Dec 1 13:27:23 PST 2013


On Sat, Nov 30, 2013 at 09:43:53PM +0400, Andrey Vagin wrote:
>  
> +static int cr_lib_add(char *path)
> +{
> +	struct cr_lib *l;
> +	cr_init_t *f_init;
> +	void *h;
> +
> +	h = dlopen(path, RTLD_LAZY);
> +	if (h == NULL) {
> +		pr_err("Unable to load %s: %s", path, dlerror());
> +		return -1;
> +	}
> +
> +	f_init = dlsym(h, "cr_init");
> +	if (f_init && f_init())
> +		return -1;
> +
> +	l = xmalloc(sizeof(struct cr_lib));
> +	if (l == NULL)
> +		goto err;
> +
> +	l->handle = h;
> +	list_add(&l->node, &opts.libs);

Btw, since the libraries are called in order as they appear in command line
probably it might have sense to use list_add_tail here and then call for
hooks with list_for_each (when it'll be needed).


More information about the CRIU mailing list