Documentation/xz.txt

Chinese translated version of Documentation/filesystems/ecryptfs.txt

If you have any comment or update to the content, please contact the

original document maintainer directly.  However, if you have a problem

communicating in English you can also ask the Chinese maintainer for

help.  Contact the Chinese maintainer if this translation is outdated

or if there is a problem with the translation.

Chinese maintainer: 谢尚敬 <1479201451@qq.com>

---------------------------------------------------------------------

Documentation/xz.txt的中文翻译

如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文

交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻

译存在问题,请联系中文版维护者。

中文版维护者: 谢尚敬 <1479201451@qq.com>

中文版翻译者: 谢尚敬 <1479201451@qq.com>

中文版校译者: 谢尚敬 <1479201451@qq.com>

以下为正文

---------------------------------------------------------------------

 

XZ.Text

 

XZ data compression in Linux

Linux中的XZ数据压缩

 

Introduction

介绍:

 

XZ is a general purpose data compression format with high compression ratio and relatively fast decompression. The primary compression algorithm (filter) is LZMA2. Additional filters can be used to improve  compression ratio even further. E.g. Branch/Call/Jump (BCJ) filters  improve compression ratio of executable data.

XZ 是一种具有高压缩比和相对快速减压的一般用途的数据压缩格式。主压缩算法 (筛选) 是 LZMA2。其他筛选器可以用于改善以致进一步压缩比率。例如,分支/电话/跳转 (BCJ) 筛选器可以提高可执行数据的压缩比率。

 

The XZ decompressor in Linux is called XZ Embedded. It supports the LZMA2 filter and optionally also BCJ filters. CRC32 is supported  for integrity checking. The home page of XZ Embedded is at  <http://tukaani.org/xz/embedded.html>, where you can find the  latest version and also information about using the code outside  the Linux kernel.

XZ解压缩在Linux中被称为: XZ嵌入式。它可以支持LZMA2过滤器和BCJ过滤器。CRC32由完整性的检查所支持。 XZ嵌入式的主页是<http://tukaani.org/xz/embedded.html> ,在这里,你可以找到另外的有关使用此Linux内核代码的最新版本信息。

 

For userspace, XZ Utils provide a zlib-like compression library  and a gzip-like command line tool. XZ Utils can be downloaded from  <http://tukaani.org/xz/>.

在用户空间,XZ utils提供一个类似的zlib的压缩库和一个gzip命令行工具。 XZ utils可以从这里<http://tukaani.org/xz/>下载。

 

XZ related components in the kernel

XZ在内核中的相关组件:

 

The xz_dec module provides XZ decompressor with single-call (buffer to buffer) and multi-call (stateful) APIs. The usage of the xz_dec module is documented in include/linux/xz.h.    

xz_dec模块提供了XZ解压缩的单个调用(缓冲)和多方通话(状态)的API 。当中使用的xz_dec模块就记录在include / linux / xz.h​​里。

 

The xz_dec_test module is for testing xz_dec. xz_dec_test is not useful unless you are hacking the XZ decompressor. xz_dec_test  allocates a char device major dynamically to which one can write .xz files from userspace. The decompressed output is thrown away. Keep an eye on dmesg to see diagnostics printed by xz_dec_test. See the xz_dec_test source code for the details.

xz_dec模块是用来测试 xz_dec_test的。除非你黑进了XZ解压缩,否则xz_dec_test是没有用的。xz_dec_test主要功能是,分配一个字符设备,到一个可以从用户空间写入write.xz的文件。解压缩后输出的结果将被扔掉。盯紧dmesg中由xz_dec_test印制的诊断。细节请见xz_dec_test中的源代码。

 

For decompressing the kernel image, initramfs, and initrd, there is a wrapper function in lib/decompress_unxz.c. Its API is the same as in other decompress_*.c files, which is defined in include/linux/decompress/generic.h.

lib/decompress_unxz.c 是一个包装函数,它用于解压缩内核映像、 内存盘和 initrd。它的 API 和其他的 decompress_*.c 文件一样,都是在 include/linux/decompress/generic.h 中定义的。

 

scripts/xz_wrap.sh is a wrapper for the xz command line tool found from XZ Utils. The wrapper sets compression options to values suitable  for compressing the kernel image.

     scripts/xz_wrap.sh 是从 XZ Utils 中发现的 xz 命令行工具的包装。该包装将压缩选项设置为适用于压缩内核映像的值。

 

For kernel makefiles, two commands are provided for use with $(call if_needed). The kernel image should be compressed with  $(call if_needed,xzkern) which will use a BCJ filter and a big LZMA2 dictionary. It will also append a four-byte trailer containing the uncompressed size of the file, which is needed by the boot code.  Other things should be compressed with $(call if_needed,xzmisc)  which will use no BCJ filter and 1 MiB LZMA2 dictionary.

对于内核的生成文件,两个命令将提供给 $(call if_needed) 的使用。$(call if_needed,xzkern)将使用一个BCJ 过滤器和一个大的 LZMA2 按字典序来压缩内核映像。它还将用需要四字节大小的启动代码的牵引器,追加包含未压缩成分的文件。(call if_needed,xzmisc)将使用无 BCJ的过滤器和 1 MiB 的LZMA2 ,以字典序压缩其他文件。

 

Notes on compression options

关于压缩选项的说明:

 

