Syntax for patch files

Source: Internet
Author: User
Tags diff
parsing Linux Patch

The main purpose of patch is to patch the code, fix known bugs, or debug the problematic code as a debugging tool, identify the problem, and verify the result of the correction.
Patch process is divided into three major steps: one is to compare the new and old code with diff tools, generate Patch files, and the second is to use the Patch command to merge Patch files into the original code; Third, check for files that cannot be Patch, modify or select whether to do Patch. Patch can be compiled directly after the end of the play.
The main commands patch correspond to are two, diff and patch. As for inspection results, use the LS command or find command in a Linux environment to view files with or without REJ types.
The common practice is to add the patch command to the makefile, do the patch of the code in the compilation process, and compile the code. structure of the patch file

Patch Head
The patch header is a two-line beginning with-/+++, used to indicate the file to be patched. -the beginning represents the old file, and the +++ begins with the new file.
Multiple patches in a patch file
A patch file may contain many sections that start with-/+++, and each section is used to make a patch. So you can include multiple patches in a patch file.
Block
Block is the place to modify in the patch. It usually starts and ends with something that doesn't have to be modified. They are only used to indicate the location to be modified. They usually start with @@ 开始 ending with the start of another block or a new patch header.
Indentation of Blocks
Blocks are indented, and this column is used to indicate whether the line is to be added or deleted.
The first column of the Block
The + number indicates that the line is to be added.
-the number indicates that the line is to be deleted.
There is no plus sign and no minus sign indicates that this is only referenced and does not need to be modified for positioning.

Diff--git A/include/linux/fb.h B/include/linux/fb.h # "Here represents a small section of the start" index c10163b. 1296AF4 100644---a/include/linux/fb.h # # (generally refers to the original file, a is the corresponding directory of the original file) +++ B/include/linux/fb.h # (generally refers to the changed file, B is its directory name, So you can look directly at their lower directories to find) @@ -403,6 +403,7 @@ -403,6 fb_cursor {# #第一段不同的地方, the old file starts with 403 lines, a total of 6 rows, and the new file starts with 403 lines, a total of 7 lines #include <linux/no tifier.h> #include <linux/list.h> #include <linux/backlight.h> + #include <linux/slab.h> # # "+ indicates increased
One line "#include <asm/io.h> struct vm_area_struct;   @@ -862,10 +863,22 @@ -862,10 fb_info {# # "@@ -862,10 862 ... This indicates how many rows should be on the file "/We need the PCI or similiar aperture base/size not smem_start/size as Smem_start might just
Be a object allocated inside the aperture so could not actually overlap * * resource_size_t aperture_base;   -resource_size_t aperture_size; # # "-Indicates delete row" + struct Apertures_struct {+ unsigned int count; + struct Aperture {+ Resource_size_
T base;
+ resource_size_t size;       +} Ranges[0];
 +} *apertures;

}; +static inline struct apertures_struct *alloc_apertures (unsigned int max_num) {+ struct apertures_struct *a = Kzalloc (s
izeof (struct apertures_struct) + + max_num * sizeof (struct aperture), gfp_kernel);
+ A->count = max_num;
+ Return A; +} + #ifdef MODULE #define Fbinfo_default fbinfo_module #else

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.