🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.os.linux
Article #66

Re: option "kernel support for java binaries" non dispo kernel 2.0.25

#66
From: Pablo Saratxaga
Date: Tue, 12 Nov 1996 00:00
176 lines
5258 bytes
Kaixo!
in article <3284F123.563AD7B8@cnam.fr>
 Jerome Le Gallic (legall_j@cnam.fr) said:

 > J'aimerai savoir pourquoi l'option "kernel support for java binaries"
 > n'est pas disponible durant le "make config" du noyeau version 2.0.25

1) fait plut�t "make menuconfig"
2) demande que le "code experimental" te soit propos�
3) choisi java.

Si tu veux avoir la m�me chose pour le format windows (nececite Wine et mz_bin)

diff -u --recursive --new-file /usr/src/linux.old/arch/i386/config.in /usr/src/linux/arch/i386/config.in
--- /usr/src/linux.old/arch/i386/config.in	Mon May 13 06:17:23 1996
+++ linux/arch/i386/config.in	Mon Sep 23 01:34:00 1996
@@ -35,6 +35,7 @@
 tristate 'Kernel support for ELF binaries' CONFIG_BINFMT_ELF
 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
   tristate 'Kernel support for JAVA binaries' CONFIG_BINFMT_JAVA
+  tristate 'Kernel support for DOS/Windows binaries' CONFIG_BINFMT_MZ
 fi
 bool 'Compile kernel as ELF - if your GCC is ELF-GCC' CONFIG_KERNEL_ELF
 
diff -u --recursive --new-file /usr/src/linux.old/fs/Makefile /usr/src/linux/fs/Makefile
--- /usr/src/linux.old/fs/Makefile	Wed May  8 17:28:01 1996
+++ linux/fs/Makefile	Mon Sep 23 01:33:40 1996
@@ -181,6 +181,14 @@
   endif
 endif
 
+ifeq ($(CONFIG_BINFMT_MZ),y)
+BINFMTS += binfmt_mz.o
+else
+  ifeq ($(CONFIG_BINFMT_MZ),m)
+  M_OBJS += binfmt_mz.o
+  endif
+endif
+
 # binfmt_script is always there
 BINFMTS += binfmt_script.o
 
diff -u --recursive --new-file /usr/src/linux.old/fs/binfmt_mz.c /usr/src/linux/fs/binfmt_mz.c
--- /usr/src/linux.old/fs/binfmt_mz.c	Thu Jan  1 01:00:00 1970
+++ linux/fs/binfmt_mz.c	Mon Sep 23 01:57:35 1996
@@ -0,0 +1,119 @@
+/*
+ *  binfmt_mz.c
+ *
+ *  Copyright (C) 1995 Wayne Meissner
+ *  Copyright (C) 1996  Martin von L�wis
+ */
+
+/*
+ * Usage: insmod binfmt_mz.o [loader=<path to mzloader>]
+ */
+
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/stat.h>
+#include <linux/malloc.h>
+#include <linux/binfmts.h>
+
+#ifdef MZLOADER
+	static char *loader = MZLOADER;
+#else
+	static char *loader = "/usr/sbin/mzloader";
+#endif
+
+static char * extensions[] = {
+	"bat", "com", "exe", NULL
+};
+
+/* Return true if the binary is supported by dosemu or Wine */
+
+static int is_dos_file(struct linux_binprm *bprm)
+{
+	int i;
+	char *ext;
+	if ((bprm->buf[0] == 'M') && (bprm->buf[1] == 'Z'))
+		return 1;
+	/* check for the extension (.bat, .com) */
+	ext = strchr (bprm->filename, '.');
+	/* if no extension, then who knows what it could be */
+	if (!ext)
+		return 0;
+	ext++;
+
+	/* lastly, check if its a .bat, .com, etc */
+	for (i = 0; extensions[i] != NULL; i++) 
+		if (strcmp(ext, extensions[i]) == 0) 
+			return 1;
+	return 0;
+}
+
+static int do_load_mz_binary(struct linux_binprm *bprm,struct pt_regs *regs)
+{
+	int retval;
+	char *mzloader;
+	mzloader=loader;
+
+	if(!is_dos_file(bprm))
+		return -ENOEXEC;
+					 
+	iput(bprm->inode);
+	bprm->dont_iput=1;
+
+#if 0
+	/* This prepends the emulator name before the command line.
+	   mzloader does not need it */
+	bprm->p = copy_strings(1, &loader, bprm->page, bprm->p, 2);
+	bprm->argc++;
+	if (!bprm->p) 
+		return -E2BIG;
+#endif
+	retval = open_namei(mzloader, 0, 0, &bprm->inode, NULL);
+	if (retval)
+		return retval;
+	bprm->dont_iput=0;
+
+	/* This avoids recursion, as is_dos_file checks for the filename, too.
+	   Just changing the pointer is OK, since the binfmt system will not
+	   mess with it. The only effect is that the command in the process table
+       is now the emulator, not the program image */
+
+	bprm->filename = mzloader;
+
+	retval=prepare_binprm(bprm);
+	if(retval<0)
+		return retval;
+	return search_binary_handler(bprm,regs);
+}
+
+static int load_mz_binary(struct linux_binprm *bprm,struct pt_regs *regs)
+{
+	int retval;
+	MOD_INC_USE_COUNT;
+	retval = do_load_mz_binary(bprm,regs);
+	MOD_DEC_USE_COUNT;
+	return retval;
+}
+
+static struct linux_binfmt mz_format = {
+#ifndef MODULE
+	NULL, 0, load_mz_binary, NULL, NULL
+#else
+	NULL, &mod_use_count_, load_mz_binary, NULL, NULL
+#endif
+};
+
+int init_mz_binfmt(void) {
+	register_binfmt(&mz_format);
+	return 0;
+}
+
+#ifdef MODULE
+int init_module(void)
+{
+	return init_mz_binfmt();
+}
+
+void cleanup_module( void) {
+	unregister_binfmt(&mz_format);
+}
+#endif


-- 

A bient�t,
Pablo Saratxaga

~
~
:wq ;-)                               PGP Key available, key ID: 0x8F0E4975
Technical Details
Message-ID: <568q26$i2o@linux.chanae.stben.be>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3284F123.563AD7B8@cnam.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 108b03,70169c8ece96ff32,start
X-Google-Attributes: gid108b03,public
X-Google-Thread: 106138,7a67175193634b53
X-Google-Attributes: gid106138,public
From: srtxg@linux.chanae.stben.be (Pablo Saratxaga)
Subject: Re: option "kernel support for java binaries" non dispo kernel 2.0.25
Date: 1996/11/12
Message-ID: <568q26$i2o@linux.chanae.stben.be>
X-Deja-AN: 196222035
references: <3284F123.563AD7B8@cnam.fr>
x-comment-to: Jerome Le Gallic <legall_j@cnam.fr>
content-type: text/plain; charset=iso-8859-1
organization: -= Bad WaZOO ;-) BBS =- Liege, Belgium
mime-version: 1.0
newsgroups: fr.comp.os.linux,fido.belg.fra.linux