[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] gziped modules support for insmod/modprobe
From: diego.alvarez () entelchile ! net
Date: 2002-04-27 15:22:02
[Download RAW message or body]
Hi,
well, i dont speak english so i'll be breve
I made a patch for insmod and modprobe.
I added a "-z" option in both applets,
so insmod gunzip the module before load it.
well i hope is understandable what i wrote :)
c ya
--
I feel sorry, for what you try to do
Breaking others down, to try and to pursue
Your own selfish interests
I am starting to get sick of you
The Gathering.
["insmod.c.path" (text/plain)]
--- insmod.orig.c Thu Apr 11 21:59:21 2002
+++ insmod.c Sat Apr 27 15:24:56 2002
@@ -623,6 +623,7 @@
static int flag_autoclean = 0;
static int flag_verbose = 0;
static int flag_export = 1;
+static int flag_gunzip = 0;
/*======================================================================*/
@@ -3203,6 +3204,11 @@
ELFW(ST_INFO) (STB_LOCAL, ELFW(ST_TYPE) (sym->info));
}
+void delete_unziped_module(char *name)
+{
+ if (unlink(name) < 0)
+ fprintf(stderr, "Couldnt remove %s", name);
+}
extern int insmod_main( int argc, char **argv)
@@ -3218,6 +3224,7 @@
struct obj_file *f;
struct stat st;
char m_name[FILENAME_MAX + 1] = "\0";
+ char m_ext[6];
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
@@ -3228,8 +3235,11 @@
#endif
/* Parse any options */
- while ((opt = getopt(argc, argv, "fkvxLo:")) > 0) {
+ while ((opt = getopt(argc, argv, "zfkvxLo:")) > 0) {
switch (opt) {
+ case 'z': /* gunzip module */
+ flag_gunzip = 1;
+ break;
case 'f': /* force loading */
flag_force_load = 1;
break;
@@ -3267,15 +3277,25 @@
tmp = argv[optind];
}
len = strlen(tmp);
-
- if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o')
- len -= 2;
+
+ if (flag_gunzip)
+ {
+ strcpy(m_ext, ".o.gz");
+ if (len > 5 && tmp[len - 5] == '.' && tmp[len - 4] == 'o' && tmp[len - 3] == '.' \
&& tmp[len - 2] == 'g' && tmp[len - 1] == 'z') + len -= 5;
+ }
+ else
+ {
+ strcpy(m_ext, ".o");
+ if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o')
+ len -= 2;
+ }
memcpy(m_fullName, tmp, len);
m_fullName[len]='\0';
if (*m_name == '\0') {
strcpy(m_name, m_fullName);
}
- strcat(m_fullName, ".o");
+ strcat(m_fullName, m_ext);
/* Get a filedesc for the module. Check we we have a complete path */
if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) ||
@@ -3323,11 +3343,52 @@
} else
safe_strncpy(m_filename, argv[optind], sizeof(m_filename));
+ if (flag_gunzip)
+ {
+ FILE *fp_unziped;
+ int my_len;
+ char m_filename_unziped[FILENAME_MAX + 1] = "\0";
+
+ strcpy(m_filename_unziped, m_filename);
+ my_len = strlen(m_filename_unziped);
+ m_filename_unziped[my_len - 3] = '\0';
+
+ if ((fp_unziped = fopen (m_filename_unziped, "w")) == NULL)
+ {
+ perror(m_filename_unziped);
+ return EXIT_FAILURE;
+ }
+
+ if (unzip(fp, fp_unziped) != 0)
+ {
+ fclose(fp);
+ fclose(fp_unziped);
+ error_msg("unable to gunzip %s", m_filename_unziped);
+ delete_unziped_module(m_filename_unziped);
+ return EXIT_FAILURE;
+ }
+
+ fclose(fp);
+ fclose(fp_unziped);
+
+ strcpy(m_filename, m_filename_unziped);
+
+ if ((fp = fopen (m_filename, "r")) == NULL)
+ {
+ perror(m_filename);
+ return EXIT_FAILURE;
+ }
+ }
+
printf("Using %s\n", m_filename);
if ((f = obj_load(fp, LOADBITS)) == NULL)
+ {
+ if (flag_gunzip)
+ delete_unziped_module(m_filename);
perror_msg_and_die("Could not load the module");
-
+ }
+
if (get_modinfo_value(f, "kernel_version") == NULL)
m_has_modinfo = 0;
else
@@ -3479,5 +3540,7 @@
out:
fclose(fp);
+ if (flag_gunzip)
+ delete_unziped_module(m_filename);
return(exit_status);
}
["modprobe.c.path" (text/plain)]
--- modprobe.orig.c Wed Apr 24 15:49:03 2002
+++ modprobe.c Sat Apr 27 16:35:24 2002
@@ -18,6 +18,7 @@
#include "busybox.h"
static char cmd[128];
+static int unzip_module = 0;
#define BB_FEATURE_MODPROBE_DEPEND
@@ -188,8 +189,16 @@
}
if ( loadit ) {
char lcmd [128];
+
+ if (unzip_module) {
+ int my_len;
+
+ my_len=strlen(mod);
+ if (mod[my_len - 2] == '.' && mod[my_len - 1] == 'o')
+ mod[my_len - 2] = '\0';
+ }
- sprintf ( lcmd, "insmod -k %s 2>/dev/null", mod );
+ sprintf ( lcmd, "insmod -k %s %s 2>/dev/null",unzip_module ? "-z" : "" , mod);
system ( lcmd );
}
}
@@ -204,8 +213,11 @@
int show_only = 0, quiet = 0, remove_opt = 0, do_syslog = 0, verbose = 0;
char *load_type = NULL, *config = NULL;
- while ((ch = getopt(argc, argv, "acdklnqrst:vVC:")) != -1)
+ while ((ch = getopt(argc, argv, "zacdklnqrst:vVC:")) != -1)
switch(ch) {
+ case 'z':
+ unzip_module = 1;
+ break;
case 'a':
loadall++;
break;
@@ -280,10 +292,11 @@
exit(EXIT_FAILURE);
}
- sprintf(cmd, "insmod %s %s %s",
+ sprintf(cmd, "insmod %s %s %s %s",
do_syslog ? "-s" : "",
quiet ? "-q" : "",
- autoclean ? "-k" : "");
+ autoclean ? "-k" : "",
+ unzip_module ? "-z" : "");
#ifdef BB_FEATURE_MODPROBE_DEPEND
check_dep ( argv [optind], 0 );
["usage.h.path" (text/plain)]
--- usage.orig.h Fri Apr 26 03:06:23 2002
+++ usage.h Sat Apr 27 15:34:59 2002
@@ -815,6 +815,7 @@
"\t-k\tMake module autoclean-able.\n" \
"\t-v\tverbose output\n" \
"\t-L\tLock to prevent simultaneous loads of a module\n" \
+ "\t-z\tsupport for gzip'ed modules\n"\
"\t-x\tdo not export externs"
#define kill_trivial_usage \
@@ -1110,7 +1111,10 @@
#define modprobe_trivial_usage \
"[FILE ...]"
#define modprobe_full_usage \
- "Used for hight level module loading and unloading."
+ "Used for hight level module loading and unloading.\n\n"\
+ "Options:\n"\
+ "\t-z\tSupport for gzip'ed modules\n"
+
#define modprobe_example_usage \
"$ modprobe cdrom\n"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic