Skip to contentSkip to conversation

module-init-tools don't support gzipped modules.

DISCUSSION Gerardo Exequiel Pozzi 8 participants 14 messages Jul 30, 2003 – Aug 1, 2003 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi gurus,

The suite module-init-tools don´t support gzipped modules such as modutils suite.
This not appears in the TODO list.

The possibility of compressing the modules is interesting, like for example in cases of construction of small systems or initrd.

That you think about this?

Signature · 4 lines
Gerardo Exequiel Pozzi ( djgera )
http://www.vmlinuz.com.ar http://www.djgera.com.ar
KeyID: 0x1B8C330D
Key fingerprint = 0CAA D5D4 CD85 4434 A219  76ED 39AB 221B 1B8C 330D
#1 lore raw
Quoted 4 lines · Gerardo Exequiel Pozzi

The possibility of compressing the modules is interesting, like for example in cases of construction of small systems or initrd.

In both cases, you might use a compressed file system. Maybe you better try to save memory and disk space by compressing less critical stuff than kernel modules.

Regards,

Bas.

#2 lore raw
Quoted 8 lines

[[email protected]]

Quoted 2 lines

The possibility of compressing the modules is interesting, like for example in cases of construction of small systems or initrd.

In both cases, you might use a compressed file system. Maybe you better try to save memory and disk space by compressing less critical stuff than kernel modules.

It's a valid feature request nonetheless.

Signature · 1 line
Tomas Szepe <[email protected]>
#3 lore raw

In message <[email protected]> you write:

Quoted 10 lines
Quoted 8 lines

[[email protected]]

Quoted 2 lines

The possibility of compressing the modules is interesting, like for example in cases of construction of small systems or initrd.

In both cases, you might use a compressed file system. Maybe you better try to save memory and disk space by compressing less critical stuff than kernel modules.

It's a valid feature request nonetheless.

I agree, but I believe almost anything is a valid feature request.

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

It's fairly trivial patch, which probably is best as an add-on (which I think RH do?

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#4 lore raw
Quoted 7 lines · Rusty Russell

I agree, but I believe almost anything is a valid feature request.

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

It's fairly trivial patch, which probably is best as an add-on (which I think RH do?

No, we don't add on gzipped module support for module-init-tools.

Bill

#5 lore raw
In reply to Rusty Russell
Quoted 2 lines · Rusty Russell

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Really? modutils 2.4: ./configure --enable-zlib

#6 lore raw
Quoted 8 lines

[[email protected]]

Quoted 2 lines · Rusty Russell

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Really? modutils 2.4: ./configure --enable-zlib

Keith, I believe Rusty meant the standard Debian package had binaries compiled w/o '--enable-zlib'.

(And so has Slackware btw.)

Signature · 1 line
Tomas Szepe <[email protected]>
#7 lore raw
Quoted 7 lines · Tomas Szepe
Quoted 7 lines

[[email protected]]

Quoted 2 lines · Rusty Russell

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Quoted 6 lines
Quoted 1 line

Really? modutils 2.4: ./configure --enable-zlib

Keith, I believe Rusty meant the standard Debian package had binaries compiled w/o '--enable-zlib'.

(And so has Slackware btw.)

Slackware since 8.0 uses compression for the kernel modules by
default and uses --enable-zlib for modutils.
See:
ftp://ftp.slackware.com/pub/slackware/slackware-9.0/source/a/modutils/modutils.SlackBuild

pkot

Signature · 2 lines
mailto:[email protected] :: mailto:[email protected]
http://kt.linuxnews.pl/ :: Kernel Traffic po polsku
#8 lore raw
Quoted 11 lines

[[email protected]]

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines · Rusty Russell

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Really? modutils 2.4: ./configure --enable-zlib

Keith, I believe Rusty meant the standard Debian package had binaries compiled w/o '--enable-zlib'.

Quoted 6 lines
Quoted 1 line

(And so has Slackware btw.)

Slackware since 8.0 uses compression for the kernel modules by
default and uses --enable-zlib for modutils.
See:
ftp://ftp.slackware.com/pub/slackware/slackware-9.0/source/a/modutils/modutils.SlackBuild

Hmmm, things change. :)
Thanks for correcting me.

Signature · 1 line
Tomas Szepe <[email protected]>
#9 lore raw
In reply to Pawel Kot
Quoted 14 lines · Pawel Kot
Quoted 5 lines · Tomas Szepe
Quoted 5 lines

[[email protected]]

Quoted 1 line · Rusty Russell

I don't want to require zlib, though. The modutils I have

(Debian)> > >doesn't support it, either.

Quoted 6 lines
Quoted 2 lines

Really? modutils 2.4: ./configure --enable-zlib

Keith, I believe Rusty meant the standard Debian package had binaries compiled w/o '--enable-zlib'.

Quoted 7 lines
Quoted 1 line

(And so has Slackware btw.)

Slackware since 8.0 uses compression for the kernel modules by default and uses --enable-zlib for modutils.
See:
ftp://ftp.slackware.com/pub/slackware/slackware-9.0/source/a/modutils/ modutils.SlackBuild

