From 11ebeb2065d5a438b3e8f0229637138209202eb1 Mon Sep 17 00:00:00 2001 From: Hao Lee Date: Sun, 25 Dec 2016 19:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E5=85=A8=E6=96=87?= =?UTF-8?q?=E6=A0=A1=E5=AF=B9=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Misc/contribute.md | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/Misc/contribute.md b/Misc/contribute.md index 1a5d32a..a068031 100644 --- a/Misc/contribute.md +++ b/Misc/contribute.md @@ -1,27 +1,29 @@ Linux kernel development +Linux 内核开发 ================================================================================ Introduction +简介 -------------------------------------------------------------------------------- As you already may know, I've started a series of [blog posts](http://0xax.github.io/categories/assembly/) about assembler programming for `x86_64` architecture in the last year. I have never written a line of low-level code before this moment, except for a couple of toy `Hello World` examples in university. It was a long time ago and, as I already said, I didn't write low-level code at all. Some time ago I became interested in such things. I understood that I can write programs, but didn't actually understand how my program is arranged. -正如你所知,我从去年开始写了一系列关于 `x86_64` 架构汇编语言程序设计的博文。除了大学期间写过一些 `Hello World` 这样的玩具例程之外,我从来没写过哪怕一行的底层代码。那些例程也是很久以前的事情了,就像我刚才说的,我几乎完全没有写过底层代码。直到不久前,我才开始对这些事情感兴趣,因为我意识到我虽然可以写出程序,但是我却不知道我的程序是怎样被组织运行的。 +如你所知,我从去年开始写了一系列关于 `x86_64` 架构汇编语言程序设计的博文。除了大学期间写过一些 `Hello World` 这样的玩具例程之外,我从来没写过哪怕一行的底层代码。那些例程也是很久以前的事情了,就像我刚才说的,我几乎完全没有写过底层代码。直到不久前,我才开始对这些事情感兴趣,因为我意识到我虽然可以写出程序,但是我却不知道我的程序是怎样被组织运行的。 After writing some assembler code I began to understand how my program looks after compilation, **approximately**. But anyway, I didn't understand many other things. For example: what occurs when the `syscall` instruction is executed in my assembler, what occurs when the `printf` function starts to work or how can my program talk with other computers via network. [Assembler](https://en.wikipedia.org/wiki/Assembly_language#Assembler) programming language didn't give me answers to my questions and I decided to go deeper in my research. I started to learn from the source code of the Linux kernel and tried to understand the things that I'm interested in. The source code of the Linux kernel didn't give me the answers to **all** of my questions, but now my knowledge about the Linux kernel and the processes around it is much better. -在写了一些汇编代码之后,我开始**大致**了解了程序在编译之后会变成什么样子。尽管如此,还是有很多其他的东西我不能够理解。例如:当 `syscall` 指令在我的汇编程序内执行时以及当 `printf` 函数开始工作时究竟发生了什么,还有,我的程序如何通过网络与其他计算机进行通信。[汇编](https://en.wikipedia.org/wiki/Assembly_language#Assembler)语言并没有为这些问题带来答案,于是我决定做一番深入研究。我开始学习 Linux 内核的源代码,并且尝试着理解那些让我感兴趣的东西。然而 Linux 内核源代码也没有解答我**所有的**问题,不过我自身关于 Linux 内核及其外围流程的知识掌握的更好了。 +在写了一些汇编代码之后,我开始**大致**了解了程序在编译之后会变成什么样子。尽管如此,还是有很多其他的东西我不能够理解。例如:当 `syscall` 指令在我的汇编程序内执行时究竟发生了什么,当 `printf` 函数开始工作时又发生了什么,还有,我的程序是如何通过网络与其他计算机进行通信的。[汇编](https://en.wikipedia.org/wiki/Assembly_language#Assembler)语言并没有为这些问题带来答案,于是我决定做一番深入研究。我开始学习 Linux 内核的源代码,并且尝试着理解那些让我感兴趣的东西。然而 Linux 内核源代码也没有解答我**所有的**问题,不过我自身关于 Linux 内核及其外围流程的知识确实掌握的更好了。 I'm writing this part nine and a half months after I've started to learn from the source code of the Linux kernel and published the first [part](https://0xax.gitbooks.io/linux-insides/content/Booting/linux-bootstrap-1.html) of this book. Now it contains forty parts and it is not the end. I decided to write this series about the Linux kernel mostly for myself. As you know the Linux kernel is very huge piece of code and it is easy to forget what does this or that part of the Linux kernel mean and how does it implement something. But soon the [linux-insides](https://github.com/0xAX/linux-insides) repo became popular and after nine months it has `9096` stars: -在我开始学习 Linux 内核的九个半月之后,我写了这部分内容,并且发布了本书的[第一部分](https://0xax.gitbooks.io/linux-insides/content/Booting/linux-bootstrap-1.html)。到现在为止,本书共包括了四个部分,而这并不是终点。我决定写这么一系列关于 Linux 内核的文章其实更多的是为了我自己。你也知道,Linux 内核的代码量极其巨大,另外还非常容易忘记这一块或那一块内核代码做了什么或者一些东西是怎么实现的。但是 [linux-insides](https://github.com/0xAX/linux-insides) 很快就变得越来越火了,并且在九个月后积攒了 `9096` 个星星。 +在我开始学习 Linux 内核的九个半月之后,我写了这部分内容,并且发布了本书的[第一部分](https://0xax.gitbooks.io/linux-insides/content/Booting/linux-bootstrap-1.html)。到现在为止,本书共包括了四个部分,而这并不是终点。我之所以写这一系列关于 Linux 内核的文章其实更多的是为了我自己。你也知道,Linux 内核的代码量极其巨大,另外还非常容易忘记这一块或那一块内核代码做了什么,或者忘记某些东西是怎么实现的。出乎意料的是 [linux-insides](https://github.com/0xAX/linux-insides) 很快就变得越来越火,并且在九个月后积攒了 `9096` 个星星。 ![github](http://s2.postimg.org/jjb3s4frt/stars.png) It seems that people are interested in the insides of the Linux kernel. Besides this, in all the time that I have been writing `linux-insides`, I have received many questions from different people about how to begin contributing to the Linux kernel. Generally people are interested in contributing to open source projects and the Linux kernel is not an exception: -看起来人们对 Linux 内核的内在机制非常的感兴趣。除此之外,在我写 `linux-insides` 的这段时间里,我收到了很多人发来的问题,这些问题大都是关于如何开始向 Linux 内核贡献代码。通常来说,人们很有兴趣为开源项目做贡献,Linux 内核也不例外。 +看起来人们对 Linux 内核的内在机制非常的感兴趣。除此之外,在我写 `linux-insides` 的这段时间里,我收到了很多人发来的问题,这些问题大都是关于如何开始向 Linux 内核贡献代码。通常来说,人们是很有兴趣为开源项目做贡献的,Linux 内核也不例外。 ![google-linux](http://s4.postimg.org/yg9z5zx0d/google_linux.png) So, it seems that people are interested in the Linux kernel development process. I thought it would be strange if a book about the Linux kernel would not contain a part describing how to take a part in the Linux kernel development and that's why I decided to write it. You will not find information about why you should be interested in contributing to the Linux kernel in this part. But if you are interested how to start with Linux kernel development, this part is for you. -这么看来人们看起来对 Linux 内核的开发流程非常感兴趣。我认为如果这么一本关于 Linux 内核的书却不包括一部分来讲讲如何参与 Linux 内核开发的话,这将会变得非常奇怪。这就是我为什么决定写这篇文章。在该部分,你不会看到关于为什么你应该对贡献 Linux 内核感兴趣的信息。但是,如果你对如何参与 Linux 内核开发有兴趣的话,这部分就是为你而作。 +这么看起来大家对 Linux 内核的开发流程非常感兴趣。我认为如果这么一本关于 Linux 内核的书却不包括一部分来讲讲如何参与 Linux 内核开发的话,这将会变得非常奇怪。这就是我为什么决定写这篇文章。在该部分,你不会看到为什么你应该对贡献 Linux 内核感兴趣,但是,如果你对参与 Linux 内核开发有兴趣的话,那这部分就是为你而作。 Let's start. 让我们开始吧 @@ -39,7 +41,7 @@ First of all, let's see how to get, build, and run the Linux kernel. You can run * 在真实的硬件上运行 Linux 内核。 I'll provide descriptions for both methods. Before we start doing anything with the Linux kernel, we need to get it. There are a couple of ways to do this depending on your purpose. If you just want to update the current version of the Linux kernel on your computer, you can use the instructions specific to your Linux [distro](https://en.wikipedia.org/wiki/Linux_distribution). -我会对这两种方式都展开描述。在我们开始对 Linux 内核做些什么之前,我们首先需要先获取它。根据你目的的不同,有两种方式可以做到这一点。如果你只是想更新一下你电脑上的 Linux 内核版本,那么你可以使用特定于你的 [Linux 发行版](https://en.wikipedia.org/wiki/Linux_distribution) 的命令。 +我会对这两种方式都展开描述。在我们开始对 Linux 内核做些什么之前,我们首先需要先获取它。根据你目的的不同,有两种方式可以做到这一点。如果你只是想更新一下你电脑上的 Linux 内核版本,那么你可以使用特定于你 [Linux 发行版](https://en.wikipedia.org/wiki/Linux_distribution) 的命令。 In the first case you just need to download new version of the Linux kernel with the [package manager](https://en.wikipedia.org/wiki/Package_manager). For example, to upgrade the version of the Linux kernel to `4.1` for [Ubuntu (Vivid Vervet)](http://releases.ubuntu.com/15.04/), you will just need to execute the following commands: 在这种情况下,你只需要使用 [软件包管理器](https://en.wikipedia.org/wiki/Package_manager) 下载新版本的 Linux 内核。例如,为了将 [Ubuntu (Vivid Vervet)](http://releases.ubuntu.com/15.04/) 系统的 Linux 内核更新至 `4.1`,你只需要执行以下命令: @@ -64,7 +66,7 @@ $ sudo apt-get install linux-headers-${version} linux-headers-${version}-generic ``` and reboot your system. After the reboot you will see the new kernel in the [grub](https://en.wikipedia.org/wiki/GNU_GRUB) menu. -然后重启你的系统。重启完成后,你将在 [grub](https://en.wikipedia.org/wiki/GNU_GRUB) 菜单中看到新的内核。 +最后重启你的系统。重启完成后,你将在 [grub](https://en.wikipedia.org/wiki/GNU_GRUB) 菜单中看到新的内核。 In the other way if you are interested in the Linux kernel development, you will need to get the source code of the Linux kernel. You can find it on the [kernel.org](https://kernel.org/) website and download an archive with the Linux kernel source code. Actually the Linux kernel development process is fully built around `git` [version control system](https://en.wikipedia.org/wiki/Version_control). So you can get it with `git` from the `kernel.org`: 另一方面,如果你对 Linux 内核开发感兴趣,那么你就需要获得 Linux 内核的源代码。你可以在 [kernel.org](https://kernel.org/) 网站上找到它并且下载一个包含了 Linux 内核源代码的归档文件。实际上,Linux 内核的开发流程完全建立在 `git` [版本控制系统](https://en.wikipedia.org/wiki/Version_control) 之上,所以你需要通过 `git` 来从 `kernel.org` 上获取内核源代码: @@ -124,7 +126,7 @@ $ cat /proc/config.gz | gunzip > ~/dev/linux/.config ``` If you are not satisfied with the standard kernel configuration that is provided by the maintainers of your distro, you can configure the Linux kernel manually. There are a couple of ways to do it. The Linux kernel root [Makefile](https://github.com/torvalds/linux/blob/master/Makefile) provides a set of targets that allows you to configure it. For example `menuconfig` provides a menu-driven interface for the kernel configuration: -如果你对发行版维护者提供的标准内核配置文件并不满意,你也可以手动配置 Linux 内核,有两种方式可以做到这一点。Linux 内核的根 [Makefile](https://github.com/torvalds/linux/blob/master/Makefile) 文件提供了一系列允许你配置的目标选项。例如 `menuconfig` 为内核配置提供了一个菜单界面。 +如果你对发行版维护者提供的标准内核配置文件并不满意,你也可以手动配置 Linux 内核,有两种方式可以做到这一点。Linux 内核的根 [Makefile](https://github.com/torvalds/linux/blob/master/Makefile) 文件提供了一系列可配置的目标选项。例如 `menuconfig` 为内核配置提供了一个菜单界面。 ![menuconfig](http://s21.postimg.org/zcz48p7yf/menucnonfig.png) @@ -141,7 +143,7 @@ The `allnoconfig`, `allyesconfig` and `allmodconfig` arguments allow you to gene ![nconfig](http://s29.postimg.org/hpghikp4n/nconfig.png) And even `randconfig` to generate random Linux kernel configuration file. I will not write about how to configure the Linux kernel or which options to enable because it makes no sense to do so for two reasons: First of all I do not know your hardware and second, if you know your hardware, the only remaining task is to find out how to use programs for kernel configuration, and all of them are pretty simple to use. -`randconfig` 参数甚至可以随机地生成 Linux 内核配置文件。我不会讨论如何去配置 Linux 内核或启用哪个选项,因为没有必要这么做:首先,我不知道你的硬件配置;其次,如果我知道了你的硬件配置,那么剩下的问题就是搞清楚如何使用程序生成内核配置,而这些程序的使用都是非常容易得。 +`randconfig` 参数甚至可以随机地生成 Linux 内核配置文件。我不会讨论如何去配置 Linux 内核或启用哪个选项,因为没有必要这么做:首先,我不知道你的硬件配置;其次,如果我知道了你的硬件配置,那么剩下的问题就是搞清楚如何使用程序生成内核配置,而这些程序的使用都是非常容易的。 OK, we now have the source code of the Linux kernel and configured it. The next step is the compilation of the Linux kernel. The simplest way to compile Linux kernel is to just execute: 好了,我们现在有了 Linux 内核的源代码并且完成了配置。下一步就是编译 Linux 内核了。最简单的编译 Linux 内核的方式就是执行以下命令: @@ -276,7 +278,7 @@ Busybox Settings ``` After this we exit from the `busysbox` configuration menu and execute following commands for building and installation of it: -在此之后,我们从 `busysbox` 的配置菜单退出去,然后执行下面的命令来构建并安装它: +之后,我们从 `busysbox` 的配置菜单退出去,然后执行下面的命令来构建并安装它: ``` $ make -j4 @@ -307,14 +309,14 @@ exec /bin/sh ``` Now we can create an archive that will be our `initrd`: -现在,我们可以创建一个归档文件,这就是我们的 `initrd`: +最后,我们创建一个归档文件,这就是我们的 `initrd` 了: ``` $ find . -print0 | cpio --null -ov --format=newc | gzip -9 > ~/dev/initrd_x86_64.gz ``` We can now run our kernel in the virtual machine. As I already wrote I prefer [qemu](https://en.wikipedia.org/wiki/QEMU) for this. We can run our kernel with the following command: -我们现在可以在虚拟机里运行我们的内核了。就像我之前写过的,我偏向于使用 [qemu](https://en.wikipedia.org/wiki/QEMU) 来完成这些工作,可以用下面的命令运行我们的 Linux 内核: +我们现在可以在虚拟机里运行内核了。就像我之前写过的,我偏向于使用 [qemu](https://en.wikipedia.org/wiki/QEMU) 来完成这些工作,下面的命令可以用来运行我们的 Linux 内核: ``` $ qemu-system-x86_64 -snapshot -m 8GB -serial stdio -kernel ~/dev/linux/arch/x86_64/boot/bzImage -initrd ~/dev/initrd_x86_64.gz -append "root=/dev/sda1 ignore_loglevel" @@ -323,7 +325,7 @@ $ qemu-system-x86_64 -snapshot -m 8GB -serial stdio -kernel ~/dev/linux/arch/x86 ![qemu](http://s22.postimg.org/b8ttyigup/qemu.png) From now we can run the Linux kernel in the virtual machine and this means that we can begin to change and test the kernel. -从现在起,我们就可以在虚拟机内运行 Linux 内核了,这意味着我们可以开始修改和测试内核了。 +从现在起,我们就可以在虚拟机内运行 Linux 内核了,这意味着我们可以开始对内核进行修改和测试了。 Consider using [ivandaviov/minimal](https://github.com/ivandavidov/minimal) to automate the process of generating initrd. 除了上面的手动过程之外,还可以考虑使用 [ivandaviov/minimal](https://github.com/ivandavidov/minimal) 来自动生成 `initrd`。 @@ -333,7 +335,7 @@ Linux 内核开发入门 --------------------------------------------------------------------------------- The main point of this paragraph is to answer two questions: What to do and what not to do before sending your first patch to the Linux kernel. Please, do not confuse this `to do` with `todo`. I have no answer what you can fix in the Linux kernel. I just want to tell you my workflow during experimenting with the Linux kernel source code. -这部分的核心内容主要回答了两个问题:在你发送第一个 Linux 内核补丁之前你应该做什么 (`to do`) 和不能做什么 (`not to do`)。请千万不要把应该做的事 (`to do`) 和待办事项 (`todo`) 搞混了。我无法回答你能为 Linux 内核修复什么问题,我只是想告诉你我拿 Linux 内核源代码做实验的流程。 +这部分的核心内容主要回答了两个问题:在你发送第一个 Linux 内核补丁之前你应该做什么 (`to do`) 和不能做什么 (`not to do`)。请千万不要把应该做的事 (`to do`) 和待办事项 (`todo`) 搞混了。我无法回答你能为 Linux 内核修复什么问题,我只是想告诉你我拿 Linux 内核源代码做实验的过程。 First of all I pull the latest updates from Linus's repo with the following commands: 首先,我需要使用以下命令从 Linus 的仓库中拉取最新的更新: @@ -344,7 +346,7 @@ $ git pull upstream master ``` After this my local repository with the Linux kernel source code is synced with the [mainline](https://github.com/torvalds/linux) repository. Now we can make some changes in the source code. As I already wrote, I have no advice for you where you can start and what `TODO` in the Linux kernel. But the best place for newbies is `staging` tree. In other words the set of drivers from the [drivers/staging](https://github.com/torvalds/linux/tree/master/drivers/staging). The maintainer of the `staging` tree is [Greg Kroah-Hartman](https://en.wikipedia.org/wiki/Greg_Kroah-Hartman) and the `staging` tree is that place where your trivial patch can be accepted. Let's look on a simple example that describes how to generate patch, check it and send to the [Linux kernel mail listing](https://lkml.org/). -在这之后,我的本地 Linux 内核源代码仓库已经和 [主线](https://github.com/torvalds/linux) 仓库同步了。现在我们可以在源代码上做些修改了。就像我之前写的,关于从哪开始修改或者可以做些什么,我并不能给你建议。不过,对于新手来说最好的地方就是 `staging` 源码树,也就是 [drivers/staging](https://github.com/torvalds/linux/tree/master/drivers/staging) 上的驱动集合。`staging` 源码树的主要维护者是 [Greg Kroah-Hartman](https://en.wikipedia.org/wiki/Greg_Kroah-Hartman),该源码树正是你的琐碎补丁可以被接受的地方。让我们看一个简单的例子,该例子描述了如何生成补丁、检查补丁以及如何将补丁发送到 [Linux 内核邮件列表](https://lkml.org/)。 +在这之后,我的本地 Linux 内核源代码仓库已经和 [主线](https://github.com/torvalds/linux) 仓库同步了。现在我们可以在源代码上做些修改了。就像我之前写的,关于从哪开始修改或者可以做些什么,我并不能给你太多建议。不过,对于新手来说最好的地方就是 `staging` 源码树,也就是 [drivers/staging](https://github.com/torvalds/linux/tree/master/drivers/staging) 上的驱动集合。`staging` 源码树的主要维护者是 [Greg Kroah-Hartman](https://en.wikipedia.org/wiki/Greg_Kroah-Hartman),该源码树正是你的琐碎补丁可以被接受的地方。让我们看一个简单的例子,该例子描述了如何生成补丁、检查补丁以及如何将补丁发送到 [Linux 内核邮件列表](https://lkml.org/)。 If we look in the driver for the [Digi International EPCA PCI](https://github.com/torvalds/linux/tree/master/drivers/staging/dgap) based devices, we will see the `dgap_sindex` function on line 295: 如果我们查看一下为 [Digi International EPCA PCI](https://github.com/torvalds/linux/tree/master/drivers/staging/dgap) 基础设备所写的驱动程序,在295行我们将会看到 `dgap_sindex` 函数: @@ -379,7 +381,7 @@ $ git checkout -b "dgap-remove-dgap_sindex" ``` And now we can replace the `dgap_sindex` with the `strpbrk`. After we did all changes we need to recompile the Linux kernel or just [dgap](https://github.com/torvalds/linux/tree/master/drivers/staging/dgap) directory. Do not forget to enable this driver in the kernel configuration. You can find it in the: -然后,我们可以将 `dgap_sindex` 函数替换为 `strpbrk`。做完这些修改之后,我们需要重新编译 Linux 内核或者只重新编译 [dgap](https://github.com/torvalds/linux/tree/master/drivers/staging/dgap) 目录。不要忘了在内核配置文件中启用这个驱动,你可以在如下位置找到该驱动: +然后,我们可以将 `dgap_sindex` 函数替换为 `strpbrk`。做完这些修改之后,我们需要重新编译 Linux 内核或者只重编译 [dgap](https://github.com/torvalds/linux/tree/master/drivers/staging/dgap) 目录。不要忘了在内核配置文件中启用这个驱动,你可以在如下位置找到该驱动: ``` Device Drivers @@ -427,14 +429,14 @@ $ git format-patch master ``` We've passed name of the branch (`master` in this case) to the `format-patch` command that will generate a patch with the last changes that are in the `dgap-remove-dgap_sindex` branch and not are in the `master` branch. As you can note, the `format-patch` command generates file that contains last changes and has name that is based on the commit short description. If you want to generate a patch with the custom name, you can use `--stdout` option: -我们把分支名字 (这里是`master`) 传递给 `format-patch` 命令,该命令会根据那些包括在 `dgap-remove-dgap_sindex` 分支但不在 `master` 分支的最新改动来生成补丁。你会发现, `format-patch` 命令生成的文件包含了最新所做的修改,该文件的名字是基于提交信息的简短描述来生成的。如果你想按照自定义的文件名来生成补丁,你可以使用 `--stdout` 选项: +我们把分支名字 (这里是`master`) 传递给 `format-patch` 命令,该命令会根据那些包括在 `dgap-remove-dgap_sindex` 分支但不在 `master` 分支的最新改动来生成补丁。你会发现, `format-patch` 命令生成的文件包含了最新所做的修改,该文件的名字是基于提交信息的简述来生成的。如果你想按照自定义的文件名来生成补丁,你可以使用 `--stdout` 选项: ``` $ git format-patch master --stdout > dgap-patch-1.patch ``` The last step after we have generated our patch is to send it to the Linux kernel mailing list. Of course, you can use any email client, `git` provides a special command for this: `git send-email`. Before you send your patch, you need to know where to send it. Yes, you can just send it to the Linux kernel mailing list address which is `linux-kernel@vger.kernel.org`, but it is very likely that the patch will be ignored, because of the large flow of messages. The better choice would be to send the patch to the maintainers of the subsystem where you have made changes. To find the names of these maintainers use the `get_maintainer.pl` script. All you need to do is pass the file or directory where you wrote code. -最后一步就是在我们生成补丁之后将之发送到 Linux 内核邮件列表。当然,你可以使用任意的邮件客户端,不过 `git` 为此提供了一个专门的命令:`git send-email`。在发送补丁之前,你需要知道发到哪里。虽然你可以直接把它发送到 `linux-kernel@vger.kernel.org` 这个 Linux 内核邮件列表,但是这很可能让你的补丁因为巨大的消息流而被忽略掉。最好的选择是将补丁发送到你的修改所属子系统的维护者那里。你可以使用 `get_maintainer.pl` 这个脚本来找到这些维护者的名字。你所需要做的就是将你代码所在的文件或目录作为参数传递给脚本。 +最后一步就是在我们生成补丁之后将之发送到 Linux 内核邮件列表。当然,你可以使用任意的邮件客户端,不过 `git` 为此提供了一个专门的命令:`git send-email`。在发送补丁之前,你需要知道发到哪里。虽然你可以直接把它发送到 `linux-kernel@vger.kernel.org` 这个邮件列表,但这很可能让你的补丁因为巨大的消息流而被忽略掉。最好的选择是将补丁发送到你的修改所属子系统的维护者那里。你可以使用 `get_maintainer.pl` 这个脚本来找到这些维护者的名字。你所需要做的就是将你代码所在的文件或目录作为参数传递给脚本。 ``` $ ./scripts/get_maintainer.pl -f drivers/staging/dgap/dgap.c @@ -503,7 +505,7 @@ Also you can see problematic places with the help of the `git diff`: * [Linus doesn't accept github pull requests](https://github.com/torvalds/linux/pull/17#issuecomment-5654674) * If your change consists from some different and unrelated changes, you need to split the changes via separate commits. The `git format-patch` command will generate patches for each commit and the subject of each patch will contain a `vN` prefix where the `N` is the number of the patch. If you are planning to send a series of patches it will be helpful to pass the `--cover-letter` option to the `git format-patch` command. This will generate an additional file that will contain the cover letter that you can use to describe what your patchset changes. It is also a good idea to use the `--in-reply-to` option in the `git send-email` command. This option allows you to send your patch series in reply to your cover message. The structure of the your patch will look like this for a maintainer: -* 如果你的修改是由一些不同的且不相关的改动所组成的,你需要通过分离提交来切分修改。`git format-patch` 命令将会为每个提交生成补丁,每个补丁的标题会包含一个 `vN` 前缀,其中 `N` 是补丁的编号。如果你打算发送一系列补丁,也许给 `git format-patch` 命令传递 `--cover-letter` 选项会对此很有帮助。这会生成一个附加文件,该文件包括的附函可以用来描述你的补丁集所做的改动。在 `git send-email` 命令中使用 `--in-reply-to` 选项也是一个好主意,该选项允许你将补丁集作为对附函的回复发送出去。对于维护者来说,你补丁集的结构看起来就像下面这样: +* 如果你的修改是由一些不同的且不相关的改动所组成的,你需要通过分离提交来切分修改。`git format-patch` 命令将会为每个提交生成一个补丁,每个补丁的标题会包含一个 `vN` 前缀,其中 `N` 是补丁的编号。如果你打算发送一系列补丁,也许给 `git format-patch` 命令传递 `--cover-letter` 选项会对此很有帮助。这会生成一个附加文件,该文件包括的附函可以用来描述你的补丁集所做的改动。在 `git send-email` 命令中使用 `--in-reply-to` 选项也是一个好主意,该选项允许你将补丁集作为对附函的回复发送出去。对于维护者来说,你补丁集的结构看起来就像下面这样: ``` |--> cover letter @@ -521,10 +523,10 @@ It's important that your email be in the [plain text](https://en.wikipedia.org/w * 如果你发完补丁之后没有得到立即答复,请不要惊讶,因为维护者们都是很忙的。 * The [scripts](https://github.com/torvalds/linux/tree/master/scripts) directory contains many different useful scripts that are related to Linux kernel development. We already saw two scripts from this directory: the `checkpatch.pl` and the `get_maintainer.pl` scripts. Outside of those scripts, you can find the [stackusage](https://github.com/torvalds/linux/blob/master/scripts/stackusage) script that will print usage of the stack, [extract-vmlinux](https://github.com/torvalds/linux/blob/master/scripts/extract-vmlinux) for extracting an uncompressed kernel image, and many others. Outside of the `scripts` directory you can find some very useful [scripts](https://github.com/lorenzo-stoakes/kernel-scripts) by [Lorenzo Stoakes](https://twitter.com/ljsloz) for kernel development. -* [scripts](https://github.com/torvalds/linux/tree/master/scripts) 目录包含了很多对 Linux 内核开发有用的脚本。我们已经看过此目录中的两个脚本了:`checkpatch.pl` 和 `get_maintainer.pl`。除此之外,你还可以找到 [stackusage](https://github.com/torvalds/linux/blob/master/scripts/stackusage) 脚本,它可以打印栈的使用情况,[extract-vmlinux](https://github.com/torvalds/linux/blob/master/scripts/extract-vmlinux) 脚本可以提取出未经压缩的内镜镜像,还有很多其他的脚本。在 `scripts` 目录之外,你也会发现很多有用的 [脚本](https://github.com/lorenzo-stoakes/kernel-scripts),这些脚本是 [Lorenzo Stoakes](https://twitter.com/ljsloz) 为内核开发而编写的。 +* [scripts](https://github.com/torvalds/linux/tree/master/scripts) 目录包含了很多对 Linux 内核开发有用的脚本。我们已经看过此目录中的两个脚本了:`checkpatch.pl` 和 `get_maintainer.pl`。除此之外,你还可以找到 [stackusage](https://github.com/torvalds/linux/blob/master/scripts/stackusage) 脚本,它可以打印栈的使用情况,[extract-vmlinux](https://github.com/torvalds/linux/blob/master/scripts/extract-vmlinux) 脚本可以提取出未经压缩的内镜镜像,还有很多其他的脚本。在 `scripts` 目录之外,你也会发现很多有用的[脚本](https://github.com/lorenzo-stoakes/kernel-scripts),这些脚本是 [Lorenzo Stoakes](https://twitter.com/ljsloz) 为内核开发而编写的。 * Subscribe to the Linux kernel mailing list. There are a large number of letters every day on `lkml`, but it is very useful to read them and understand things such as the current state of the Linux kernel. Other than `lkml` there are [set](http://vger.kernel.org/vger-lists.html) mailing listings which are related to the different Linux kernel subsystems. -* 订阅 Linux 内核邮件列表。`lkml` 列表中每天都会有大量的信件,但是阅读它们并了解一些类似于 Linux 内核目前开发状态的内容是很有帮助的。除了 `lkml` 之外,还有 [一些](http://vger.kernel.org/vger-lists.html) 其他的邮件列表,它们分别对应于不同的 Linux 内核子系统。 +* 订阅 Linux 内核邮件列表。`lkml` 列表中每天都会有大量的信件,但是阅读它们并了解一些类似于 Linux 内核目前开发状态的内容是很有帮助的。除了 `lkml` 之外,还有[一些](http://vger.kernel.org/vger-lists.html)其他的邮件列表,它们分别对应于不同的 Linux 内核子系统。 * If your patch is not accepted the first time and you receive feedback from Linux kernel developers, make your changes and resend the patch with the `[PATCH vN]` prefix (where `N` is the number of patch version). For example: * 如果你发的补丁第一次没有被接受,你就会收到 Linux 内核开发者的反馈。请做一些修改然后以 `[PATCH vN]`(`N` 是补丁版本号) 为前缀重新发送补丁,例如: