Skip to contentSkip to conversation

modules_install must not remove existing modules

PATCH Applied Andreas Gruenbacher 5 participants 10 messages Apr 5, 2006 – Apr 6, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modules_install must not remove existing modules

When installing external modules with `make modules_install', the first thing that happens is a rm -rf of the target directory. This works only once, and breaks when installing more than one (set of) external module(s). Bug introduced in:
http://www.kernel.org/hg/linux-2.6/?cs=bbb3915836f5

Sam, is this fix okay with you?

Makefile +0 -1
Index: linux-2.6.16/Makefile
===================================================================
@@ -1131,7 +1131,6 @@ modules_install: _emodinst_ _emodinst_po
 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)	
 .PHONY: _emodinst_
 _emodinst_:
-	$(Q)rm -rf $(MODLIB)/$(install-dir)
 	$(Q)mkdir -p $(MODLIB)/$(install-dir)
 	$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
 
Signature · 2 lines
Andreas Gruenbacher <[email protected]>
Novell / SUSE Labs
#1 lore raw
Quoted 4 lines · Andreas Gruenbacher

When installing external modules with `make modules_install', the first thing that happens is a rm -rf of the target directory. This works only once, and breaks when installing more than one (set of) external module(s).

Can this be re-worked to ensure that it clears the target directory the *first* time? It would suck mightily if a previous build of 2.6.17-rc2 left a net_foo.ko lying around to get insmod'ed by accident (consider the case of CONFIG_NETFOO=m getting changed to y or n, and other possible horkage. Module versioning will catch some, but not all, of this crap....)

#2 lore raw
Quoted 5 lines · On Wednesday 05 April 2006 23:52, [email protected] wrote:

Can this be re-worked to ensure that it clears the target directory the *first* time? It would suck mightily if a previous build of 2.6.17-rc2 left a net_foo.ko lying around to get insmod'ed by accident (consider the case of CONFIG_NETFOO=m getting changed to y or n, and other possible horkage. Module versioning will catch some, but not all, of this crap....)

We could wipe away everything in the non-external modules_install case (not only everything below kernel/ as is done now). The problem here is that different external modules_install calls into the same dir conflict.

Andreas

#3 lore raw
In reply to [email protected]
Quoted 6 lines · On Wednesday 05 April 2006 17:52, [email protected] wrote:
Quoted 4 lines · Andreas Gruenbacher

When installing external modules with `make modules_install', the first thing that happens is a rm -rf of the target directory. This works only once, and breaks when installing more than one (set of) external module(s).

Quoted 6 lines

Can this be re-worked to ensure that it clears the target directory the *first* time? It would suck mightily if a previous build of 2.6.17-rc2 left a net_foo.ko lying around to get insmod'ed by accident (consider the case of CONFIG_NETFOO=m getting changed to y or n, and other possible horkage. Module versioning will catch some, but not all, of this crap....)

I avoid this in my own makeit script by mv'ing all that stuff to a /lib/modules/version_number.old, ditto for vmlinuz and initrd. That way, if the new one doesn't work, I can choose some other kernel in the grub startup, boot it it, then just mv the stuff back, and voila! Another reboot and I'm back on the last kernel that worked.

Signature · 7 lines
Cheers, Gene
People having trouble with vz bouncing email to me should add the word
'online' between the 'verizon', and the dot which bypasses vz's
stupid bounce rules.  I do use spamassassin too. :-)
Yahoo.com and AOL/TW attorneys please note, additions to the above
message by Gene Heskett are:
Copyright 2006 by Maurice Eugene Heskett, all rights reserved.
#4 lore raw
In reply to Andreas Gruenbacher
Quoted 7 lines · Andreas Gruenbacher

When installing external modules with `make modules_install', the first thing that happens is a rm -rf of the target directory. This works only once, and breaks when installing more than one (set of) external module(s). Bug introduced in:
http://www.kernel.org/hg/linux-2.6/?cs=bbb3915836f5

Sam, is this fix okay with you?

The removal was introduced to get rid of old modules from an earlier build of the same kernel with potential more modules.
I was obvious when I played with an allmodconfig kernel IIRC.

The usecase you have in mind is with external modules only? We could special case in that suation and avoid the removal.

I see no way to detect when it is OK to remove or not, so in the principle of least suprise I prefer having the removal unconditional for normal kernel builds, and no removal for external modules.

OK?

Sam

Quoted 18 lines

Index: linux-2.6.16/Makefile
===================================================================

Makefile +0 -1
@@ -1131,7 +1131,6 @@ modules_install: _emodinst_ _emodinst_po
 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)	
 .PHONY: _emodinst_
 _emodinst_:
-	$(Q)rm -rf $(MODLIB)/$(install-dir)
 	$(Q)mkdir -p $(MODLIB)/$(install-dir)
 	$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
 
Signature · 2 lines
Andreas Gruenbacher <[email protected]>
Novell / SUSE Labs
#5 lore raw
Quoted 3 lines · Sam Ravnborg

The removal was introduced to get rid of old modules from an earlier build of the same kernel with potential more modules.
I was obvious when I played with an allmodconfig kernel IIRC.

The in-tree modules all install below kernel/, so I don't see why removing the external modules directory (extra or whatever) is necessary for that. It might still be that there are other external modules
below /lib/modules/$KERNELRELEASE, though.

Quoted 1 line

The usecase you have in mind is with external modules only?

Yes, with more than one set of them, each of which using modules_install.

Quoted 7 lines

We could special case in that suation and avoid the removal.

I see no way to detect when it is OK to remove or not, so in the principle of least suprise I prefer having the removal unconditional for normal kernel builds, and no removal for external modules.

OK?

That would be okay for me, yes.

Thanks,
Andreas

#6 lore raw
In reply to Sam Ravnborg
Quoted 3 lines · Sam Ravnborg

I see no way to detect when it is OK to remove or not, so in the principle of least suprise I prefer having the removal unconditional for normal kernel builds, and no removal for external modules.

That sounds workable to me.

#8 lore raw
Quoted 10 lines · On Thu, 6 Apr 2006 08:43:10 +0200 Sam Ravnborg wrote:
Quoted 7 lines · Andreas Gruenbacher

When installing external modules with `make modules_install', the first thing that happens is a rm -rf of the target directory. This works only once, and breaks when installing more than one (set of) external module(s). Bug introduced in:
http://www.kernel.org/hg/linux-2.6/?cs=bbb3915836f5

Sam, is this fix okay with you?

Applied.
We should document this somewhere...

Sam, did you apply the original patch from Andreas or some updated one?

---
~Randy

#9 lore raw
Quoted 9 lines · Randy.Dunlap
Quoted 7 lines · On Thu, 6 Apr 2006 08:43:10 +0200 Sam Ravnborg wrote:
Quoted 6 lines · Andreas Gruenbacher

When installing external modules with `make modules_install', the first thing that happens is a rm -rf of the target directory. This works only once, and breaks when installing more than one (set of) external module(s). Bug introduced in:
http://www.kernel.org/hg/linux-2.6/?cs=bbb3915836f5

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Sam, is this fix okay with you?

Applied.
We should document this somewhere...

Sam, did you apply the original patch from Andreas or some updated one?

The original patch from Andreas.

It is not yet pushed - I need to sort out a few klibc related bits first.

Sam