[Mono-docs-list] Question about EXE binaries and kernels?
Is the following true? If so, what does it mean-- what will happen if I fail to make the EXE binaries compatible with the kernel? You can make your mono .exe files executable by following these steps: Enabling binfmt in your kernel. Adding the line below to your fstab: binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc none On boot run the command below: echo ':CLR:M::MZ::/usr/bin/mono:' /proc/sys/fs/binfmt_misc/register chmod +x foobar.exe Another way to accomplish the above is to wrap the mono .exe file it in a shell script, like this: #!/bin/sh /usr/bin/mono $@ If you installed mono to a different location, substitute that for /usr/bin/mono. You can check with the which mono command.
Re: [Mono-docs-list] Question about EXE binaries and kernels?
On Tue, 2004-04-06 at 22:48, Aaron Weber wrote: Is the following true? If so, what does it mean-- what will happen if I fail to make the EXE binaries compatible with the kernel? You don't make EXE's compatible with the kernel. Instead, you instruct the kernel to use a wrapper ELF (native) binary to bootstrap (launch) the EXE program. That's what BINFMT is for: while trying to launch an EXE, the kernel detects the file signature is not a native one, looks the BINFMT registered formats and tries to look for a match. If a match is found, the corresponding bootstraper native binary is used to launch the non-native program. BINFMT can also used to launch EXE files using WINE or .class files using the JVM. You can make your mono .exe files executable by following these steps: 1. Enabling binfmt in your kernel. This adds support to launch non-native binaries using a bootstrap loader. 1. Adding the line below to your fstab: binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc none Needed to configure BINFMT support. 1. On boot run the command below: echo ':CLR:M::MZ::/usr/bin/mono:' /proc/sys/fs/binfmt_misc/register This adds a new executable format for EXE files. Thus, the next time you launch a file whose signature matches the MZ signature of an EXE file, /usr/bin/mono will be used to bootstrap the EXE program. ___ Mono-docs-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-docs-list
Re: [Mono-docs-list] Question about EXE binaries and kernels?
Thanks for the explanation. How's this sound? The normal way to run a Mono application is to invoke it through the interpreter, like so: mono myprogram.exe However, there are two things you can do to make it more convenient to run Mono applications. The first is to use a shell script instead of the EXE file. For example, if you had myprogram.exe you could create a shell script called myprogram that had the contents: #!/bin/sh /usr/bin/mono myprogram.exe If you installed mono to a different location, substitute that for /usr/bin/mono. You can check with the which mono command. You can also make a systemwide change, and use binfmt to register the exe files as non-native binaries. Then, when trying to launch an exe file, the kernel will run the mono interpreter to handle the command. Binfmt can also be used to launch Windows executables using WINE, or Java .class files using a JVM. To register exe with the kernel: Turn on binfmt in your kernel. Add the line below to your fstab: binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc none Then, have your system run the following command on boot: echo ':CLR:M::MZ::/usr/bin/mono:' /proc/sys/fs/binfmt_misc/register Be sure to mark your .exe files as executable in the filesystem as well: chmod +x myprogram.exe
Re: [Mono-docs-list] Question about EXE binaries and kernels?
On a related note, wouldn't it make sense to bundle a simple binfmt init script with mono? I'm sure we can come up with a script generic enough to work across most of the major distros. -fawad Ben Maurer wrote: On Tue, 2004-04-06 at 17:57, Aaron Weber wrote: Thanks for the explanation. How's this sound? The normal way to run a Mono application is to invoke it through the interpreter, like so: Caution. You probably dont mean an `interpreter'. Someone could get confused with interpreter vs jit. #!/bin/sh /usr/bin/mono myprogram.exe This will execute `myprogram.exe' that is located in the current working directory. You probably want an absolute path there. Or you could get the path of the script that is executing. Also, you want to put $@ at the end so that it gets arguments. cat `which mcs` has a good example. ___ Mono-docs-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-docs-list ___ Mono-docs-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-docs-list
Re: [Mono-docs-list] Question about EXE binaries and kernels?
On Tue, 2004-04-06 at 23:57, Aaron Weber wrote: Thanks for the explanation. How's this sound? This looks really good. Please take a look at the end of the e-mail for some additional comments. The normal way to run a Mono application is to invoke it through the interpreter, like so: mono myprogram.exe However, there are two things you can do to make it more convenient to run Mono applications. The first is to use a shell script instead of the EXE file. For example, if you had myprogram.exe you could create a shell script called myprogram that had the contents: #!/bin/sh /usr/bin/mono myprogram.exe If you installed mono to a different location, substitute that for /usr/bin/mono. You can check with the which mono command. You can also make a systemwide change, and use binfmt to register the exe files as non-native binaries. Then, when trying to launch an exe file, the kernel will run the mono interpreter to handle the command. Binfmt can also be used to launch Windows executables using WINE, or Java .class files using a JVM. To register exe with the kernel: 1. Turn on binfmt in your kernel. 1.1. If you choose to enable binfmt as a module, you'll need to manually load it by running modprobe binfmt as root. Usually, you will want to place the previous command inside the boot script, for example /etc/rc.local so the module gets loaded during boot. 1. Add the line below to your fstab: binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc none 2. Then, have your system run the following command on boot: echo ':CLR:M::MZ::/usr/bin/mono:' /proc/sys/fs/binfmt_misc/register This is usually placed inside a boot script, like /etc/rc.local, for example, so it gets invoked automatically at startup. 1. Be sure to mark your .exe files as executable in the filesystem as well: chmod +x myprogram.exe Also, it would be interesing to state that enabling BINFMT support shouldn't create any compatibility or interaction problem between EXE files, the MONO CLR and the kernel, and shouldn't pose any problems when upgrading MONO CLR or the kernel itself, since the process of launching and running the EXE file is handled by a userspace program, /usr/bin/mono, that is, the MONO CLR. Thus, this will work with any BINFMT-enabled kernel, such as 2.4.x and 2.6.x kernels. Recently, I submitted a patch against the 2.6.5 kernel that describes process exactly in the same way as you did in the previous e-mail. It's already upstream so anyone working with a 2.6.5 kernel can also have this handy steps at a well-known place: Documentation/mono.txt and inside the kernel config help text. Thanks! ___ Mono-docs-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-docs-list
Re: [Mono-docs-list] Question about EXE binaries and kernels?
On Wed, 2004-04-07 at 00:17, Ben Maurer wrote: On Tue, 2004-04-06 at 17:57, Aaron Weber wrote: Thanks for the explanation. How's this sound? The normal way to run a Mono application is to invoke it through the interpreter, like so: Caution. You probably dont mean an `interpreter'. Someone could get confused with interpreter vs jit. #!/bin/sh /usr/bin/mono myprogram.exe This will execute `myprogram.exe' that is located in the current working directory. You probably want an absolute path there. Or you could get the path of the script that is executing. Also, you want to put $@ at the end so that it gets arguments. Good catch! ___ Mono-docs-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-docs-list