Skip to contentSkip to conversation

markup_oops: Use modinfo to avoid confusion with underscored module names

PATCH Superseded Ozan Çağlayan 3 participants 6 messages Aug 6, 2009 – Aug 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 markup_oops: Use modinfo to avoid confusion with underscored module names

When EIP is at a module having an underscore in its name, the current code fails to find it because the module filenames has '-' instead of '_'.

Use modinfo to correctly get the full path to the module.

---
This is just a trivial patch to pinpoint the problem. Usage of modinfo is faster than searching through the filesystem but may not be desirable as it brings a dependency to module-init-tools. Replacing underscore occurences by '-' can be another solution.

 scripts/markup_oops.pl |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
scripts/markup_oops.pl +1 -4
index 8977401..bc14f4c 100644
@@ -184,10 +184,7 @@ if ($target eq "0") {
 
 # if it's a module, we need to find the .ko file and calculate a load offset
 if ($module ne "") {
-	my $dir = dirname($filename);
-	$dir = $dir . "/";
-	my $mod = $module . ".ko";
-	my $modulefile = `find $dir -name $mod | head -1`;
+	my $modulefile = `modinfo $module | grep 'filename' | gawk '{ print \$2 }'`;
 	chomp($modulefile);
 	$filename = $modulefile;
 	if ($filename eq "") {
Signature · 1 line
1.6.3.4
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Thu, 6 Aug 2009 15:21:55 +0300 Ozan Çağlayan <[email protected]> wrote:

When EIP is at a module having an underscore in its name, the current code fails to find it because the module filenames has '-' instead of '_'.

Use modinfo to correctly get the full path to the module.

I like it, it's simple.
I don't mind about the module-init-tools dependency, everyone will have that already.

Andrew: can you hover this one up and send to Linus when its time is due?

Quoted 25 lines

---
This is just a trivial patch to pinpoint the problem. Usage of modinfo is faster than searching through the filesystem but may not be desirable as it brings a dependency to module-init-tools. Replacing underscore occurences by '-' can be another solution.

 scripts/markup_oops.pl |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
scripts/markup_oops.pl +1 -4
index 8977401..bc14f4c 100644
@@ -184,10 +184,7 @@ if ($target eq "0") {
 
 # if it's a module, we need to find the .ko file and calculate a
 load offset if ($module ne "") {
-	my $dir = dirname($filename);
-	$dir = $dir . "/";
-	my $mod = $module . ".ko";
-	my $modulefile = `find $dir -name $mod | head -1`;
+	my $modulefile = `modinfo $module | grep 'filename' | gawk
 '{ print \$2 }'`; chomp($modulefile);
 	$filename = $modulefile;
 	if ($filename eq "") {
Signature · 3 lines
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#2 lore raw
Quoted 8 lines · Arjan van de Ven
Quoted 4 lines · On Thu, 6 Aug 2009 15:21:55 +0300 Ozan Çağlayan <[email protected]> wrote:

When EIP is at a module having an underscore in its name, the current code fails to find it because the module filenames has '-' instead of '_'.

Quoted 9 lines
Quoted 4 lines

Use modinfo to correctly get the full path to the module.

I like it, it's simple.
I don't mind about the module-init-tools dependency, everyone will have that already.

BTW, note that the old code was searching for *.ko files in dirname($vmlinux_name). Replacing it by modprobe will eventually always search for the modules in /lib/modules/KVER/.

#3 lore raw
In reply to Ozan Çağlayan
Quoted 20 lines · Ozan Çağlayan

When EIP is at a module having an underscore in its name, the current code fails to find it because the module filenames has '-' instead of '_'.

Use modinfo to correctly get the full path to the module.

---
This is just a trivial patch to pinpoint the problem. Usage of modinfo is faster than searching through the filesystem but may not be desirable as it brings a dependency to module-init-tools. Replacing underscore occurences by '-' can be another solution.

scripts/markup_oops.pl | 5 +----

1 files changed, 1 insertions(+), 4 deletions(-)
scripts/markup_oops.pl +0 -0
index 8977401..bc14f4c 100644

scripts/markup_oops.pl if ($target eq "0") { · line 187

Quoted 8 lines
scripts/markup_oops.pl +1 -4
@@ -184,10 +184,7 @@ if ($target eq "0") {
 
 # if it's a module, we need to find the .ko file and calculate a load offset
 if ($module ne "") {
-	my $dir = dirname($filename);
-	$dir = $dir . "/";
-	my $mod = $module . ".ko";
-	my $modulefile = `find $dir -name $mod | head -1`;
+	my $modulefile = `modinfo $module | grep 'filename' | gawk '{ print \$2 }'`;

I know this works, but how about grep '^filename:' ? This is more strict.

Also, although on most Linux awk is just a symbol link to gawk, but it is still better to use awk instead of gawk for portability reason.

Quoted 3 lines
scripts/markup_oops.pl +0 -0
 	chomp($modulefile);
 	$filename = $modulefile;
 	if ($filename eq "") {
#4 lore raw

PATCH v2 1/1 markup_oops: Use modinfo to avoid confusion with underscored module names

In reply to Ozan Çağlayan

When EIP is at a module having an underscore in its name, the current code fails to find it because the module filenames has '-' instead of '_'. Use modinfo for a better path finding.

---
 scripts/markup_oops.pl |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
scripts/markup_oops.pl +1 -4
index 8977401..5f0fcb7 100644
@@ -184,10 +184,7 @@ if ($target eq "0") {
 
 # if it's a module, we need to find the .ko file and calculate a load offset
 if ($module ne "") {
-	my $dir = dirname($filename);
-	$dir = $dir . "/";
-	my $mod = $module . ".ko";
-	my $modulefile = `find $dir -name $mod | head -1`;
+	my $modulefile = `modinfo $module | grep '^filename:' | awk '{ print \$2 }'`;
 	chomp($modulefile);
 	$filename = $modulefile;
 	if ($filename eq "") {
Signature · 1 line
1.6.3.4
Acked-by on v2 1/1
#5 lore raw
Quoted 5 lines · Ozan Çağlayan

When EIP is at a module having an underscore in its name, the current code fails to find it because the module filenames has '-' instead of '_'. Use modinfo for a better path finding.

Thanks!

Quoted 28 lines

---
scripts/markup_oops.pl | 5 +----

1 files changed, 1 insertions(+), 4 deletions(-)
scripts/markup_oops.pl +1 -4
index 8977401..5f0fcb7 100644
@@ -184,10 +184,7 @@ if ($target eq "0") {
 
 # if it's a module, we need to find the .ko file and calculate a load offset
 if ($module ne "") {
-	my $dir = dirname($filename);
-	$dir = $dir . "/";
-	my $mod = $module . ".ko";
-	my $modulefile = `find $dir -name $mod | head -1`;
+	my $modulefile = `modinfo $module | grep '^filename:' | awk '{ print \$2 }'`;
 	chomp($modulefile);
 	$filename = $modulefile;
 	if ($filename eq "") {
Signature · 7 lines
1.6.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 1 line
Live like a child, think like the god.