binfmt_misc
From Wikipedia, the free encyclopedia
Please help improve this article or section by expanding it. Further information might be found on the talk page or at requests for expansion. (May 2008) |
binfmt_misc is a capability of the Linux kernel which allows arbitrary executable file formats to be recognized and passed to certain user space applications, such as emulators and virtual machines.
The executable formats are registered through a special purpose file system interface (similar to /proc).
Contents |
[edit] Registration
The register file contains lines which define executable types to be handled. Each line is of the form:
:name:type:offset:magic:mask:interpreter:
- name is the name of the new binary format.
- type is either E or M. If it is E, then the executable file format is identified by its filename extension, offset and mask are ignored, and magic is the file extension to be associated with the binary format. If it is M, then the executable file format is identified by a magic number near the beginning of the file. magic is the magic number identifying the binary format and offset is the offset at which the magic number is found in the file. The mask is bitwise ANDed with the magic string from the file: the bits which are unset in the mask are ignored in the comparison to the magic.
- interpreter is a path to an executable. When a file using a binfmt_misc-registered executable format is executed, this program is run with the executable as an argument.
When an executable file format is registered, a file is created in the /proc/sys/fs/binfmt_misc directory. This file can be read later to get information about the file format.
[edit] Common usage
binfmt_misc allows Java programs to be passed directly to the Java virtual machine.
Another common usage is to execute PE executables (compiled for MS-DOS or Microsoft Windows) through Wine. For example, the following line will run DOS and Windows EXE files (identified by the "MZ" type code) using Wine:
:DOSWin:M::MZ::/usr/bin/wine:
[edit] See also
[edit] References
- Documentation/binfmt_misc.txt in the Linux kernel source tree