Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Mar 1997 16:42:43 +0100
From:      j@ida.interface-business.de (J Wunsch)
To:        adrian@obiwan.aceonline.com.au (Adrian Chadd)
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Re : java support under FreeBSD - test code.
Message-ID:  <Mutt.19970303164243.j@ida.>
In-Reply-To: <Pine.BSF.3.95q.970303062707.219A-100000@obiwan.aceonline.com.au>; from Adrian Chadd on Mar 3, 1997 06:42:04 %2B0800
References:  <Pine.BSF.3.95q.970303062707.219A-100000@obiwan.aceonline.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
As Adrian Chadd wrote:

> OK guys - here is the magic file.

Great!

> Stick it under /usr/src/sys/kern/imgact_java.c, and do these two steps :

Hmm, i've been too lazy to reboot my machine just for this.  Hence i
cloned Søren's ibcs2 coff LKM stuff, and made it an LKM wrapper for
imgact_java.c.  What should i say?  It works.  The LKM wrapper is
below.

Also, i needed the following diffs.  The basic problem is that
/usr/local/jdk/bin/java itself is a shell script, and stacking image
activators (first imgact_java, then imgact_shell, then imgact_aout) is
not possible.  Hence one must use the path to the a.out binary itself.

Also, i believe the /usr/local/jdk directory is where the FreeBSD port
drops it.

Btw., the first printf is blatant; it causes any shell script that's
not caught by an image activator to launch a complaint on the console.

Apart from this: good stuff!  Now if only javac would set the x bit... :)

p.s.: Please put your favorite copyright above.  We are not allowed to
redistribute it otherwise.

--- /tmp/imgact_java.c	Mon Mar  3 12:46:32 1997
+++ /sys/kern/imgact_java.c	Mon Mar  3 16:35:32 1997
@@ -18,9 +18,10 @@
 */
 
 
-static char interpreter[256] = "/usr/local/java/bin/java";
-static char appletviewer[256] = "/usr/local/java/bin/appletviewer";
-static char classpath[256] = "/usr/local/java/classes.zip";
+static char interpreter[256] = "/usr/local/jdk/bin/i386/java";
+static char appletviewer[256] = "/usr/local/jdk/bin/i386/appletviewer";
+static char classpath[256] =
+	"/usr/local/jdk/classes:/usr/local/jdk/lib/classes.zip";
 
 SYSCTL_NODE(_kern, OID_AUTO, java, CTLFLAG_RW, 0, "Kernel Java support");
 
@@ -245,7 +246,9 @@
 
 	if ((image_header[0] != '\xca') || (image_header[1] != '\xfe') ||
 	  (image_header[2] != '\xba') || (image_header[3] != '\xbe')) {
+#ifdef DEBUG
 		printf("Failed to run a java binary : invalid signature?\n");
+#endif
 		return(-1);
 	}
 
@@ -302,7 +305,9 @@
 	
 	strcpy(imgp->uap->fname, javabin_name);
 	suword(imgp->uap->argv, (int)imgp->uap->fname);
+#ifdef DEBUG
 	printf("fname : %s\n", imgp->uap->fname);
+#endif
 
 	return (0);
 
@@ -313,9 +318,6 @@
  * Since `const' objects end up in the text segment, TEXT_SET is the
  * correct directive to use. 
  */      
-static const struct execsw java_execsw = { exec_java_imgact, "\xca\xfe\xba\xbe" };
+const struct execsw java_execsw = { exec_java_imgact, "\xca\xfe\xba\xbe" };
 TEXT_SET(execsw_set, java_execsw);
-
-
-
 


The `static' in the linker set needs to be removed for the LKM to link
properly.

The LKM doesn't install the sysctl hooks.  Anybody around with an idea
to do this?

Finally, here's the LKM stuff:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	/usr/src/lkm/java/
#	/usr/src/lkm/java/java.c
#	/usr/src/lkm/java/Makefile
#
echo c - /usr/src/lkm/java/
mkdir -p /usr/src/lkm/java/ > /dev/null 2>&1
echo x - /usr/src/lkm/java/java.c
sed 's/^X//' >/usr/src/lkm/java/java.c << 'END-of-/usr/src/lkm/java/java.c'
X/*-
X * Copyright (c) 1997 Jörg Wunsch
X * Copyright (c) 1994 Søren Schmidt
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer
X *    in this position and unchanged.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. The name of the author may not be used to endorse or promote products
X *    derived from this software withough specific prior written permission
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X *
X *	$Id$
X */
X
X#include <sys/param.h>
X#include <sys/systm.h>
X#include <sys/exec.h>
X#include <sys/conf.h>
X#include <sys/sysent.h>
X#include <sys/lkm.h>
X#include <sys/errno.h>
X
Xextern const struct execsw java_execsw;
X
XMOD_EXEC(java, -1, &java_execsw);
X
Xstatic int
Xjava_load(struct lkm_table *lkmtp, int cmd)
X{
X	uprintf("java loader installed\n");
X	return 0;
X}
X
Xstatic int
Xjava_unload(struct lkm_table *lkmtp, int cmd)
X{
X	uprintf("java loader removed\n");
X	return 0;
X}
X
Xint
Xjava_mod(struct lkm_table *lkmtp, int cmd, int ver)
X{
X	DISPATCH(lkmtp, cmd, ver, java_load, java_unload,
X		 lkm_nullcmd);
X}
END-of-/usr/src/lkm/java/java.c
echo x - /usr/src/lkm/java/Makefile
sed 's/^X//' >/usr/src/lkm/java/Makefile << 'END-of-/usr/src/lkm/java/Makefile'
X# $Id$
X
X.PATH:	${.CURDIR}/../../sys/kern
XKMOD=	java_mod
XSRCS= 	java.c imgact_java.c vnode_if.h
XNOMAN=
XCLEANFILES+= vnode_if.h vnode_if.c
XCFLAGS+= -DLKM -I.
X
X.include <bsd.kmod.mk>
END-of-/usr/src/lkm/java/Makefile
exit



-- 
J"org Wunsch					       Unix support engineer
joerg_wunsch@interface-business.de       http://www.interface-business.de/~j



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Mutt.19970303164243.j>