Documentation目录下binfmt_misc文档的翻译

简介:      Kernel Support for miscellaneous (your favourite) Binary Formats v1.
     Kernel Support for miscellaneous (your favourite) Binary Formats v1.1
内核对五花八门的二进制格式的支持
     =====================================================================


This Kernel feature allows you to invoke almost (for restrictions see below)
every program by simply typing its name in the shell.
该内核允许你调用几乎任何一个程序,你仅仅需要在shell中键入他的名字。
This includes for example compiled Java(TM), Python or Emacs programs.
这包括例如被编译之后的java,python或者是emacs程序。


To achieve this you must tell binfmt_misc which interpreter has to be invoked
with which binary. Binfmt_misc recognises 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 recognise a filename extension
aka '.com' or '.exe'.
为了达到这个目的,你必须告诉binfmt_misc你需要调用哪一个二进制格式的解释器。Binfmt_misc
程序通过匹配文件开始的一些二进制序列(以一些特殊的二进制位来标识)来识别是哪一种二进制
类型。Binfmt_misc也能够识别一个文件的扩展名例如'.com'或者是'.exe'.


First you must mount binfmt_misc:
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 
首先你需要挂载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.
为了能够真正的注册一个新的二进制类型,你应该设置一个字符串看上去像:name:type:offset
:magic:mask:interpreter:(你可以根据你的需要选择':')并且将他广播到/proc/sys/fs/binfmt_misc/resgister中


Here is what the fields mean:
下面是这些参数的意思:
 - 'name' is an identifier string. A new /proc file will be created with this
   name below /proc/sys/fs/binfmt_misc
 - 'name'是定义字符串.一个新的/proc文件将在/proc/sys/fs/binfmt_misc下以他的名字被创建


 - 'type' is the type of recognition. Give 'M' for magic and 'E' for extension.
 - 'type' 是识别的类型。'M'代表着二进制序列和'E'是扩展


 - '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'是在文件中二进制学列的偏移量,以位计数。如果你这样写':name:type::magic...',
   那么它默认是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
   recognised (without the '.', the \x0a specials are not allowed). Extension
   matching is case sensitive!
 - 'magic'是binfmt_misc要匹配的位序列。这个位序列可能包含16进制编码的字符例如\x0a 
   或者是 \xA4.在一个shell环境中,你必须写\\x0a来避免shell吞掉你的\。如果你选择
   使用文件扩展名开匹配的话,下面是一些小规则(不能有'.',\x0a是不允许的).并且扩展名
   匹配是大小写敏感的。


 - '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'是一个标识(可选的,默认所有的都是0xff)。通过提供一个类似于magic或者是和magic
一样长的字符串来从正在匹配的文件中标识出一些位。


 - 'interpreter' is the program that should be invoked with the binary as first
   argument (specify the full path)
 - 'interpreter' 应该是被二进制文件首先被调用的参数(特别是全路径)。


There are some restrictions:
同时还有一些显示:
 - the whole register string may not exceed 255 characters                  整体的寄存器字符串不应该超过255个字符
 - the magic must reside in the first 128 bytes of the file, i.e.           位序列一定要放在文件的前128位上,例如offset+size(magic)一定要少于128
   offset+size(magic) has to be less than 128
 - the interpreter string may not exceed 127 characters                     解释器字符串不能超过127个字符


To use binfmt_misc you have to mount it first. You can mount it with
"mount -t binfmt_misc none /proc/sys/fs/binfmt_misc" command, or you can add
a line "none  /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0" to your
/etc/fstab so it auto mounts on boot.
为了能够使用binfmt_misc你必须先去挂载她。你可以使用命令"mount -t binfmt_misc
none /proc/sys/fs/binfmt_misc"来挂载她,或者是你可以在/etc/fstab中添加一行
"none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0",这样他就会自动在
启动的时候挂载。


You may want to add the binary formats in one of your /etc/rc scripts during
boot-up. Read the manual of your init program to figure out how to do this
right.
你可能想要在启动的时候在你的一个/etc/rc脚本文件中添加一个二进制格式。阅读你的启动
程序手册来弄清楚如何正确的做这些事情。


Think about the order of adding entries! Later added entries are matched first!
请思考一些添加的顺序,后添加的会先被匹配。


A few examples (assumed you are in /proc/sys/fs/binfmt_misc):
几个小例子(假设你在/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\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register
  echo ':i486:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register
启动对em86的支持(类似于binfmt_em86,仅仅对Alpha AXP适用)
echo ':i386:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register
  echo ':i486:M::\x7fELF\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfb\xff\xff:/bin/em86:' > register


- enable support for packed DOS applications (pre-configured dosemu hdimages):
  echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register
启动对DOS应用程序的支持
echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register


- enable support for Windows executables using wine:
  echo ':DOSWin:M::MZ::/usr/local/bin/wine:' > register
启动使用wine对windows可执行程序的支持
echo ':DOSWin:M::MZ::/usr/local/bin/wine:' > register


For java support see Documentation/java.txt
对于java支持,请查看Documentation/java.txt文件


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.
你可以通过向/proc/sys/fs/binfmt_misc/status 或者是 /proc/.../the_name广播0(关闭)
或者是1(启动)来启动/关闭binfmt_misc或者是一个二进制类型。查看文件能够告诉你binfmt_misc
/the entry的当前状态。


You can remove one entry or all entries by echoing -1 to /proc/.../the_name
or /proc/sys/fs/binfmt_misc/status.
你可以通过向/proc/.../the_name或者是/proc/sys/fs/binfmt_misc/status广播-1来移除
一个记录或者是所有的记录。


HINTS:
提示:
======


If you want to pass special arguments to your interpreter, you can
write a wrapper script for it. See Documentation/java.txt for an
example.
如果你想要向你的解释器传送特殊的参数,你可以向他写一个脚本文件。例如
你可以查看Documentation/java.txt文件。


Your interpreter should NOT look in the PATH for the filename; the
kernel passes it the full filename to use.  Using the PATH can cause
unexpected behaviour and be a security hazard.
你的解释器不应该查看文件名字的路径。(这句话不是很明白)内核会将文件全名
传送给她使用。使用PATH可能会导致不可预料的问题并且会成为一个安全危险。


There is a web page about binfmt_misc at
http://www.tat.physik.uni-tuebingen.de/~rguenth/linux/binfmt_misc.html
这里有一个有关binfmt_misc的网页:
http://www.tat.physik.uni-tuebingen.de/~rguenth/linux/binfmt_misc.html


Richard G黱ther <rguenth@tat.physik.uni-tuebingen.de>
目录
相关文章
|
Kubernetes 负载均衡 安全
【K8S系列】深入解析k8s网络插件—Cilium
【K8S系列】深入解析k8s网络插件—Cilium
1890 1
|
8月前
图片的大小
【10月更文挑战第7天】
580 1
|
SQL 人工智能 自然语言处理
NL2SQL基础系列(2):主流大模型与微调方法精选集,Text2SQL经典算法技术回顾七年发展脉络梳理
NL2SQL基础系列(2):主流大模型与微调方法精选集,Text2SQL经典算法技术回顾七年发展脉络梳理
NL2SQL基础系列(2):主流大模型与微调方法精选集,Text2SQL经典算法技术回顾七年发展脉络梳理
|
SQL 存储 关系型数据库
sql数据库优点
SQL数据库(如MySQL、SQL Server等)以其标准化、强大的查询功能、数据完整性保障、事务处理、安全性、可扩展性和灵活性受到青睐。它们支持事务及用户访问控制,保证数据准确一致;提供多样化存储引擎和索引技术,适应不同场景。SQL易学易用,并广泛应用于各种系统集成,拥有丰富的社区资源,便于问题解决和学习。
|
云安全 存储 弹性计算
阿里云产品试用图文教程及注意事项
阿里云产品可以免费试用,阿里云企业和个人用户都能申请,本文以个人用户申请试用云服务器ECS产品为例为大家展示阿里云产品试用图文教程及注意事项,来看看怎么申请免费试用到阿里云产品吧。
阿里云产品试用图文教程及注意事项
|
关系型数据库 Apache DataX
BDCC - 数据集成领域的主流中间件_ Apache SeaTunnel vs Flink CDC vs DataX vs Apache Sqoop vs Apache Flume
BDCC - 数据集成领域的主流中间件_ Apache SeaTunnel vs Flink CDC vs DataX vs Apache Sqoop vs Apache Flume
1152 0
|
存储 Kubernetes 安全
kubernetes集群备份与恢复
k8s集群服务所有组件都是无状态服务,所有数据都存储在etcd集群当中,所以为保证k8s集群的安全可以直接备份etcd集群数据,备份etcd的数据相当于直接备份k8s整个集群。
2218 1
|
小程序 iOS开发 Python
抓包技术的应用示例:薅瑞幸羊毛 🦙
抓包技术的应用示例:薅瑞幸羊毛 🦙
343 0
|
Dubbo Java 关系型数据库
探索 Java ServiceLoader、Dubbo ExtensionLoader:构建灵活可扩展的应用程序的利器(上)
探索 Java ServiceLoader、Dubbo ExtensionLoader:构建灵活可扩展的应用程序的利器
188 0
|
SQL JavaScript 前端开发
大数据 ETL 处理工具 Kettle 完成一个作业任务
简单一句话,作业流程,即是对转换流程进行调度,也可以嵌套转换流程和作业流程。