]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/busybox-0.60.5-gzip.patch
Wir kehren zurueck zu Kudzu, da hwinfo noch mehr Aerger macht.
[people/teissler/ipfire-2.x.git] / src / patches / busybox-0.60.5-gzip.patch
CommitLineData
cd1a2927
MT
1--- busybox-0.60.5/insmod.c 2002-09-16 06:30:10.000000000 +0100
2+++ busybox-0.60.5.gz/insmod.c 2003-12-29 17:43:56.000000000 +0000
3@@ -3429,6 +3429,12 @@
4 close(fd);
5 }
6
7+void delete_unziped_module(char *name)
8+{
9+ if (unlink(name) < 0)
10+ fprintf(stderr, "Couldnt remove %s", name);
11+}
12+
13 extern int insmod_main( int argc, char **argv)
14 {
15 int opt;
16@@ -3444,6 +3450,7 @@
17 char m_name[FILENAME_MAX] = "\0";
18 int exit_status = EXIT_FAILURE;
19 int m_has_modinfo;
20+ int gunzip = 0;
21 #ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
22 struct utsname uts_info;
23 char m_strversion[STRVERSIONLEN];
24@@ -3498,9 +3505,18 @@
25 tmp = basename(tmp1);
26 len = strlen(tmp);
27
28- if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
29- len-=2;
30+ if (len > 5 && tmp[len - 5] == '.' && tmp[len - 4] == 'o' && tmp[len - 3] == '.' && tmp[len - 2] == 'g' && tmp[len - 1] == 'z') {
31+ len-=5;
32 tmp[len] = '\0';
33+ gunzip = 1;
34+ }
35+ else
36+ {
37+ if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
38+ len-=2;
39+ tmp[len] = '\0';
40+ gunzip = 0;
41+ }
42 }
43 /* Make sure there is space for the terminal NULL */
44 len += 1;
45@@ -3524,6 +3540,7 @@
46 (fp = fopen(argv[optind], "r")) == NULL) {
47 struct utsname myuname;
48
49+AGAIN:
50 /* Hmm. Could not open it. First search under /lib/modules/`uname -r`,
51 * but do not error out yet if we fail to find it... */
52 if (uname(&myuname) == 0) {
53@@ -3542,6 +3559,14 @@
54 check_module_name_match, 0, m_fullName);
55 }
56
57+ /* If we've not found anything, try the gzipped version */
58+ if ((m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL)) && !gunzip)
59+ {
60+ strcat(m_fullName, ".gz");
61+ gunzip = 1;
62+ goto AGAIN;
63+ }
64+
65 /* Check if we have found anything yet */
66 if (m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL))
67 {
68@@ -3565,11 +3590,52 @@
69 } else
70 safe_strncpy(m_filename, argv[optind], sizeof(m_filename));
71
72+ if (gunzip)
73+ {
74+ FILE *fp_unziped;
75+ int my_len;
76+ char m_filename_unziped[FILENAME_MAX + 1] = "\0";
77+
78+ strcpy(m_filename_unziped, m_filename);
79+ my_len = strlen(m_filename_unziped);
80+ m_filename_unziped[my_len - 3] = '\0';
81+
82+ if ((fp_unziped = fopen (m_filename_unziped, "w")) == NULL)
83+ {
84+ perror(m_filename_unziped);
85+ return EXIT_FAILURE;
86+ }
87+
88+ if (unzip(fp, fp_unziped) != 0)
89+ {
90+ fclose(fp);
91+ fclose(fp_unziped);
92+ error_msg("unable to gunzip %s", m_filename_unziped);
93+ delete_unziped_module(m_filename_unziped);
94+ return EXIT_FAILURE;
95+ }
96+
97+ fclose(fp);
98+ fclose(fp_unziped);
99+
100+ strcpy(m_filename, m_filename_unziped);
101+
102+ if ((fp = fopen (m_filename, "r")) == NULL)
103+ {
104+ perror(m_filename);
105+ return EXIT_FAILURE;
106+ }
107+ }
108+
109 printf("Using %s\n", m_filename);
110
111 if ((f = obj_load(fp, LOADBITS)) == NULL)
112- perror_msg_and_die("Could not load the module");
113-
114+ {
115+ if (gunzip)
116+ delete_unziped_module(m_filename);
117+ perror_msg_and_die("Could not load the module");
118+ }
119+
120 if (get_modinfo_value(f, "kernel_version") == NULL)
121 m_has_modinfo = 0;
122 else
123@@ -3679,8 +3745,6 @@
124
125 /* Find current size of the module */
126 m_size = obj_load_size(f);
127-
128-
129 m_addr = create_module(m_name, m_size);
130 if (m_addr==-1) switch (errno) {
131 case EEXIST:
132@@ -3723,5 +3787,7 @@
133
134 out:
135 fclose(fp);
136+ if (gunzip)
137+ delete_unziped_module(m_filename);
138 return(exit_status);
139 }
140--- busybox-0.60.5/modprobe.c 2003-12-29 17:05:50.000000000 +0000
141+++ busybox-0.60.5.gz/modprobe.c 2004-01-01 19:22:44.000000000 +0000
142@@ -105,6 +105,9 @@
143 else
144 mods++;
145
146+ if (( *(col-5) == '.' ) && ( *(col-4) == 'o' ) && ( *(col-3) == '.' ) && ( *(col-2) == 'g' ) && ( *(col-1) == 'z' ))
147+ ext = 5;
148+
149 if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
150 ext = 2;
151
152@@ -152,6 +155,9 @@
153 else
154 deps++;
155
156+ if (( *(end-4) == '.' ) && ( *(end-3) == 'o' ) && ( *(end-2) == '.' ) && ( *(end-1) == 'g' ) && ( *end == 'z' ))
157+ ext = 5;
158+
159 if (( *(end-1) == '.' ) && ( *end == 'o' ))
160 ext = 2;
161
162@@ -184,6 +190,9 @@
163 int lm = xstrlen ( mod );
164 int extpos = 0;
165
166+ if (( mod [lm-5] == '.' ) && ( mod [lm-4] == 'o' ) && ( mod [lm-3] == '.' ) && ( mod[lm-2] == 'g' ) && ( mod[lm-1] == 'z' ))
167+ extpos = 5;
168+
169 if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
170 extpos = 2;
171