From seggers@semyam.dinoco.de  Sun Aug 23 05:42:23 1998
Received: from tim.xenologics.com (tim.xenologics.com [194.77.5.24])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA11486
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Aug 1998 05:42:04 -0700 (PDT)
          (envelope-from seggers@semyam.dinoco.de)
Received: (from uucp@localhost)
	by tim.xenologics.com (8.8.5/8.8.8) with UUCP id OAA21153
	for FreeBSD-gnats-submit@freebsd.org; Sun, 23 Aug 1998 14:36:16 +0200 (MET DST)
Received: (from seggers@localhost)
	by semyam.dinoco.de (8.8.8/8.8.8) id OAA02830;
	Sun, 23 Aug 1998 14:33:46 +0200 (CEST)
	(envelope-from seggers)
Message-Id: <199808231233.OAA02830@semyam.dinoco.de>
Date: Sun, 23 Aug 1998 14:33:46 +0200 (CEST)
From: Stefan Eggers <seggers@semyam.dinoco.de>
Reply-To: seggers@semyam.dinoco.de
To: FreeBSD-gnats-submit@freebsd.org
Cc: seggers@semyam.dinoco.de
Subject: /usr/bin/linux can leave garbage in /tmp
X-Send-Pr-Version: 3.2

>Number:         7725
>Category:       i386
>Synopsis:       /usr/bin/linux can leave garbage in /tmp
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 23 05:50:00 PDT 1998
>Closed-Date:    Mon Sep 7 18:16:46 MEST 1998
>Last-Modified:  Mon Sep  7 18:17:55 MEST 1998
>Originator:     Stefan Eggers
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
none
>Environment:

	-current from two or three weeks ago, verified with sources
CVSUp'ed yesterday.

>Description:

	/usr/bin/linux doesn't test if the linux LKM is already
loaded or not.  It just blindly calls modload to do the work.

	Now the problem is that modload leaves behind the module in
/tmp when the linux LKM is already loaded.  This can happen after
going single user and then back to multi user.

>How-To-Repeat:

	Make sure linux emulation is enabled in /etc/rc.conf and the
linux LKM is loadded.  Go single user, at the password prompt just
press CTRL-D and after being back in multi user look at the contents
of /tmp.

>Fix:

	I just took the test from /etc/rc.i386 which tests for an
already loaded screen blanker and changed it to work for the linux
LKM.  This code I added to /usr/bin/linux.

	Another way to reach the same goal is to modfiy modload to
also delete the temporary module (if the command line flags say to
delete it) even in case of an error.  Then trying to load an already
loaded module would be a NOP with a non-zero exit status.

Index: linux
===================================================================
RCS file: /usr2/FreeBSD/CVSROOT/src/lkm/linux/linux,v
retrieving revision 1.4
diff -u -r1.4 linux
--- linux	1997/02/22 12:48:25	1.4
+++ linux	1998/08/23 12:06:12
@@ -1,3 +1,4 @@
 #!/bin/sh
 # $Id: linux,v 1.4 1997/02/22 12:48:25 peter Exp $
-modload -e linux_mod -u -q -o /tmp/linux_mod /lkm/linux_mod.o
+modstat | grep linux_mod >/dev/null || \
+   modload -e linux_mod -u -q -o /tmp/linux_mod /lkm/linux_mod.o
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: cracauer 
State-Changed-When: Mon Sep 7 18:16:46 MEST 1998 
State-Changed-Why:  
Fixed in -current, will commit to -stable after test period. 

Load linux emulator lkm only when not already loaded. This avoids 
leftover files in /tmp. Script slightly modified from PR version 
to use fewer processes. 

Thanks! 
>Unformatted:
