Binfmt_misc file translation under the documentation directory

Source: Internet
Author: User

Binfmt_misc Kernel

Kernel support for miscellaneous (your favorite) binary formats V1.1
Kernel support for a variety of binary formats
========================================================== ==================================


This kernel feature allows you to invoke almost (for restrictions see below)
Every program by simply typing its name in the shell.
This kernel allows you to call almost any program. You just need to type its name in shell.
This includes des for example compiled Java (TM), Python or Emacs programs.
This includes, for example, compiled Java, Python, or Emacs programs.


To achieve this you must tell binfmt_misc which interpreter has to be invoked
With which binary. binfmt_misc recognizes the binary-type by matching some bytes
At the beginning of the file with a magic byte sequence (masking out specified
BITs) you have supplied. binfmt_misc can also recognize a filename extension
AKA '. com' or '.exe '.
To achieve this, you must tell binfmt_misc which binary interpreter you need to call. Binfmt_misc
The Program identifies a binary by matching some binary sequences starting with a file (identified by some special binary bits ).
Type. Binfmt_misccan also identify the extension name of a file, for example, '.com'extension is '.exe '.


First you must mount binfmt_misc:
Mount binfmt_misc-T binfmt_misc/proc/sys/fs/binfmt_misc
First you need to mount binfmt_misc
Mount binfmt_misc-T binfmt_misc/proc/sys/fs/binfmt_misc


To actually register a new binary type, you have to set up a string looking like
: Name: Type: offset: Magic: mask: Interpreter: (where you can choose the ': 'upon
Your needs) and echo it to/proc/sys/fs/binfmt_misc/register.
To register a new binary type, you should set a string that looks like: Name: Type: offset.
: Magic: mask: Interpreter :( you can select ':' as needed) and broadcast it to/proc/sys/fs/binfmt_misc/resgister.


Here is what the fields mean:
The following are the meanings of these parameters:
-'Name' is an identifier string. A new/proc file will be created with this
Name below/proc/sys/fs/binfmt_misc
-'Name' is the definition string. A new/proc file will be created under/proc/sys/fs/binfmt_misc with its name


-'Type' is the type of recognition. Give 'M' for magic and 'E' for extension.
-'Type' indicates the recognition type. 'M' indicates that the binary sequence and 'E' are extensions.


-'Offset' is the offset of the magic/mask in the file, counted in bytes. This
Defaults to 0 if you omit it (I. e. You write ': Name: Type: Magic ...')
-'Offset' is the offset of binary columns in the file, which is counted in bits. If you write ': Name: Type: Magic ...',
The default value is 0.


-'Magic 'is the byte sequence binfmt_misc is matching for. The magic string
May contain hex-encoded characters like \ x0a or \ xa4. in a shell Environment
You will have to write \ x0a to prevent the shell from eating your \.
If you chose filename extension matching, This is the extension to be
Recognized (without the '.', the \ x0a specials are not allowed). Extension
Matching is case sensitive!
-'Magic 'is the bit sequence to be matched by binfmt_misc. This bit sequence may contain hexadecimal characters such as \ x0a
Or \ xa4. in a shell environment, you must write \ x0a to prevent shell from consuming your \. If you choose
If you use the file extension to enable matching, the following are some small rules ('.' And \ x0a are not allowed). And the extension
Matching is case sensitive.


-'Mask' is an (optional, defaults to all 0xff) mask. You can mask out some
Bits from matching by supplying a string like magic and as long as magic.
The mask is anded with the byte sequence of the file.
-'Mask' is an identifier (optional, all of which are 0xff by default ). By providing
Long string to identify some bits from the bid of the matching file.


-'Interpreter 'is the program that shoshould be invoked with the binary as first
Argument (specify the full path)
-'Interpresion' should be the parameter first called by the binary file (especially the full path ).


There are some restrictions:
There are also some displays:
-The whole register string may not exceed 255 characters the overall register string should not exceed 255 characters
-The magic must reside in the first 128 bytes of the file, I. e. bit sequences must be placed on the first 128 bits of the file. For example, offset + size (MAGIC) must be less than 128
Offset + size (MAGIC) has to be less than 128
-The Interpreter string may not exceed 127 characters interpreter string cannot exceed 127 characters


