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

use*_*ult 4 git fuse git-apply

我有一个基于熔丝的文件系统,为了改进它我需要实现这种方法 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..
Run Code Online (Sandbox Code Playgroud)

这是我用locate命令找不到的,也尝试丢失'a'和'b'前缀并找到了makefile.

  • 注意:已安装libfuse-dev

lar*_*sks 5

这是Linux内核的补丁.如果您还没有Linux内核源代码,则需要从Linux内核源代码的克隆开始:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Run Code Online (Sandbox Code Playgroud)

然后你需要下载补丁.请勿尝试从网络浏览器中复制并粘贴它.您可以从https://patchwork.kernel.org/下载内核补丁; 您引用的补丁似乎是https://patchwork.kernel.org/patch/8182901.mbox这里下载补丁版本,将其保存到名为的文件中 v5-fuse-Add-support-for-passthrough-read-write.patch.然后,您可以通过git am在linux源目录中运行命令来应用此修补程序:

$ cd linux
$ git am /path/to/v5-fuse-Add-support-for-passthrough-read-write.patch
Run Code Online (Sandbox Code Playgroud)

但是看看这个补丁,它是从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".
Run Code Online (Sandbox Code Playgroud)

所以我们需要做的是将内核源代码恢复到2016年的状态.首先,我们需要中止正在进行的git am操作:

$ git am --abort
Run Code Online (Sandbox Code Playgroud)

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

$ git checkout $(git rev-list -1 --before=2016-02-02 --first-parent master)
Run Code Online (Sandbox Code Playgroud)

现在补丁应用得很干净:

$ git am /path/to/v5-fuse-Add-support-for-passthrough-read-write.patch
Applying: fuse: Add support for passthrough read/write
Run Code Online (Sandbox Code Playgroud)

应用补丁后,您需要编译并安装新的内核和模块,这超出了本答案的范围,但是相当详细.

问自己的问题是,鉴于这个补丁已经超过一年了,并且从未被内核接受,你确定你需要它吗?从那时起,是否有其他变化可能会提供类似的改进?