Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完成 headers_install.md 的翻译 #69

Merged
merged 3 commits into from
May 10, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 13 additions & 32 deletions sources/kernel/kbuild/headers_install.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,34 @@
---
status: translating
status: translated
title: "Exporting kernel headers for use by userspace"
author: Linux Kernel Community
collector: tttturtle-russ
collected_date: 20240425
translator: RutingZhang0429
translated_date: 20240510
link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/kbuild/headers_install.rst
---

# Exporting kernel headers for use by userspace

The \"make headers_install\" command exports the kernel\'s header files
in a form suitable for use by userspace programs.
# 导出内核头文件供用户空间使用

The linux kernel\'s exported header files describe the API for user
space programs attempting to use kernel services. These kernel header
files are used by the system\'s C library (such as glibc or uClibc) to
define available system calls, as well as constants and structures to be
used with these system calls. The C library\'s header files include the
kernel header files from the \"linux\" subdirectory. The system\'s libc
headers are usually installed at the default location /usr/include and
the kernel headers in subdirectories under that (most notably
/usr/include/linux and /usr/include/asm).
"make headers_install" 命令以适合用户空间程序使用的形式导出内核的头文件。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可使用``来适应markdown


Kernel headers are backwards compatible, but not forwards compatible.
This means that a program built against a C library using older kernel
headers should run on a newer kernel (although it may not have access to
new features), but a program built against newer kernel headers may not
work on an older kernel.
Linux 内核导出的头文件描述了用户空间程序尝试使用内核服务的 API。这些内核头文件被系统的 C 库(例如 glibc 和 uClibc)用于定义可用的系统调用,以及与这些系统调用一起使用的常量和结构。C 库的头文件包括来自 "linux" 子目录的内核头文件。系统的 libc 头文件通常被安装在默认位置 /usr/include,而内核头文件则在该位置的子目录下(尤其是 /usr/include/linux 和 /usr/include/asm)。

The \"make headers_install\" command can be run in the top level
directory of the kernel source code (or using a standard out-of-tree
build). It takes two optional arguments:
内核头文件向后兼容,但不向前兼容。这意味着使用旧内核头文件和C库构建的程序可以在新内核上运行(尽管它可能无法访问新功能),但使用新内核头文件构建的程序可能无法在旧内核上运行。

"make headers_install" 命令可以在内核源代码的顶层目录中运行(或使用标准的树外构建)。它接受两个可选参数:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上注释


make headers_install ARCH=i386 INSTALL_HDR_PATH=/usr

ARCH indicates which architecture to produce headers for, and defaults
to the current architecture. The linux/asm directory of the exported
kernel headers is platform-specific, to see a complete list of supported
architectures use the command:
ARCH 指示为其生成头文件的架构,默认为当前架构。导出内核头文件的 linux/asm 目录是基于特定平台的,要查看支持架构的完整列表,使用以下命令:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

指示在这里翻译有些奇怪,翻译为”表明“吧


ls -d include/asm-* | sed 's/.*-//'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个位置也可以使用markdown语法进行一下调整,是shell语法


INSTALL_HDR_PATH indicates where to install the headers. It defaults to
\"./usr\".
INSTALL_HDR_PATH 指示要安装头文件的位置。默认为 "./usr"。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个句话,可以用逗号”,“代替


一个 'include' 目录会自动被创建在 INSTALL_HDR_PATH 中,头文件会被安装在 INSTALL_HDR_PATH/include 中。

An \'include\' directory is automatically created inside
INSTALL_HDR_PATH and headers are installed in
\'INSTALL_HDR_PATH/include\'.
内核头文件导出基础设施由 David Woodhouse <<dwmw2@infradead.org>> 维护。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个转义符应该是需要的吧,你可以看一下自己仓库的markdown渲染结果

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个comment不用修改,我看渲染的结果正好是使用markdown的语法<>,然后里面的邮箱被搞成了mailto:XXX,这样也挺好的


The kernel header export infrastructure is maintained by David Woodhouse
\<<dwmw2@infradead.org>\>.