To use binfmt_misc you have to mount it first. You can mount it
"Mount-T binfmt_misc NONE/proc/sys/fs/binfmt_misc" command, or you can add
A line "NONE/proc/sys/fs/binfmt_misc defaults 0 0" to your
/Etc/fstab so it auto mounts on boot.
To be able to use binfmt_misc, you must first mount it. You can run the command "Mount-T binfmt_misc
None/proc/sys/fs/binfmt_misc "to mount her, or you can add a line in/etc/fstab.
"None/proc/sys/fs/binfmt_misc defaults 0 0", then it will automatically
It is mounted at startup.


You may want to add the binary formats in one of your/etc/rc scripts
Boot-up. Read the manual of your INIT program to figure out how to do this
Right.
You may want to add a binary format to your/etc/rc script file at startup. Read your startup
Program manual to find out how to do these things correctly.


Think about the order of adding entries! Later added entries are matched first!
Think about the order of addition. The addition will be matched first.


A few examples (assumed you are in/proc/sys/fs/binfmt_misc ):
A few small examples (Suppose You Are In/proc/sys/fs/binfmt_misc)


-Enable support for em86 (like binfmt_em86, for Alpha AXP only ):
Echo ': i386: M :: \ x7felf \ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x02 \ x00 \ x03: \ xFF \ xfe \ xFF \ xfb \ xFF: /bin/em86: '> Register
Echo ': iworkflow: M :: \ x7felf \ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x02 \ x00 \ x06: \ xFF \ xfe \ xFF \ xfb \ xFF: /bin/em86: '> Register
Start em86 support (similar to binfmt_em86, applicable only to Alpha AXP)
Echo ': i386: M :: \ x7felf \ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x02 \ x00 \ x03: \ xFF \ xfe \ xFF \ xfb \ xFF: /bin/em86: '> Register
Echo ': iworkflow: M :: \ x7felf \ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x02 \ x00 \ x06: \ xFF \ xfe \ xFF \ xfb \ xFF: /bin/em86: '> Register


-Enable support for packed dos applications (pre-configured dosemu hdimages ):
Echo ': dexe: M: \ x0edex:/usr/bin/dosexec:'> Register
Start support for DOS applications
Echo ': dexe: M: \ x0edex:/usr/bin/dosexec:'> Register


-Enable support for Windows executables using wine:
Echo ': doswin: M: MZ:/usr/local/bin/wine:'> Register
Start Windows executable program support using wine
Echo ': doswin: M: MZ:/usr/local/bin/wine:'> Register


For Java support see documentation/java.txt
For Java support, see the documentation/java.txt File


You can enable/disable binfmt_misc or one binary type by echoing 0 (to disable)
Or 1 (to enable) to/proc/sys/fs/binfmt_misc/status or/proc/.../the_name.
Catting the file tells you the current status of binfmt_misc/the entry.
You can broadcast 0 to/proc/sys/fs/binfmt_misc/status or/proc/.../the_name (disable)
Or 1 (start) to start/Close binfmt_misc or a binary type. View the file to tell you binfmt_misc
/The current status of the entry.


You can remove one entry or all entries by echoing-1 to/proc/.../the_name
Or/proc/sys/fs/binfmt_misc/status.
You can remove it from/proc/.../the_name or/proc/sys/fs/binfmt_misc/status broadcast-1.
One or all records.


Hints:
Tip:
======


If you want to pass special arguments to your interpreter, you can
Write a wrapper script for it. See documentation/java.txt for
Example.
If you want to transmit special parameters to your interpreter, you can write a script file to it. For example
You can view the documentation/java.txt file.


Your interpreter shocould not look in the path for the filename;
Kernel passes it the full filename to use. Using the path can cause
Unexpected behaviour and be a security hazard.
Your interpreter should not view the path of the file name. (This sentence is not quite clear) the kernel will replace the full name of the file
Send it to her for use. Using path may cause unexpected problems and become a security risk.


There is a Web page about binfmt_misc
Http://www.tat.physik.uni-tuebingen.de /~ Rguenth/Linux/binfmt_misc.html
Here is a Web page about binfmt_misc:
Http://www.tat.physik.uni-tuebingen.de /~ Rguenth/Linux/binfmt_misc.html


Richard G ther <[email protected]>

Binfmt_misc file translation under the documentation directory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.