码迷,mamicode.com
首页 > 移动开发 > 详细

How to apply a patch for Linux source code

时间:2016-04-26 17:19:17      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

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.

How to apply a patch for Linux source code

标签:

原文地址:http://www.cnblogs.com/dxh1231/p/5435640.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!