Since the XZ Embedded supports only streams with no integrity check or  CRC32, make sure that you don't use some other integrity check type when encoding files that are supposed to be decoded by the kernel. With  liblzma, you need to use either LZMA_CHECK_NONE or LZMA_CHECK_CRC32 when encoding. With the xz command line tool, use --check=none or --check=crc32.

由于 XZ 嵌入只支持没有完整性检查的流或 CRC32,请确保您在解码内核文件的编码时,不使用其他一些完整性去检查类型。对于liblzma,您需要在编码时使用 LZMA_CHECK_NONE 或 LZMA_CHECK_CRC32。可以使用--check=none or --check=crc32. 命令去打开 xz 的命令行工具。

 

Using CRC32 is strongly recommended unless there is some other layer which will verify the integrity of the uncompressed data anyway. Double checking the integrity would probably be waste of CPU cycles.  Note that the headers will always have a CRC32 which will be validated  by the decoder; you can only change the integrity check type (or disable it) for the actual uncompressed data.

除非有一些其它图层无论如何都会验证未压缩数据的完整性,强烈建议使用 CRC32。双重检查完整性可能会浪费 CPU 的周期。请注意头部将总是有由解码器验证过的CRC32;对于实际未压缩的数据,您只可以更改其完整性检查的类型 (或禁用它)。

 

In userspace, LZMA2 is typically used with dictionary sizes of several  megabytes. The decoder needs to have the dictionary in RAM, thus big  dictionaries cannot be used for files that are intended to be decoded  by the kernel. 1 MiB is probably the maximum reasonable dictionary  size for in-kernel use (maybe more is OK for initramfs). The presets  in XZ Utils may not be optimal when creating files for the kernel,  so don't hesitate to use custom settings. Example:

字典容量为几兆字节的LZMA2,在用户空间里很常用。解码器需要有字典在 RAM 中,因此大词典不能用于的必须进行解码的内核文件。1 MiB 可能是内核中使用 (也许更多是为内存盘的确定)在合理范围内最大的字典容量。在创建内核文件时,XZ Utils的预设可能不是最佳的,因此不要犹豫,使用自定义设置文件。示例:

xz --check=crc32 --lzma2=dict=512KiB inputfile

 

An exception to above dictionary size limitation is when the decoder is used in single-call mode. Decompressing the kernel itself is an  example of this situation. In single-call mode, the memory usage doesn't depend on the dictionary size, and it is perfectly fine to  use a big dictionary: for maximum compression, the dictionary should  be at least as big as the uncompressed data itself.

以上字典容量限制的一个例外是,解码器使用单一调用模式。解压缩的内核本身就是这种情况的示例。在单一调用模式下,内存的使用不依赖于字典容量,故使用大词典将非常好:若要执行最大压缩,字典至少应与未压缩的数据一样大。

 

Future plans

未来计划:

 

Creating a limited XZ encoder may be considered if people think it is useful. LZMA2 is slower to compress than e.g. Deflate or LZO even at the fastest settings, so it isn't clear if LZMA2 encoder is wanted into the kernel.

如果有人以为这很有用,那么他们可以考虑创建一个有限的 XZ 编码器。LZMA2 即使设置到最快,仍要比像 Deflate 、LZO 这些压缩要慢,因此,不清楚LZMA2 编码器是否想进内核。

 

Support for limited random-access reading is planned for the  decompression code. I don't know if it could have any use in the  kernel, but I know that it would be useful in some embedded projects outside the Linux kernel.

正在为减压的代码,计划有限的随机访问读取的支持。虽然我不知道它能否有任何内核的使用,但是,我知道它在 Linux 内核以外的一些嵌入式项目中,将会非常有用。

Conformance to the .xz file format specification

Xz 压缩包文件格式规范的一致性:

     

There are a couple of corner cases where things have been simplified   at expense of detecting errors as early as possible. These should not  matter in practice all, since they don't cause security issues. But  it is good to know this if testing the code e.g. with the test files  from XZ Utils.

有几个地方的细节,在快速检测的错误上的消耗,已经被简化了。这在总体的测试中并不重要,因为它们不会导致安全问题。但如果要测试代码,知道这些终归还是好事,比如, XZ Utils 中文件的测试。

 

Reporting bugs

报告错误:

 

Before reporting a bug, please check that it's not fixed already at upstream. See <http://tukaani.org/xz/embedded.html> to get the latest code.

在报告错误之前,请确认它还没有被修复。请在<http://tukaani.org/xz/embedded.html>上下载最新的代码。

 

Report bugs to <lasse.collin@tukaani.org> or visit #tukaani on Freenode and talk to Larhzu. I don't actively read LKML or other kernel-related mailing lists, so if there's something I should know, you should email to me personally or use IRC.

可以向 < lasse.collin@tukaani.org > 报告 bug 或访问 Freenode #tukaani 和跟Larhzu说。我不经常读 LKML 或其他内核相关的邮件列表,故如果有什么我不知道的,你应该亲自给我发邮件,或使用 IRC。

 

Don't bother Igor Pavlov with questions about the XZ implementation in the kernel or about XZ Utils. While these two implementations  include essential code that is directly based on Igor Pavlov's code, these implementations aren't maintained nor supported by him.

关于 XZ 在内核执行或 XZ Utils 的问题,请不要打扰伊戈尔 · 帕夫洛夫。虽然这两种实现方式包括核心代码,是直接基于伊戈尔 · 帕夫洛夫的代码,但这些实现也不是由他来维护和支持的。

 

原文地址: http://lxr.linux.no/#linux+v3.11.6/Documentation/xz.txt

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值