diff options
author | Matt Kraai <kraai@debian.org> | 2001-08-06 14:18:08 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2001-08-06 14:18:08 +0000 |
commit | 063c1f54eae3e1dcb8dd5c00ba9bf802357d3cb9 (patch) | |
tree | 4388471e90fd6deb1fd34379403e9108ee54d093 | |
parent | 69edfecfb981d5761c3e39f43f33451fd55e81b8 (diff) | |
download | busybox-w32-063c1f54eae3e1dcb8dd5c00ba9bf802357d3cb9.tar.gz busybox-w32-063c1f54eae3e1dcb8dd5c00ba9bf802357d3cb9.tar.bz2 busybox-w32-063c1f54eae3e1dcb8dd5c00ba9bf802357d3cb9.zip |
Simplified version checking.
-rw-r--r-- | insmod.c | 32 | ||||
-rw-r--r-- | modutils/insmod.c | 32 |
2 files changed, 16 insertions, 48 deletions
@@ -133,7 +133,7 @@ | |||
133 | #ifndef MODUTILS_MODULE_H | 133 | #ifndef MODUTILS_MODULE_H |
134 | static const int MODUTILS_MODULE_H = 1; | 134 | static const int MODUTILS_MODULE_H = 1; |
135 | 135 | ||
136 | #ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" | 136 | #ident "$Id: insmod.c,v 1.71 2001/08/06 14:18:08 kraai Exp $" |
137 | 137 | ||
138 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 138 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
139 | We do not use the kernel headers directly because we do not wish | 139 | We do not use the kernel headers directly because we do not wish |
@@ -350,7 +350,7 @@ int delete_module(const char *); | |||
350 | #ifndef MODUTILS_OBJ_H | 350 | #ifndef MODUTILS_OBJ_H |
351 | static const int MODUTILS_OBJ_H = 1; | 351 | static const int MODUTILS_OBJ_H = 1; |
352 | 352 | ||
353 | #ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" | 353 | #ident "$Id: insmod.c,v 1.71 2001/08/06 14:18:08 kraai Exp $" |
354 | 354 | ||
355 | /* The relocatable object is manipulated using elfin types. */ | 355 | /* The relocatable object is manipulated using elfin types. */ |
356 | 356 | ||
@@ -1304,22 +1304,6 @@ static unsigned long obj_elf_hash(const char *name) | |||
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING | 1306 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING |
1307 | /* Get the kernel version in the canonical integer form. */ | ||
1308 | |||
1309 | static int get_kernel_version(char str[STRVERSIONLEN]) | ||
1310 | { | ||
1311 | struct utsname uts_info; | ||
1312 | int kv; | ||
1313 | |||
1314 | if (uname(&uts_info) < 0) | ||
1315 | return -1; | ||
1316 | strncpy(str, uts_info.release, STRVERSIONLEN); | ||
1317 | |||
1318 | kv = get_kernel_revision(); | ||
1319 | if(kv==0) | ||
1320 | return -1; | ||
1321 | } | ||
1322 | |||
1323 | /* String comparison for non-co-versioned kernel and module. */ | 1307 | /* String comparison for non-co-versioned kernel and module. */ |
1324 | 1308 | ||
1325 | static int ncv_strcmp(const char *a, const char *b) | 1309 | static int ncv_strcmp(const char *a, const char *b) |
@@ -3239,8 +3223,7 @@ extern int insmod_main( int argc, char **argv) | |||
3239 | int exit_status = EXIT_FAILURE; | 3223 | int exit_status = EXIT_FAILURE; |
3240 | int m_has_modinfo; | 3224 | int m_has_modinfo; |
3241 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING | 3225 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING |
3242 | int k_version; | 3226 | struct utsname uts_info; |
3243 | char k_strversion[STRVERSIONLEN]; | ||
3244 | char m_strversion[STRVERSIONLEN]; | 3227 | char m_strversion[STRVERSIONLEN]; |
3245 | int m_version; | 3228 | int m_version; |
3246 | int m_crcs; | 3229 | int m_crcs; |
@@ -3355,7 +3338,8 @@ extern int insmod_main( int argc, char **argv) | |||
3355 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING | 3338 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING |
3356 | /* Version correspondence? */ | 3339 | /* Version correspondence? */ |
3357 | 3340 | ||
3358 | k_version = get_kernel_version(k_strversion); | 3341 | if (uname(&uts_info) < 0) |
3342 | uts_info.release[0] = '\0'; | ||
3359 | if (m_has_modinfo) { | 3343 | if (m_has_modinfo) { |
3360 | m_version = new_get_module_version(f, m_strversion); | 3344 | m_version = new_get_module_version(f, m_strversion); |
3361 | } else { | 3345 | } else { |
@@ -3367,17 +3351,17 @@ extern int insmod_main( int argc, char **argv) | |||
3367 | } | 3351 | } |
3368 | } | 3352 | } |
3369 | 3353 | ||
3370 | if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { | 3354 | if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) { |
3371 | if (flag_force_load) { | 3355 | if (flag_force_load) { |
3372 | error_msg("Warning: kernel-module version mismatch\n" | 3356 | error_msg("Warning: kernel-module version mismatch\n" |
3373 | "\t%s was compiled for kernel version %s\n" | 3357 | "\t%s was compiled for kernel version %s\n" |
3374 | "\twhile this kernel is version %s", | 3358 | "\twhile this kernel is version %s", |
3375 | m_filename, m_strversion, k_strversion); | 3359 | m_filename, m_strversion, uts_info.release); |
3376 | } else { | 3360 | } else { |
3377 | error_msg("kernel-module version mismatch\n" | 3361 | error_msg("kernel-module version mismatch\n" |
3378 | "\t%s was compiled for kernel version %s\n" | 3362 | "\t%s was compiled for kernel version %s\n" |
3379 | "\twhile this kernel is version %s.", | 3363 | "\twhile this kernel is version %s.", |
3380 | m_filename, m_strversion, k_strversion); | 3364 | m_filename, m_strversion, uts_info.release); |
3381 | goto out; | 3365 | goto out; |
3382 | } | 3366 | } |
3383 | } | 3367 | } |
diff --git a/modutils/insmod.c b/modutils/insmod.c index 1a63ecb2a..50aa60eb6 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -133,7 +133,7 @@ | |||
133 | #ifndef MODUTILS_MODULE_H | 133 | #ifndef MODUTILS_MODULE_H |
134 | static const int MODUTILS_MODULE_H = 1; | 134 | static const int MODUTILS_MODULE_H = 1; |
135 | 135 | ||
136 | #ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" | 136 | #ident "$Id: insmod.c,v 1.71 2001/08/06 14:18:08 kraai Exp $" |
137 | 137 | ||
138 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 138 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
139 | We do not use the kernel headers directly because we do not wish | 139 | We do not use the kernel headers directly because we do not wish |
@@ -350,7 +350,7 @@ int delete_module(const char *); | |||
350 | #ifndef MODUTILS_OBJ_H | 350 | #ifndef MODUTILS_OBJ_H |
351 | static const int MODUTILS_OBJ_H = 1; | 351 | static const int MODUTILS_OBJ_H = 1; |
352 | 352 | ||
353 | #ident "$Id: insmod.c,v 1.70 2001/07/31 22:51:49 andersen Exp $" | 353 | #ident "$Id: insmod.c,v 1.71 2001/08/06 14:18:08 kraai Exp $" |
354 | 354 | ||
355 | /* The relocatable object is manipulated using elfin types. */ | 355 | /* The relocatable object is manipulated using elfin types. */ |
356 | 356 | ||
@@ -1304,22 +1304,6 @@ static unsigned long obj_elf_hash(const char *name) | |||
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING | 1306 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING |
1307 | /* Get the kernel version in the canonical integer form. */ | ||
1308 | |||
1309 | static int get_kernel_version(char str[STRVERSIONLEN]) | ||
1310 | { | ||
1311 | struct utsname uts_info; | ||
1312 | int kv; | ||
1313 | |||
1314 | if (uname(&uts_info) < 0) | ||
1315 | return -1; | ||
1316 | strncpy(str, uts_info.release, STRVERSIONLEN); | ||
1317 | |||
1318 | kv = get_kernel_revision(); | ||
1319 | if(kv==0) | ||
1320 | return -1; | ||
1321 | } | ||
1322 | |||
1323 | /* String comparison for non-co-versioned kernel and module. */ | 1307 | /* String comparison for non-co-versioned kernel and module. */ |
1324 | 1308 | ||
1325 | static int ncv_strcmp(const char *a, const char *b) | 1309 | static int ncv_strcmp(const char *a, const char *b) |
@@ -3239,8 +3223,7 @@ extern int insmod_main( int argc, char **argv) | |||
3239 | int exit_status = EXIT_FAILURE; | 3223 | int exit_status = EXIT_FAILURE; |
3240 | int m_has_modinfo; | 3224 | int m_has_modinfo; |
3241 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING | 3225 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING |
3242 | int k_version; | 3226 | struct utsname uts_info; |
3243 | char k_strversion[STRVERSIONLEN]; | ||
3244 | char m_strversion[STRVERSIONLEN]; | 3227 | char m_strversion[STRVERSIONLEN]; |
3245 | int m_version; | 3228 | int m_version; |
3246 | int m_crcs; | 3229 | int m_crcs; |
@@ -3355,7 +3338,8 @@ extern int insmod_main( int argc, char **argv) | |||
3355 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING | 3338 | #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING |
3356 | /* Version correspondence? */ | 3339 | /* Version correspondence? */ |
3357 | 3340 | ||
3358 | k_version = get_kernel_version(k_strversion); | 3341 | if (uname(&uts_info) < 0) |
3342 | uts_info.release[0] = '\0'; | ||
3359 | if (m_has_modinfo) { | 3343 | if (m_has_modinfo) { |
3360 | m_version = new_get_module_version(f, m_strversion); | 3344 | m_version = new_get_module_version(f, m_strversion); |
3361 | } else { | 3345 | } else { |
@@ -3367,17 +3351,17 @@ extern int insmod_main( int argc, char **argv) | |||
3367 | } | 3351 | } |
3368 | } | 3352 | } |
3369 | 3353 | ||
3370 | if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { | 3354 | if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) { |
3371 | if (flag_force_load) { | 3355 | if (flag_force_load) { |
3372 | error_msg("Warning: kernel-module version mismatch\n" | 3356 | error_msg("Warning: kernel-module version mismatch\n" |
3373 | "\t%s was compiled for kernel version %s\n" | 3357 | "\t%s was compiled for kernel version %s\n" |
3374 | "\twhile this kernel is version %s", | 3358 | "\twhile this kernel is version %s", |
3375 | m_filename, m_strversion, k_strversion); | 3359 | m_filename, m_strversion, uts_info.release); |
3376 | } else { | 3360 | } else { |
3377 | error_msg("kernel-module version mismatch\n" | 3361 | error_msg("kernel-module version mismatch\n" |
3378 | "\t%s was compiled for kernel version %s\n" | 3362 | "\t%s was compiled for kernel version %s\n" |
3379 | "\twhile this kernel is version %s.", | 3363 | "\twhile this kernel is version %s.", |
3380 | m_filename, m_strversion, k_strversion); | 3364 | m_filename, m_strversion, uts_info.release); |
3381 | goto out; | 3365 | goto out; |
3382 | } | 3366 | } |
3383 | } | 3367 | } |