annotate patch-ker.sh @ 305:1e8f7df58d5e

Rationalise stats gathering for nand access. Does not instrument mounting.
author charles
date Wed, 09 Sep 2009 04:03:01 +0100
parents 6170df5875f3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
1 #!/bin/sh
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
2 #
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
3 # YAFFS: Yet another FFS. A NAND-flash specific file system.
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
4 #
174
7d11ae6795e4 normalise licence headers and attributions
wookey
parents: 52
diff changeset
5 # Copyright (C) 2002-2006 Aleph One Ltd.
205
f95fdc6123fb Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey
parents: 191
diff changeset
6 #
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
7 # Created by Charles Manning <charles@aleph1.co.uk>
205
f95fdc6123fb Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey
parents: 191
diff changeset
8 #
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
9 # This program is free software; you can redistribute it and/or modify
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
10 # it under the terms of the GNU General Public License version 2 as
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
11 # published by the Free Software Foundation.
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
12 #
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
13 # Patch YAFFS into the kernel
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
14 #
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
15 # args: kpath : Full path to kernel sources to be patched
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
16 #
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
17 # Somewhat "inspired by" the mtd patchin script
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
18 #
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
19 # $Id$
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
20
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
21 VERSION=0
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
22 PATCHLEVEL=0
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
23 SUBLEVEL=0
191
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
24 COPYORLINK=$1
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
25 LINUXDIR=$2
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
26
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
27 # To be a Linux directory, it must have a Makefile
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
28
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
29
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
30 # Display usage of this script
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
31 usage () {
191
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
32 echo "usage: $0 c/l kernelpath"
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
33 echo " if c/l is c, then copy. If l then link"
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
34 exit 1
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
35 }
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
36
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
37
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
38
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
39 if [ -z $LINUXDIR ]
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
40 then
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
41 usage;
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
42 fi
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
43
191
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
44 if [ $COPYORLINK = l ]; then
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
45 CPY="ln -s"
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
46 elif [ $COPYORLINK = c ]; then
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
47 CPY="cp"
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
48 else
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
49 echo "unknown copy or link type"
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
50 usage;
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
51 fi
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
52
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
53
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
54 # Check if kerneldir contains a Makefile
205
f95fdc6123fb Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey
parents: 191
diff changeset
55 if [ ! -f $LINUXDIR/Makefile ]
f95fdc6123fb Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey
parents: 191
diff changeset
56 then
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
57 echo "Directory $LINUXDIR does not exist or is not a kernel source directory";
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
58 exit 1;
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
59 fi
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
60
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
61 # Get kernel version
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
62 VERSION=`grep -s VERSION <$LINUXDIR/Makefile | head -n 1 | sed s/'VERSION = '//`
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
63 PATCHLEVEL=`grep -s PATCHLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'PATCHLEVEL = '//`
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
64 SUBLEVEL=`grep -s SUBLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'SUBLEVEL = '//`
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
65
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
66 # Can we handle this version?
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
67 if [ $VERSION -ne 2 -o $PATCHLEVEL -lt 6 ]
205
f95fdc6123fb Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey
parents: 191
diff changeset
68 then
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
69 echo "Cannot patch kernel version $VERSION.$PATCHLEVEL.$SUBLEVEL, must be 2.6.x or higher"
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
70 exit 1;
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
71 fi
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
72
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
73
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
74 KCONFIG=$LINUXDIR/fs/Kconfig
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
75 KCONFIGOLD=$LINUXDIR/fs/Kconfig.pre.yaffs
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
76 YAFFS_PATCHED_STRING=`grep -s yaffs <$KCONFIG | head -n 1`
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
77
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
78 MAKEFILE=$LINUXDIR/fs/Makefile
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
79 MAKEFILEOLD=$LINUXDIR/fs/Makefile.pre.yaffs
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
80
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
81 if [ ! -z "$YAFFS_PATCHED_STRING" ]
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
82 then
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
83 YAFFS_PATCHED=0
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
84 echo "$KCONFIG already mentions YAFFS, so we will not change it"
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
85 else
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
86 # Change the fs/Kconfig file
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
87 # Save the old Kconfig
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
88 # Copy all stuff up to JFFS
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
89 # Insert some YAFFS stuff
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
90 # Copy all the rest of the stuff
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
91
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
92 YAFFS_PATCHED=1
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
93 echo "Updating $KCONFIG"
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
94 mv -f $KCONFIG $KCONFIGOLD
263
6170df5875f3 Change kernel patchin script for 2.6.28 friendliness
charles
parents: 205
diff changeset
95 sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 ! p" $KCONFIGOLD >$KCONFIG
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
96 echo "">>$KCONFIG
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
97 echo "# Patched by YAFFS" >>$KCONFIG
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
98 echo "source \"fs/yaffs2/Kconfig\"">>$KCONFIG
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
99 echo "">>$KCONFIG
263
6170df5875f3 Change kernel patchin script for 2.6.28 friendliness
charles
parents: 205
diff changeset
100 sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 p" $KCONFIGOLD >>$KCONFIG
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
101
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
102 # now do fs/Makefile -- simply add the target at the end
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
103 echo "Updating $MAKEFILE"
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
104 cp -f $MAKEFILE $MAKEFILEOLD
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
105 echo "">>$MAKEFILE
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
106 echo "# Patched by YAFFS" >>$MAKEFILE
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
107 echo "obj-\$(CONFIG_YAFFS_FS) += yaffs2/" >>$MAKEFILE
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
108
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
109 fi
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
110
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
111 YAFFSDIR=$LINUXDIR/fs/yaffs2
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
112
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
113 if [ -e $YAFFSDIR ]
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
114 then
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
115 echo "$YAFFSDIR exists, not patching"
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
116 else
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
117 mkdir $LINUXDIR/fs/yaffs2
191
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
118 $CPY $PWD/Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
119 $CPY $PWD/Kconfig $LINUXDIR/fs/yaffs2
45fbb5342d69 Add a symlink option to the patching script
charles
parents: 174
diff changeset
120 $CPY $PWD/*.c $PWD/*.h $LINUXDIR/fs/yaffs2
52
9fff486c54cb Added files that support the ability to "patchin" yaffs2 into the 2.6
marty
parents:
diff changeset
121 fi