Versions 2.1.43 and later of the Linux kernel have contained the binfmt_misc
module.
This enables a system administrator to register interpreters for various
binary formats based on a magic number or their file extension, and cause
the appropriate interpreter to be invoked whenever a matching file is
executed.
Think of it as a more flexible version of the #! executable interpreter
mechanism, or as something which can behave a little like "associations" in
certain other operating systems (though in GNU/Linux the tendency is to keep
this sort of thing somewhere else, like your file manager).
manages a persistent database of these interpreters.
When each package providing a registered interpreter is installed, changed,
or removed,
is called to update information about that interpreter.
is usually called from the
or
scripts in Debian packages.
OPTIONS
Exactly one action must be specified; this may be accompanied by any one of
the common options.
Specifies the name of the current package, to be used by package
post-installation and pre-removal scripts.
System administrators installing binary formats for local use should
probably ignore this option.
When installing new formats, the
action should be used instead.
Specifies the administrative directory, when this is to be different from
the default of
Specifies the directory from which packaged binary formats are imported,
when this is to be different from the default of
Don't do anything, just demonstrate what would be done.
Display some usage information.
Display version information.
Install a binary format identified by
with interpreter
into the database.
After registration, this format will be used when the kernel tries to
execute a file matching
(see
below).
will attempt to enable this binary format in the kernel as well as adding it
to its own database; see
below.
You cannot install a format with any of the names ".", "..", "register", or
"status", as these are used by the filesystem or the binfmt_misc module.
Remove the binary format identified by
with interpreter
from the database.
This will also attempt to disable the binary format in the kernel; see
below.
Import a packaged format file called
or import all format files currently on the system if no
is given.
If
is not a full path, it is assumed to be a file in the import directory
by default).
See
below for the required contents of these files.
For packages, this is preferable to using the
option, as a format file can be installed without
needing to be available.
Display any information held in the database about the binary format
identifier
or about all known binary formats if no
is given.
Also show whether displayed binary formats are enabled or disabled.
Enable binary format
or all known binary formats if no
is given, in the kernel, thus enabling direct execution of matching files.
You must have binfmt_misc compiled into the kernel or loaded as a module for
this to work.
Disable binary format
or all known binary formats if no
is given, in the kernel, thus disabling direct execution of matching files.
You must have binfmt_misc compiled into the kernel or loaded as a module for
this to work.
This matches all files with the magic number
Hexadecimal escapes may be included in the
by preceding them with \x, for example
for a linefeed.
Remember to protect such escapes with quotes or an additional backslash to
prevent their interpretation by the shell.
Also see
and
This is the offset of the magic/mask in the file, counted in bytes.
The default is 0.
Only valid with
This mask will be logically-ANDed with the string to be checked against the
magic number given with
The default is all 0xff, i.e. no effect.
Only valid with
This matches all files whose names end in
Hexadecimal escapes are not recognized here.
Extension matching is case-sensitive.
If this option is used, a userspace detector program will be used to check
whether the file is suitable for this interpreter.
This may be used when the binary format is more complex than can be handled
by the kernel's format specifications alone.
The program should return an exit code of zero if the file is appropriate
and non-zero otherwise.
A format file is a sequence of options, one per line, corresponding roughly
to the options given to an
command.
Each option consists of a key, followed by whitespace, followed by a value.
The
option should be set to the current package.
The
option should be set to the path to the interpreter that will handle this
binary format.
The
and
options correspond to the command-line options of the same names.
EXIT STATUS
The requested action was successfully performed.
Problems were encountered whilst parsing the command line or performing the
action.
EXAMPLES
This format file can be used with an interpreter capable of handling Java
.class files:
package javawrapper
interpreter /usr/bin/javawrapper
magic \xca\xfe\xba\xbe
This corresponds roughly to the following command:
update-binfmts --package javawrapper \
--install javawrapper /usr/bin/javawrapper \
--magic (aq\xca\xfe\xba\xbe(aq
NOTES
If you're not careful, you can break your system with
An easy way to do this is to register an ELF binary as a handler for ELF,
which will almost certainly cause your system to hang immediately; even if
it doesn't, you won't be able to run
to fix it.
In the future
may have some checks to prevent this sort of thing happening accidentally,
though of course you can still manipulate the binfmt_misc kernel module
directly.
AUTHOR
is copyright (c) 2000-2002
See the GNU General Public License version 2 or later for copying
conditions.
You can find the GNU GPL in
on any modern Debian system.
Richard Guenther wrote the binfmt_misc kernel module.
THANKS
Ian Jackson wrote
and
from which this program borrows heavily.