Files
bpfire/src/patches/busybox-0.60.5-gzip.patch

172 lines
4.2 KiB
Diff

--- busybox-0.60.5/insmod.c 2002-09-16 06:30:10.000000000 +0100
+++ busybox-0.60.5.gz/insmod.c 2003-12-29 17:43:56.000000000 +0000
@@ -3429,6 +3429,12 @@
close(fd);
}
+void delete_unziped_module(char *name)
+{
+ if (unlink(name) < 0)
+ fprintf(stderr, "Couldnt remove %s", name);
+}
+
extern int insmod_main( int argc, char **argv)
{
int opt;
@@ -3444,6 +3450,7 @@
char m_name[FILENAME_MAX] = "\0";
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
+ int gunzip = 0;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
struct utsname uts_info;
char m_strversion[STRVERSIONLEN];
@@ -3498,9 +3505,18 @@
tmp = basename(tmp1);
len = strlen(tmp);
- if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
- len-=2;
+ if (len > 5 && tmp[len - 5] == '.' && tmp[len - 4] == 'o' && tmp[len - 3] == '.' && tmp[len - 2] == 'g' && tmp[len - 1] == 'z') {
+ len-=5;
tmp[len] = '\0';
+ gunzip = 1;
+ }
+ else
+ {
+ if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
+ len-=2;
+ tmp[len] = '\0';
+ gunzip = 0;
+ }
}
/* Make sure there is space for the terminal NULL */
len += 1;
@@ -3524,6 +3540,7 @@
(fp = fopen(argv[optind], "r")) == NULL) {
struct utsname myuname;
+AGAIN:
/* Hmm. Could not open it. First search under /lib/modules/`uname -r`,
* but do not error out yet if we fail to find it... */
if (uname(&myuname) == 0) {
@@ -3542,6 +3559,14 @@
check_module_name_match, 0, m_fullName);
}
+ /* If we've not found anything, try the gzipped version */
+ if ((m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL)) && !gunzip)
+ {
+ strcat(m_fullName, ".gz");
+ gunzip = 1;
+ goto AGAIN;
+ }
+
/* Check if we have found anything yet */
if (m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL))
{
@@ -3565,11 +3590,52 @@
} else
safe_strncpy(m_filename, argv[optind], sizeof(m_filename));
+ if (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)
- perror_msg_and_die("Could not load the module");
-
+ {
+ if (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
@@ -3679,8 +3745,6 @@
/* Find current size of the module */
m_size = obj_load_size(f);
-
-
m_addr = create_module(m_name, m_size);
if (m_addr==-1) switch (errno) {
case EEXIST:
@@ -3723,5 +3787,7 @@
out:
fclose(fp);
+ if (gunzip)
+ delete_unziped_module(m_filename);
return(exit_status);
}
--- busybox-0.60.5/modprobe.c 2003-12-29 17:05:50.000000000 +0000
+++ busybox-0.60.5.gz/modprobe.c 2004-01-01 19:22:44.000000000 +0000
@@ -105,6 +105,9 @@
else
mods++;
+ if (( *(col-5) == '.' ) && ( *(col-4) == 'o' ) && ( *(col-3) == '.' ) && ( *(col-2) == 'g' ) && ( *(col-1) == 'z' ))
+ ext = 5;
+
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
ext = 2;
@@ -152,6 +155,9 @@
else
deps++;
+ if (( *(end-4) == '.' ) && ( *(end-3) == 'o' ) && ( *(end-2) == '.' ) && ( *(end-1) == 'g' ) && ( *end == 'z' ))
+ ext = 5;
+
if (( *(end-1) == '.' ) && ( *end == 'o' ))
ext = 2;
@@ -184,6 +190,9 @@
int lm = xstrlen ( mod );
int extpos = 0;
+ if (( mod [lm-5] == '.' ) && ( mod [lm-4] == 'o' ) && ( mod [lm-3] == '.' ) && ( mod[lm-2] == 'g' ) && ( mod[lm-1] == 'z' ))
+ extpos = 5;
+
if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
extpos = 2;