How to apply a patch for Linux source code

For example, I need to apply this patch for my Linux source code: http://git.kernel.org/cgit/linux/kernel/git/davem/net.git/diff/?id=fe82b3300ec9c0dc4ba871f9a58b265aadf4e186

First, I copy this paragraph to a file in local directory: /usr/src/linux-4.3/patch.file.

"

diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
index 67591ae..64afd3d 100644
--- a/net/mpls/mpls_iptunnel.c
+++ b/net/mpls/mpls_iptunnel.c

@@ -54,10 +54,10 @@ int mpls_output(struct net *net, struct sock *sk, struct sk_buff *skb)

unsigned int ttl;

/* Obtain the ttl */

- if (skb->protocol == htons(ETH_P_IP)) {

+ if (dst->ops->family == AF_INET) {

ttl = ip_hdr(skb)->ttl;

rt = (struct rtable *)dst;

- } else if (skb->protocol == htons(ETH_P_IPV6)) {

+ } else if (dst->ops->family == AF_INET6) {

ttl = ipv6_hdr(skb)->hop_limit;

rt6 = (struct rt6_info *)dst;

} else {

"

and then use this command to do the patch:

# patch < patch.file

and then I got the warning info:

"

can‘t find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c
|index 67591ae..64afd3d 100644
|--- a/net/mpls/mpls_iptunnel.c
|+++ b/net/mpls/mpls_iptunnel.c
--------------------------
File to patch:

"

I ignore the warning and input the file name: net/mpls/mpls_iptunnel.c

And then the patch is applied.

时间: 2024-07-30 23:51:25

How to apply a patch for Linux source code的相关文章

Android Branch and master source code merge(patch)

Environment : Android 4.4.2 merge with Android 4.4.3(with other vendors source code) 1.确定你要merge 到 其他分支的版本,并在服务器测获得具体lable 对应的commit 或者 从build 对应的Repo Manifest 中找到要patch 到目标代码的Commit ID <?xml version="1.0" encoding="UTF-8"?> <

How to Create an OCM Response file to Apply a Patch (文档 ID 966023.1)

How to Create an OCM Response file to Apply a Patch in Silent Mode - opatch silent (文档 ID 966023.1) APPLIES TO: Oracle Universal Installer - Version 10.2.0.1 to 11.2.0.4 [Release 10.2 to 11.2]Oracle Database - Enterprise Edition - Version 10.2.0.1 to

Linux source命令

Linux source命令: 通常用法:source filepath 或 . filepath 功能:使当前shell读入路径为filepath的shell文件并依次执行文件中的所有语句,通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录.例如,当我们修改了/etc/profile文件,并想让它立刻生效,而不用重新登录,就可以使用source命令,如source /etc/profile. source命令(从 C Shell 而来)是bash shell的内置命令:点命

[转] linux source命令

source命令用法:source FileName作用:在当前bash环境下读取并执行FileName中的命令.注:该命令通常用命令“.”来替代.如:source .bash_rc 与 . .bash_rc 是等效的.                source命令(从 C Shell 而来)是bash shell的内置命令.点命令,就是个点符号,(从Bourne Shell而来)是source的另一名称.同样的,当前脚本中配置的变量也将作为脚本的环境,source(或点)命令通常用于重新执行

CRC32 Source Code

/* The Quest Operating System * Copyright (C) 2005-2010 Richard West, Boston University * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Softwar

Google Chrome Source Code Download)

Google Chrome 源码下载地址 (Google Chrome Source Code Download) 地址: http://www.xiaohui.com/dev/vccool/internet/google-chrome-source-code-download.htm 1. Google Chrome 源码 SVN 地址:http://src.chromium.org/svn.包含有 Chrome.Gears.Webkit.GCC 等源码以及编译依赖工具.Chrome 浏览器项

MySQL 5.7.18 Source Code Installation

1  下载 1.1 下载网址: www.mysql.com 1.2 下载方法 1.2.1 进入主页后,选择 DOWNLOADS ,这时我们进入了下载页面.如下载的网址所示https://www.mysql.com/downloads/ 1.2.2 进入下载页面后,可以看到很多产品,这里我们将滚动条拉到最下面. 我们要下载的是MySQL Community Edition(GPL) 1.2.3 进入MySQL Community后. selecting operating system选择Sour

How to compile and install Snort from source code on Ubuntu

http://www.tuicool.com/articles/v6j2Ab Snort is by far the most popular open-source network intrusion detection and prevention system (IDS/IPS) for Linux. Snort can conduct detailed traffic analysis, including protocol analysis, packet content search

Classic Source Code Collected

收藏一些经典的源码,持续更新!!! 1.深度学习框架(Deep Learning Framework). A:Caffe (Convolutional Architecture for Fast Feature Embedding)Convolutional 由伯克利大学Yangqing Jia Ph.D开发的开源深度学习的代码. Homepage:http://caffe.berkeleyvision.org/ Paper:Caffe: Convolutional Architecture f