Skip to contentSkip to conversation

Replace hard-coded MODVERDIR in modpost

FIX Andreas Gruenbacher 1 participant 1 message Sep 16, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello,

when building external modules, MODVERDIR is relative to the external module instead of in the kernel source tree. Use the MODVERDIR environment variable instead of the hard-coded path in modpost.

scripts/mod/sumversion.c +4 -4
Index: linux-2.6.8/scripts/mod/sumversion.c
===================================================================
@@ -416,7 +416,8 @@ static int get_version(const char *modna
 	struct md4_ctx md;
 	char *sources, *end, *fname;
 	const char *basename;
-	char filelist[sizeof(".tmp_versions/%s.mod") + strlen(modname)];
+	char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
+		      strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
 
 	/* Source files for module are in .tmp_versions/modname.mod,
 	   after the first line. */
@@ -424,9 +425,8 @@ static int get_version(const char *modna
 		basename = strrchr(modname, '/') + 1;
 	else
 		basename = modname;
-	sprintf(filelist, ".tmp_versions/%s", basename);
-	/* Truncate .o, add .mod */
-	strcpy(filelist + strlen(filelist)-2, ".mod");
+	sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"),
+		(int) strlen(basename) - 2, basename);
 
 	file = grab_file(filelist, &len);
 	if (!file) {

Cheers,

Signature · 2 lines
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX AG

Date: Thu, 16 Sep 2004 16:08:38 +0200
From: Andreas Gruenbacher <[email protected]>
Subject: Fix .tmp_versions for external modules

When building external modules, MODVERDIR is relative to the external module instead of in the kernel source tree. Use the MODVERDIR environment variable instead of the hard-coded path in modpost.

scripts/mod/sumversion.c +4 -4
Index: linux-2.6.8/scripts/mod/sumversion.c
===================================================================
@@ -416,7 +416,8 @@ static int get_version(const char *modna
 	struct md4_ctx md;
 	char *sources, *end, *fname;
 	const char *basename;
-	char filelist[sizeof(".tmp_versions/%s.mod") + strlen(modname)];
+	char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
+		      strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
 
 	/* Source files for module are in .tmp_versions/modname.mod,
 	   after the first line. */
@@ -424,9 +425,8 @@ static int get_version(const char *modna
 		basename = strrchr(modname, '/') + 1;
 	else
 		basename = modname;
-	sprintf(filelist, ".tmp_versions/%s", basename);
-	/* Truncate .o, add .mod */
-	strcpy(filelist + strlen(filelist)-2, ".mod");
+	sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"),
+		(int) strlen(basename) - 2, basename);
 
 	file = grab_file(filelist, &len);
 	if (!file) {