理解并尝试应用git补丁到fuse文件系统

4
我是一名有用的助手,可以翻译文字。

我有一个基于Fuse的文件系统,为了改进它,我需要实现这种方法 https://lwn.net/Articles/674286/

我知道我应该git apply < patch >,但问题是我不确定这个补丁应该被应用到哪里?

这个补丁试图修改几个文件,例如:

a/fs/fuse/Makefile
a/fs/fuse/dev.c
b/fs/fuse/dev.c
a/fs/fuse/dir.c
b/fs/fuse/dir.c
etc..

我用locate命令找不到它,尝试去掉前缀'a'和'b'只找到了makefile。

  • 注意:已安装libfuse-dev。

如果您的应用程序需要打过补丁的内核,那么它(或其功能区域)只能在已安装了打过补丁的内核的系统上运行。 - Kaz
1个回答

6

这是 Linux 内核的一个补丁。如果您还没有 Linux 内核源码的副本,您需要从头开始进行克隆:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

接下来,您需要下载补丁。 请勿尝试从Web浏览器复制粘贴。 您可以从 https://patchwork.kernel.org/ 下载内核补丁;您所提到的补丁似乎是 https://patchwork.kernel.org/patch/8182901 。 从这里下载补丁的mbox版本,它将保存到一个名为v5-fuse-Add-support-for-passthrough-read-write.patch的文件中。 然后,您可以在Linux源目录中运行git am命令来应用此补丁:

$ cd linux
$ git am /path/to/v5-fuse-Add-support-for-passthrough-read-write.patch

但是看着这个补丁,它是来自2016年2月的,所以它可能不会在当前版本的内核上应用得很干净。而且说“可能”,我的意思是“它不能应用”。上面的命令结果如下:

Applying: fuse: Add support for passthrough read/write
error: patch failed: fs/fuse/Makefile:5
error: fs/fuse/Makefile: patch does not apply
error: patch failed: fs/fuse/file.c:252
error: fs/fuse/file.c: patch does not apply
error: patch failed: fs/fuse/fuse_i.h:531
error: fs/fuse/fuse_i.h: patch does not apply
error: fs/fuse/fuse_passthrough.h: already exists in working directory
error: patch failed: fs/fuse/inode.c:898
error: fs/fuse/inode.c: patch does not apply
error: fs/fuse/passthrough.c: already exists in working directory
error: patch failed: include/uapi/linux/fuse.h:250
error: include/uapi/linux/fuse.h: patch does not apply
Patch failed at 0001 fuse: Add support for passthrough read/write
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

那么我们需要做的是将内核源代码回滚到2016年的状态。首先,我们需要中止正在进行的git am操作:

$ git am --abort

然后将源代码回滚到2016年2月1日左右:

$ git checkout $(git rev-list -1 --before=2016-02-02 --first-parent master)

现在这个补丁能够干净地应用:
$ git am /path/to/v5-fuse-Add-support-for-passthrough-read-write.patch
Applying: fuse: Add support for passthrough read/write

应用此补丁后,您需要编译和安装新的内核和模块,这超出了本回答的范围,但已有相当好的记录。

您需要问自己的问题是,考虑到这个补丁已经有一年之久,并且从未被纳入内核,您确定需要它吗?此后是否有其他更改可以提供类似的改进?


他可能没有2016-02-01的reflogs :-) git rev-list -1 --before=2016-02-02 --first-parent master - jthill
说实话,这是一个相当容易的合并,虽然有一些位掩码的争执,但并不太难。 - jthill
@jthill 是的,这就是我使用本地工作目录而没有检出新副本的结果 :)。已修复。 - larsks
非常感谢,这对我帮助很大!! - userfault

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接