Next: , Previous: , Up: binfmt   [Index]


I.4 Using the mechanism

When binfmt_misc support is enabled, the Vicare package installs a set of files automating almost everything:

$sysconfdir/rc.d/rc.vicare-scheme

A shell script (/bin/sh) to be executed to enable or disable the feature. Just running it enables binfmt_misc support.

$libexecdir/vicare-scheme/binfmt-script-launcher.sh

A shell script (/bin/sh) used as interpreter when running source scripts.

$libexecdir/vicare-scheme/binfmt-program-launcher.sh

A shell script (/bin/sh) used as interpreter when running compiled programs.

We might want to add the invocation of rc.vicare-scheme in one of the shell scripts that are executed at system boot time; for example, on a Slackware Linux system we can use /etc/rc.d/rc.local by inserting this code:

if [ -x "$sysconfdir/rc.d/rc.vicare-scheme" ]; then
   "$sysconfdir/rc.d/rc.vicare-scheme"
fi

The script rc.vicare-scheme implements binfmt_misc support by adding two records to the register: one for source scripts with name VICARE_SCRIPTS and one for compiled programs with name VICARE_PROGRAMS. rc.vicare-scheme does the following:

  1. Verify if the binfmt_misc kernel module has been loaded by testing the existence of the register file; if the module is not there, nothing happens.
  2. Remove the configuration from the registry if it is already there; this is done by testing the existence of the special files:
    /proc/sys/fs/binfmt_misc/VICARE_SCRIPTS
    /proc/sys/fs/binfmt_misc/VICARE_PROGRAMS
    

    echoing -1 in them removes the records.

  3. Echo the records into the registry with the following fields for source scripts:
    VICARE_SCRIPTS

    It is the name of the special file representing the record in the registry.

    M

    Activates first bytes recognition.

    0

    The offset of the magic string into the file.

    ;;;!vicare

    The magic string itself.

    $libexecdir/vicare-scheme/binfmt-script-launcher.sh

    The full pathname to the source scripts launcher.

    and the following fields for compiled programs:

    VICARE_PROGRAMS

    It is the name of the special file representing the record in the registry.

    M

    Activates first bytes recognition.

    0

    The offset of the magic string into the file.

    #@IK01
    #@IK02

    The magic string itself. One for 32-bit platforms the other for 64-bit platforms.

    $libexecdir/vicare-scheme/binfmt-script-launcher.sh

    The full pathname to the compiled programs launcher.

The mask field is set to the empty string, that is: no mask is applied and the magic is matched literally.

We have to care about the order of added entries: entries added later are matched first.


Next: , Previous: , Up: binfmt   [Index]