[ltt-dev] [PATCH 2/2] Make lttctl load ltt-trace-control module automatically

Mathieu Desnoyers compudj at krystal.dyndns.org
Wed Jan 14 20:20:18 EST 2009


* Zhaolei (zhaolei at cn.fujitsu.com) wrote:
> lttctl need to use ltt-trace-control module.
> This patch make lttctl try to load ltt-trace-control module automatically when
> ltt-trace-control is compiled as a module and not loaded.
> 
> Applies on ltt-control-0.63-03012009 with previous patch of:
> [PATCH 1/2] Make lttctl mount debugfs automatically
> 

Applied to ltt-control 0.64, thanks !

Mathieu

> Signed-off-by: Zhao lei <zhaolei at cn.fujitsu.com>
> ---
>  liblttctl.c |   51 +++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 39 insertions(+), 12 deletions(-)
> diff -Nur ltt-control-0.63-03012009.org/liblttctl/liblttctl.c ltt-control-0.63-03012009.new/liblttctl/liblttctl.c
> --- ltt-control-0.63-03012009.org/liblttctl/liblttctl.c	2009-01-07 15:54:45.000000000 +0800
> +++ ltt-control-0.63-03012009.new/liblttctl/liblttctl.c	2009-01-07 15:54:49.000000000 +0800
> @@ -42,11 +42,44 @@
>  	return getdebugfsmntdir(debugfsmntdir);
>  }
>  
> +/*
> + * This function must called posterior to initdebugfsmntdir(),
> + * because it need to use debugfsmntdir[] which is inited in initdebugfsmntdir()
> + */
> +static int initmodule(void)
> +{
> +	char controldirname[PATH_MAX];
> +	DIR *dir;
> +	int tryload_done = 0;
> +
> +	sprintf(controldirname, "%s/ltt/control/", debugfsmntdir);
> +
> +check_again:
> +	/*
> +	 * Check ltt control's debugfs dir
> +	 *
> +	 * We don't check is ltt-trace-control module exist, because it maybe
> +	 * compiled into kernel.
> +	 */
> +	dir = opendir(controldirname);
> +	if (dir) {
> +		closedir(dir);
> +		return 0;
> +	}
> +
> +	if (!tryload_done) {
> +		system("modprobe ltt-trace-control");
> +		tryload_done = 1;
> +		goto check_again;
> +	}
> +
> +	return -ENOENT;
> +}
> +
>  int lttctl_init(void)
>  {
>  	int ret;
> -	DIR *dir;
> -	char controldirname[PATH_MAX];
> +
>  
>  	ret = initdebugfsmntdir();
>  	if (ret) {
> @@ -54,18 +87,12 @@
>  		return 1;
>  	}
>  
> -	/* check ltt control's debugfs dir */
> -	sprintf(controldirname, "%s/ltt/control/", debugfsmntdir);
> -
> -	dir = opendir(controldirname);
> -	if (!dir) {
> -		fprintf(stderr, "ltt-trace-control's debugfs dir not found\n");
> -		closedir(dir);
> -		return -errno;
> +	ret = initmodule();
> +	if (ret) {
> +		fprintf(stderr, "Control module seems not work\n");
> +		return 1;
>  	}
>  
> -	closedir(dir);
> -
>  	return 0;
>  }
>  
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list