yes, originally I wrote the mail, commenting on the necessity of gzip, because of mails that interchanges with Patrick Volkerding about the inclusion of 2.6.

Signature · 4 lines
Gerardo Exequiel Pozzi ( djgera )
http://www.vmlinuz.com.ar http://www.djgera.com.ar
KeyID: 0x1B8C330D
Key fingerprint = 0CAA D5D4 CD85 4434 A219  76ED 39AB 221B 1B8C 330D
#10 lore raw
In reply to Keith Owens
Quoted 6 lines · Keith Owens
Quoted 2 lines · Rusty Russell

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Really? modutils 2.4: ./configure --enable-zlib

Ok, here is a patch against module-init-tools-0.9.13-pre that I ported from modutils. I haven't tested it yet since I don't have any 2.6 kernel right here. But at least it compiles with and without zlib.

After applying the patch, you'll have to run aclocal, automake and autoconf as specified in the README.

There's one thing I'm not sure about. There were mmap() calls which I replaced with malloc()+read(). I don't know if the syscall supports such a way to load modules. Volunteers will have to try it :-)

Cheers,
Willy

Makefile.am +6 -5
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/Makefile.am module-init-tools-0.9.13-pre-gz/Makefile.am
@@ -1,12 +1,13 @@
-insmod_SOURCES = insmod.c testing.h
+insmod_SOURCES = insmod.c gzfiles.c testing.h
 lsmod_SOURCES = lsmod.c testing.h
-modprobe_SOURCES = modprobe.c testing.h
+modprobe_SOURCES = modprobe.c gzfiles.c testing.h
 rmmod_SOURCES = rmmod.c testing.h
-depmod_SOURCES = depmod.c moduleops.c tables.c depmod.h moduleops.h tables.h list.h testing.h
-modinfo_SOURCES = modinfo.c testing.h 
+depmod_SOURCES = depmod.c gzfiles.c moduleops.c tables.c depmod.h moduleops.h tables.h list.h testing.h
+modinfo_SOURCES = modinfo.c gzfiles.c testing.h 
 
-insmod_static_SOURCES = insmod.c
+insmod_static_SOURCES = insmod.c gzfiles.c
 insmod_static_LDFLAGS = -static
+insmod_static_LDADD = $(LDADD) $(stat_zlib_flags)
 
 EXTRA_insmod_SOURCES = backwards_compat.c
 EXTRA_lsmod_SOURCES = backwards_compat.c
configure.in +16 -0
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/configure.in module-init-tools-0.9.13-pre-gz/configure.in
@@ -4,7 +4,23 @@
 
 AM_INIT_AUTOMAKE(module-init-tools,"0.9.13-pre")
 
+# If zlib is required, libz must be linked static, insmod is in /sbin, libz is
+# in /usr/lib and may not be available when insmod is run.
+AC_ARG_ENABLE(zlib,
+[  --disable-zlib               Do not handle gzipped objects (default)],
+[if test "$enableval" = "yes"; then
+  AC_DEFINE(CONFIG_USE_ZLIB)
+  zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
+  stat_zlib_flags="-Wl,-Bstatic"
+fi])
+
 AC_PROG_CC
+
+# Delay adding the zlib_flags until after AC_PROG_CC, so we can distinguish
+# between a broken cc and a working cc but missing libz.a.
+LDADD="$LDADD $zlib_flags"
+AC_SUBST(LDADD)
+AC_SUBST(stat_zlib_flags)
 
 case $target in
 *-*-linux*) ;;
depmod.c +8 -0
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/depmod.c module-init-tools-0.9.13-pre-gz/depmod.c
@@ -23,6 +23,7 @@
 #include "tables.h"
 
 #include "testing.h"
+#include "gzfiles.h"
 
 /* I hate strcmp. */
 #define streq(a,b) (strcmp((a),(b)) == 0)
@@ -291,8 +292,15 @@
 		     new->pathname, strerror(errno));
 		goto fail;
 	}
