david135 / ypsilon

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

[wiki contrib] on using binfmt_misc linux kernel module #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have added to my distribution[1] a simple project to use the binfmt_misc
mechanism to run R6RS Scheme programs. I think that it would be good to add
a description of the thing to the Ypsilon Wiki. The distribution has
extended documentation and example scripts, but below is a compressed
version which you can use.

[1] http://github.com/marcomaggi/nausicaa/tree/master/scripts

It is possible to activate automatic execution
of R6RS Scheme programs with Ypsilon through the
mechanism of the "binfmt_misc" Linux kernel module.
It is available only on Unix--like platforms running
the Linux kernel.

The "binfmt_mic" module allows us to run R6RS
programs without explicitly invoking the Ypsilon
runtime executable.  It is a generalisation of
the mechanism that allows us to run shell scripts
by starting the file with "#!/bin/sh".

This is what we have to do:

1. at system boot load the kernel module
   by running:

|  /sbin/modprobe binfmt_misc

2. add the following line to "/etc/fstab":

|  none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0

   so that the "binfmt_misc" directory is mounted
   when booting the system;

3. put in a system shell boot script:

|  if test -f /proc/sys/fs/binfmt_misc/register ; then
|    echo ':YPSILON:M:3:!ypsilon::/usr/local/bin/ypsilon:' \
|      >/proc/sys/fs/binfmt_misc/register
|  fi

   which tells the Linux kernel to do the following
   when running an executable file: look at zero-based
   offset 3 in the file for the string "!ypsilon",
   and if it is there run the file using the given
   "ypsilon" full pathname;

3. write an Ypsilon program, say "proof.sps", and
   begin the file with the string ";;;!ypsilon";

4. make it executable:

|   $ chmod 0755 proof.sps

5. run it like any other executable:

    $ ./proof.sps

We can inspect the status of the executable
files record with:

|  $ cat /proc/sys/fs/binfmt_misc/YPSILON

disable it with (as root):

|  $ echo 0 >/proc/sys/fs/binfmt_misc/YPSILON

enable it with (as root):

|  $ echo 1 >/proc/sys/fs/binfmt_misc/YPSILON

and remove this record with (as root):

|  $ echo -1 >/proc/sys/fs/binfmt_misc/YPSILON

Original issue reported on code.google.com by mrc....@gmail.com on 9 Jan 2009 at 12:35

GoogleCodeExporter commented 9 years ago
Thank you very much!
I have added new wiki page: http://code.google.com/p/ypsilon/wiki/linux_binfmt
Please check it. :)
-- fujita

Original comment by y.fujita...@gmail.com on 15 Jan 2009 at 4:03

GoogleCodeExporter commented 9 years ago
Fine for me. Thanks.

Original comment by mrc....@gmail.com on 15 Jan 2009 at 7:55

GoogleCodeExporter commented 9 years ago
Dunno what you say, in Italy we say "night brings advice". So rethinking of it: 
do
not cite me or Nausicaa on that page, it is not pertinent. Focus the content on 
using
Ypsilon.

Original comment by mrc....@gmail.com on 16 Jan 2009 at 6:49