From owner-freebsd-hackers Mon Mar 3 07:43:08 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA08452 for hackers-outgoing; Mon, 3 Mar 1997 07:43:08 -0800 (PST) Received: from innocence.interface-business.de (innocence.interface-business.de [193.101.57.202]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA08446 for ; Mon, 3 Mar 1997 07:43:01 -0800 (PST) Received: from ida.interface-business.de (ida.interface-business.de [193.101.57.203]) by innocence.interface-business.de (8.6.11/8.6.9) with SMTP id QAA23212; Mon, 3 Mar 1997 16:38:33 +0100 Received: (from j@localhost) by ida.interface-business.de (8.8.5/8.7.3) id QAA17133; Mon, 3 Mar 1997 16:42:43 +0100 (MET) Message-ID: 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. References: X-Mailer: Mutt 0.55-PL15 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Phone: +49-351-31809-14 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Organization: interface business GmbH, Dresden Reply-To: joerg_wunsch@interface-business.de (Joerg Wunsch) In-Reply-To: ; from Adrian Chadd on Mar 3, 1997 06:42:04 +0800 Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 X#include X#include X#include X#include X#include X#include 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 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