Monday, June 13, 2011

The Ten Minute Guide to diff and patch

Situation one: you are trying to compile a package from source and you discover that somebody has already done the work for you of modifying it slightly to compile on your system. They have made their work available as a "patch", but you're not sure how to make use of it. The answer is that you apply the patch to the original source code with a command line tool called, appropriately, patch.

Situation two: you have downloaded the source code to an open source package and after an hour or so of minor edits, you manage to make it compile on your system. You would like to make your work available to other programmers, or to the authors of the package, without redistributing the entire modified package. Now you are in a situation where you need to create a patch of your own, and the tool you need is diff.

This is a quick guide to diff and patch which will help you in these situations by describing the tools as they are most commonly used. It tells you enough to get started right away. Later, you can learn the ins and outs of diff and patch at your leisure, using the man pages.

Applying patches with patch

To apply a patch to a single file, change to the directory where the file is located and call patch:

patch < foo.patch

These instructions assume the patch is distributed in unified format, which identifies the file the patch should be applied to. If not, you can specify the file on the command line:

patch foo.txt < bar.patch

Applying patches to entire directories (perhaps the more common case) is similar, but you have to be careful about setting a "p level". What this means is that, within patch files, the files to be patched are identified by path names which may be different now that the files are located on your computer rather than on the computer where the patch was created. The p level instructs patch to ignore parts of the path name so that it can identify the files correctly. Most often a p level of one will work, so you use:

patch -p1 < baz.patch

You should change to the top level source directory before running this command. If a patch level of one does not correctly identify any files to patch, inspect the patch file for file names. If you see a name like

and you are working in a directory that contains net/http.c, use

patch -p5 < baz.patch

In general, count up one for each path separator (slash character) that you remove from the beginning of the path, until what's left is a path that exists in your working directory. The count you reach is the p level. To remove a patch, use the -R flag, ie

patch -p5 -R < baz.patch

Creating patches with diff Using diff is simple whether you are working with single files or entire source directories. To create a patch for a single file, use the form:

diff -u original.c new.c > original.patch

To create a patch for an entire source tree, make a copy of the tree:

cp -R original new

Make any changes required in the directory new/. Then create a patch with the following command:

diff -rupN original/ new/ > original.patch

That's all you need to get started with diff and patch. For more information use:

man diff
man patch

Saturday, December 4, 2010

New android mobile

Started using samsung galaxy s android mobile... The best smart phone ... I will write my review soon :)
Published with Blogger-droid v1.6.5

Saturday, September 25, 2010

started with PB42 and PB44 reference board and ath9k

hi ,

started working with atheros reference boards PB42,PB44 boards. Boards comes with 2 and 3 miniPCI slots. ar7161 600 Mhz processor , gb ethernet switch, usb connectors.

Now i started porting ath9k using openWRT. that is done...

the ath9k is not like madwifi. the commands are different.

need to learn configuration, commands, testing methods.

Tuesday, July 27, 2010

VLAN support + madwifi-r3314 + kernel > 2.6.30


after porting i was testing the features of the AP. while testing VLAN was not working with
the kernel while looking at the "netdevice.h" file the net_device structure coding has been changed from the kernel version 2.6.29 onwards.
But madwifi supports only kernels upto 2.6.28

Now its time to add the patches into madwifi code to add support for vlan....

Got the link from the below site

added the patches manually ... finally it started working...... tested upto 8 VAPS with 8 different VLAN tags....

Jul 27 2010

Tuesday, July 6, 2010

Linux Embedded Board Partition confusions


After board bring up (LS-SR71), now need to add the option firmware upgrade through WEB-GUI...
For that i need to use mtd utilities (MTD)
Inside board,
When i give "cat /proc/mtd" i can see 5 partitions
mtd0: "redboot"
mtd1: "kernel"
mtd2: "rootfs"
mtd3: "FIS directory"
mtd4: "RedBoot config"

but when in /dev/ directory there are 7 mtd devices(both character device and block device)
namely mtd0 to mtd6 and mtdblock0 to mtdblock6 ....

I can't write my kernel file in mtd1.
only possible way is writing kernel in mtd2 and rootfs in mtd4 ....

I want some explanation... ??

Thursday, July 1, 2010

UBNT LS-SR71 Board Bring up --- Successfully Done :)


The Next Hardware Board which has AR71xx series Processor. Made it work finally... Lot of problems i faced during the Board Bring up.

Finally its up and running.... Thanks to openwrt....

The Next step i done is ported my own SDK to UBNT LS-SR-71 Board....

Here are Specification

Board - UBNT LS-SR71 - AR7161 with 600Mhz
8 MB Flash (Nor)

Kernel - Linux (openwrt patched)
Wireless - Madwifi r3314 ( Base Code taken from openwrt) but Done some changes to add
support to WDS mode

Now started testing ......

Sunday, April 4, 2010

Routerboard 411 openwrt porting with MADWIFI

successfully ported the openwrt trunk+madwifi wireless driver into RB411 board...

Initially find some problems with wireless interface and Ethernet interface detection.

Finally integrated everything.. and working fine

Kernel 2.6.32
Madwifi r3314