From: zhaolei@cn.fujitsu.com (Zhaolei)
Subject: [ltt-dev] [PATCH 2/2] Make lttctl load ltt-trace-control module automatically
Date: Wed, 07 Jan 2009 16:09:11 +0800 [thread overview]
Message-ID: <49646327.2020307@cn.fujitsu.com> (raw)
In-Reply-To: <49646208.7070607@cn.fujitsu.com>
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
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;
}
next prev parent reply other threads:[~2009-01-07 8:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-07 8:04 [ltt-dev] [PATCH 1/2] Make lttctl mount debugfs automatically Zhaolei
2009-01-07 8:09 ` Zhaolei [this message]
2009-01-15 1:20 ` [ltt-dev] [PATCH 2/2] Make lttctl load ltt-trace-control module automatically Mathieu Desnoyers
2009-01-07 14:20 ` [ltt-dev] [PATCH 1/2] Make lttctl mount debugfs automatically Pierre-Marc Fournier
2009-01-08 0:40 ` Zhaolei
2009-01-08 14:44 ` Mathieu Desnoyers
2009-01-09 1:57 ` Zhaolei
2009-01-09 3:30 ` Mathieu Desnoyers
2009-01-13 23:54 ` Greg KH
2009-01-14 2:02 ` Josh Boyer
2009-01-14 5:16 ` Mathieu Desnoyers
2009-01-14 5:54 ` Greg KH
2009-01-15 1:41 ` Mathieu Desnoyers
2009-01-15 1:20 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49646327.2020307@cn.fujitsu.com \
--to=zhaolei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox