It may sound strange, but there are still Linux kernel 2.4.x out and up and running. Tools to manage (list, load, unload kernel modules) belong usually to a package called modutils. Modutils support dealing with gzip compressed images and therefore depend on zlib.
Unfortunately original implementation of modutils did use internal data structures of zlib to access compressed data. At least changes made by zlib version 1.2.5 break modutils and make insmod fail with SIGSEGV even on uncompressed modules.
All code dealing with compressed modules is bundled in a wrapper found in modutil source file util/gzfiles.c. This code needs to be patched.
Following patch removes dependency on zlib internal data structures and makes modutils work together with current zlib releases.
A unified diff patch follows:
--- modutils-2.4.21-orig/util/gzfiles.c 2001-01-05 02:45:19.000000000 +0100
+++ modutils-2.4.21/util/gzfiles.c 2011-01-03 12:10:18.000000000 +0100
@@ -13,22 +13,6 @@
#include <fcntl.h>
#include <unistd.h>
-/* redefinition of gz_stream which isn't exported by zlib */
-typedef struct gz_stream {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- FILE *file; /* .gz file */
- Byte *inbuf; /* input buffer */
- Byte *outbuf; /* output buffer */
- uLong crc; /* crc32 of uncompressed data */
- char *msg; /* error message */
- char *path; /* path name for debugging only */
- int transparent; /* 1 if input file is not a .gz file */
- char mode; /* 'w' or 'r' */
- long startpos; /* start of compressed data in file (header skipped) */
-} gz_stream;
-
/* maximum number of simultaneous open files, also greater file descriptor number */
#define MAXFD 64
@@ -40,14 +24,11 @@
int fd;
gzFile g;
- if ((g=gzopen(name, "rb")) != NULL) {
- fd=fileno(((gz_stream*)g)->file);
- gzf_fds[fd]=g;
- }
- else if ((fd=open(name, mode)) != -1) {
- gzf_fds[fd]=NULL; /* NULL means not GZ mode */
- }
- return fd;
+ if ((fd=open(name, mode)) != -1) {
+ g=gzdopen(fd, "rb");
+ gzf_fds[fd]=g; /* NULL means not GZ mode */
+ }
+ return fd;
}
off_t gzf_lseek(int fd, off_t offset, int whence) {
Keine Kommentare:
Kommentar veröffentlichen