wok diff busybox/stuff/busybox-1.12.0-zmodules.u @ rev 1299
Up busybox (1.12.0) with built in module-init-tools
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Aug 21 20:11:27 2008 +0000 (2008-08-21) |
parents | |
children | ce72aad145d4 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/busybox/stuff/busybox-1.12.0-zmodules.u Thu Aug 21 20:11:27 2008 +0000 1.3 @@ -0,0 +1,169 @@ 1.4 +--- busybox-1.12.0/modutils/depmod.c 1.5 ++++ busybox-1.12.0/modutils/depmod.c 1.6 +@@ -53,27 +53,14 @@ static int FAST_FUNC fileAction(const ch 1.7 + size_t len = sb->st_size; 1.8 + void *the_module; 1.9 + char *ptr; 1.10 +- int fd; 1.11 + char *depends, *deps; 1.12 + dep_lst_t *this; 1.13 ++ extern void *xalloc_load_module(const char filename[], size_t *len); 1.14 + 1.15 + if (strrstr(fname, ".ko") == NULL) /* not a module */ 1.16 + goto skip; 1.17 + 1.18 +-/*XXX: FIXME: does not handle compressed modules! 1.19 +- * There should be a function that looks at the extension and sets up 1.20 +- * open_transformer for us. 1.21 +- */ 1.22 +- fd = xopen(fname, O_RDONLY); 1.23 +- the_module = mmap(NULL, len, PROT_READ, MAP_SHARED 1.24 +-#if defined MAP_POPULATE 1.25 +- |MAP_POPULATE 1.26 +-#endif 1.27 +- , fd, 0); 1.28 +- close(fd); 1.29 +- if (the_module == MAP_FAILED) 1.30 +- bb_perror_msg_and_die("mmap"); 1.31 +- 1.32 ++ the_module = xalloc_load_module(fname, &len); 1.33 + this = xzalloc(sizeof(dep_lst_t)); 1.34 + this->name = xstrdup(fname); 1.35 + this->next = G.lst; 1.36 +@@ -104,7 +91,7 @@ static int FAST_FUNC fileAction(const ch 1.37 + pos = (ptr - (char*)the_module); 1.38 + } while (1); 1.39 + } 1.40 +- munmap(the_module, sb->st_size); 1.41 ++ free(the_module); 1.42 + skip: 1.43 + return TRUE; 1.44 + } 1.45 + 1.46 +--- busybox-1.12.0/modutils/insmod.c 1.47 ++++ busybox-1.12.0/modutils/insmod.c 1.48 +@@ -59,6 +59,7 @@ 1.49 + */ 1.50 + 1.51 + #include "libbb.h" 1.52 ++#include "unarchive.h" 1.53 + #include <libgen.h> 1.54 + #include <sys/utsname.h> 1.55 + 1.56 +@@ -4212,6 +4213,45 @@ static const char *moderror(int err) 1.57 + } 1.58 + } 1.59 + 1.60 ++void *xalloc_load_module(const char filename[], size_t *len); 1.61 ++void *xalloc_load_module(const char filename[], size_t *len) 1.62 ++{ 1.63 ++ int fd, max; 1.64 ++ unsigned char head[16]; 1.65 ++ void *map; 1.66 ++ size_t l; 1.67 ++ 1.68 ++ max = 8 * 1024; 1.69 ++ fd = open(filename, O_RDONLY); 1.70 ++ if (fd < 0) return NULL; 1.71 ++ xread(fd,head,sizeof(head)); 1.72 ++ lseek(fd,0L,SEEK_SET); 1.73 ++ if (head[0] == 0x1f && head[1] == 0x8b) { /* gzip */ 1.74 ++ open_transformer(fd, unpack_gz_stream, "gunzip"); 1.75 ++ } 1.76 ++ else if (head[0] == 'B' && head[1] == 'Z' && 1.77 ++ head[2] == 'h' && isdigit(head[3])) { /* bzip2 */ 1.78 ++ open_transformer(fd, unpack_bz2_stream, "bunzip2"); 1.79 ++ } 1.80 ++ else if (head[1] != 'E' || head[2] != 'L' || head[3] != 'F') { 1.81 ++ open_transformer(fd, unpack_lzma_stream, "unlzma"); 1.82 ++ if (* (unsigned *) (head + 9) == 0) 1.83 ++ max = 1 + head[5] + (head[6]<<8) 1.84 ++ + (head[7]<<16) + (head[8]<<24); 1.85 ++ } 1.86 ++ l = 0; 1.87 ++ map = xmalloc(max); 1.88 ++ while (1) { 1.89 ++ l += full_read(fd, l + (char *) map, max - l); 1.90 ++ if (l != max) break; 1.91 ++ max <<= 1; 1.92 ++ map = xrealloc(map, max); 1.93 ++ } 1.94 ++ if (len) 1.95 ++ *len = l; 1.96 ++ return xrealloc(map, l); 1.97 ++} 1.98 ++ 1.99 + #if !ENABLE_FEATURE_2_4_MODULES 1.100 + int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1.101 + int insmod_main(int argc UNUSED_PARAM, char **argv) 1.102 +@@ -4264,8 +4304,7 @@ static int insmod_ng_main(int argc UNUSE 1.103 + xread(fd, map, len); 1.104 + } 1.105 + #else 1.106 +- len = MAXINT(ssize_t); 1.107 +- map = xmalloc_open_read_close(filename, &len); 1.108 ++ map = xalloc_load_module(filename, &len); 1.109 + #endif 1.110 + 1.111 + if (init_module(map, len, options) != 0) 1.112 + 1.113 +--- busybox-1.12.0/modutils/modprobe.c 1.114 ++++ busybox-1.12.0/modutils/modprobe.c 1.115 +@@ -396,6 +396,29 @@ static int include_conf_file2(struct inc 1.116 + return include_conf_file(conf, oldname); 1.117 + } 1.118 + 1.119 ++static int ext_size(char *end USE_FEATURE_2_6_MODULES(, int k_version)) 1.120 ++{ 1.121 ++ int ext; 1.122 ++ char *next; 1.123 ++ 1.124 ++ ext = 0; 1.125 ++ if (end[-2] == '.' && end[-1] == 'g' && end[0] == 'z') 1.126 ++ ext = 3; 1.127 ++ if (end[-3] == '.' && end[-2] == 'b' && end[-1] == 'z' && end[0] == '2') 1.128 ++ ext = 4; 1.129 ++ next = end - ext; 1.130 ++#if ENABLE_FEATURE_2_6_MODULES 1.131 ++ if (ENABLE_FEATURE_2_6_MODULES 1.132 ++ && (k_version > 4) && (next[-2] == '.') 1.133 ++ && (next[-1] == 'k') && (next[0] == 'o')) 1.134 ++ ext += 3; 1.135 ++ else 1.136 ++#endif 1.137 ++ if ((next[-1] == '.') && (next[0] == 'o')) 1.138 ++ ext += 2; 1.139 ++ return ext; 1.140 ++} 1.141 ++ 1.142 + /* 1.143 + * This function builds a list of dependency rules from /lib/modules/`uname -r`/modules.dep. 1.144 + * It then fills every modules and aliases with their default options, found by parsing 1.145 +@@ -464,12 +487,7 @@ static struct dep_t *build_dep(void) 1.146 + if (!modpath) 1.147 + modpath = line_buffer; /* module with no path */ 1.148 + /* find the end of the module name in the file name */ 1.149 +- if (ENABLE_FEATURE_2_6_MODULES && 1.150 +- (k_version > 4) && (col[-3] == '.') && 1.151 +- (col[-2] == 'k') && (col[-1] == 'o')) 1.152 +- dot = col - 3; 1.153 +- else if ((col[-2] == '.') && (col[-1] == 'o')) 1.154 +- dot = col - 2; 1.155 ++ dot = col - ext_size(col - 1 USE_FEATURE_2_6_MODULES(, k_version)); 1.156 + 1.157 + mod = xstrndup(mods, dot - mods); 1.158 + 1.159 +@@ -522,12 +540,7 @@ static struct dep_t *build_dep(void) 1.160 + deps = skip_whitespace(deps); 1.161 + 1.162 + /* find the end of the module name in the file name */ 1.163 +- if (ENABLE_FEATURE_2_6_MODULES 1.164 +- && (k_version > 4) && (next[-2] == '.') 1.165 +- && (next[-1] == 'k') && (next[0] == 'o')) 1.166 +- ext = 3; 1.167 +- else if ((next[-1] == '.') && (next[0] == 'o')) 1.168 +- ext = 2; 1.169 ++ ext = ext_size(next USE_FEATURE_2_6_MODULES(, k_version)); 1.170 + 1.171 + /* Cope with blank lines */ 1.172 + if ((next - deps - ext + 1) <= 0)