3 # YAFFS: Yet another FFS. A NAND-flash specific file system.
5 # Copyright (C) 2002 Aleph One Ltd.
7 # Created by Charles Manning <charles@aleph1.co.uk>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2 as
11 # published by the Free Software Foundation.
13 # Patch YAFFS into the kernel
15 # args: kpath : Full path to kernel sources to be patched
17 # Somewhat "inspired by" the mtd patchin script
19 # $Id: patch-ker.sh,v 1.1 2005-04-06 01:03:46 charles Exp $
26 # To be a Linux directory, it must have a Makefile
29 # Display usage of this script
31 echo "usage: $0 kernelpath"
42 # Check if kerneldir contains a Makefile
43 if [ ! -f $LINUXDIR/Makefile ]
45 echo "Directory $LINUXDIR does not exist or is not a kernel source directory";
50 VERSION=`grep -s VERSION <$LINUXDIR/Makefile | head -n 1 | sed s/'VERSION = '//`
51 PATCHLEVEL=`grep -s PATCHLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'PATCHLEVEL = '//`
52 SUBLEVEL=`grep -s SUBLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'SUBLEVEL = '//`
54 # Can we handle this version?
55 if [ $VERSION -ne 2 -o $PATCHLEVEL -lt 6 ]
57 echo "Cannot patch kernel version $VERSION.$PATCHLEVEL.$SUBLEVEL, must be 2.6.x or higher"
62 KCONFIG=$LINUXDIR/fs/Kconfig
63 KCONFIGOLD=$LINUXDIR/fs/Kconfig.pre.yaffs
64 YAFFS_PATCHED_STRING=`grep -s yaffs <$KCONFIG | head -n 1`
67 if [ ! -z "$YAFFS_PATCHED_STRING" ]
70 echo "$KCONFIG already mentions YAFFS, so we will not change it"
72 # Change the fs/Kconfig file
73 # Save the old Kconfig
74 # Copy all stuff up to JFFS
75 # Insert some YAFFS stuff
76 # Copy all the rest of the stuff
79 echo "Updating $KCONFIG"
80 mv -f $KCONFIG $KCONFIGOLD
81 sed -n -e "/JFFS/,99999 ! p" $KCONFIGOLD >$KCONFIG
83 echo "# Patched by YAFFS" >>$KCONFIG
84 echo "source \"fs/yaffs/Kconfig\"">>$KCONFIG
86 sed -n -e "/JFFS/,99999 p" $KCONFIGOLD >>$KCONFIG
91 YAFFSDIR=$LINUXDIR/fs/yaffs
95 echo "$YAFFSDIR exists, not patching"
97 ln -fs `pwd`/fs/yaffs $LINUXDIR/fs/yaffs