+#ifndef CONFIG_USE_ZLIB
 	fstat(fd, &buf);
 	new->mmap = mmap(0, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+#else
+	bzero(&buf, sizeof(buf));
+	new->mmap = gzf_load(fd, &buf.st_size);
+	if (new->mmap == NULL)
+	    new->mmap = MAP_FAILED;
+#endif
 	if (new->mmap == MAP_FAILED) {
 		warn("Can't map module %s: %s\n",
 		     new->pathname, strerror(errno));
gzfiles.c +124 -0

124 lines not on this page · raw message

gzfiles.h +22 -0
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/gzfiles.h module-init-tools-0.9.13-pre-gz/gzfiles.h
@@ -0,0 +1,22 @@
+#ifndef GZFILES_H
+#define GZFILES_H
+
+#ifdef CONFIG_USE_ZLIB
+extern int gzf_open(const char *name, int mode);
+extern int gzf_read(int fd, void *buf, size_t count);
+extern off_t gzf_lseek(int fd, off_t offset, int whence);
+extern void gzf_close(int fd);
+extern void *gzf_load(int fd, off_t *size);
+
+#else /* ! CONFIG_USE_ZLIB */
+
+#include <unistd.h>
+
+#define gzf_open        open
+#define gzf_read        read
+#define gzf_lseek       lseek
+#define gzf_close       close
+
+#endif /* CONFIG_USE_ZLIB */
+
+#endif /* GZFILES_H */
insmod.c +8 -0
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/insmod.c module-init-tools-0.9.13-pre-gz/insmod.c
@@ -29,6 +29,7 @@
 #include <asm/unistd.h>
 
 #include "backwards_compat.c"
+#include "gzfiles.h"
 
 static void print_usage(const char *progname)
 {
@@ -99,9 +100,16 @@
 		exit(1);
 	}
 
+#ifndef CONFIG_USE_ZLIB
 	fstat(fd, &st);
 	len = st.st_size;
 	map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
+#else
+	bzero(&st, sizeof(st));
+	map = gzf_load(fd, &st.st_size);
+	if (map == NULL)
+	    map = MAP_FAILED;
+#endif
 	if (map == MAP_FAILED) {
 		fprintf(stderr, "Can't map '%s': %s\n",
 			filename, strerror(errno));
modinfo.c +8 -0
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/modinfo.c module-init-tools-0.9.13-pre-gz/modinfo.c
@@ -13,6 +13,7 @@
 #include <sys/utsname.h>
 #include <sys/mman.h>
 #include "backwards_compat.c"
+#include "gzfiles.h"
 
 #define streq(a,b) (strcmp((a),(b)) == 0)
 
@@ -219,9 +220,16 @@
 		}
 	}
 
+#ifndef CONFIG_USE_ZLIB
 	fstat(fd, &st);
 	*size = st.st_size;
 	map = mmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
+#else
+	bzero(&st, sizeof(st));
+	map = gzf_load(fd, size);
+	if (map == NULL)
+	    map = MAP_FAILED;
+#endif
 	if (map == MAP_FAILED) {
 		fprintf(stderr, "Could not find module %s\n", name);
 		close(fd);
modprobe.c +6 -0
diff -urN --exclude aclocal.m4 --exclude Makefile.in --exclude configure module-init-tools-0.9.13-pre/modprobe.c module-init-tools-0.9.13-pre-gz/modprobe.c
@@ -41,6 +41,7 @@
 
 #include "list.h"
 #include "backwards_compat.c"
+#include "gzfiles.h"
 
 struct module {
 	struct list_head list;
@@ -729,8 +730,13 @@
 		goto out_optstring;
 	}
 
+#ifndef CONFIG_USE_ZLIB
 	fstat(fd, &st);
 	map = read_in(fd, st.st_size);
+#else
+	bzero(&st, sizeof(st));
+	map = gzf_load(fd, &st.st_size);
+#endif
 	if (!map) {
 		if (dont_fail)
 			fatal("Can't read '%s': %s\n",
#11 lore raw

In message <[email protected]> you write:

Quoted 11 lines · Keith Owens
Quoted 6 lines
Quoted 2 lines · Rusty Russell

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Really? modutils 2.4: ./configure --enable-zlib

Ok, here is a patch against module-init-tools-0.9.13-pre that I ported from modutils. I haven't tested it yet since I don't have any 2.6 kernel right here. But at least it compiles with and without zlib.

OK, I'll work from this patch: I'll probably pull out a separate "snarf file" function and use that for all these cases, to ensure there's only one #ifdef though.

Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#12 lore raw
Quoted 13 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 4 lines · Keith Owens
Quoted 3 lines
Quoted 1 line · Rusty Russell

I don't want to require zlib, though. The modutils I have

(Debian)> > >doesn't support it, either.

Quoted 4 lines
Quoted 2 lines

Really? modutils 2.4: ./configure --enable-zlib

Ok, here is a patch against module-init-tools-0.9.13-pre that I

ported from> modutils. I haven't tested it yet since I don't have any 2.6 kernel right here.> But at least it compiles with and without zlib.

Quoted 7 lines

OK, I'll work from this patch: I'll probably pull out a separate "snarf file" function and use that for all these cases, to ensure there's only one #ifdef though.

Thanks!
Rusty.
--

Greetings, and thanks a lot for your attention!.

chau, djgera

Signature · 4 lines
Gerardo Exequiel Pozzi ( djgera )
http://www.vmlinuz.com.ar http://www.djgera.com.ar
KeyID: 0x1B8C330D
Key fingerprint = 0CAA D5D4 CD85 4434 A219  76ED 39AB 221B 1B8C 330D
#13 lore raw
In reply to Rusty Russell
Quoted 2 lines

I don't want to require zlib, though. The modutils I have (Debian) doesn't support it, either.

Well, if you decide to implement zlib support, let's have it optional just like it is in modutils.

Signature · 1 line
Tomas Szepe <[email protected]>