yaffs Fix incorrect handling of deletion flag
[yaffs2.git] / patch-ker.sh
index 93233889cf807dd62da226bd7f70250cab836924..67e7a519487bcf891520ad9f3911990606245c82 100755 (executable)
@@ -2,10 +2,10 @@
 #
 # YAFFS: Yet another FFS. A NAND-flash specific file system.
 #
-# Copyright (C) 2002-2006 Aleph One Ltd.
-# 
+# Copyright (C) 2002-2010 Aleph One Ltd.
+#
 # Created by Charles Manning <charles@aleph1.co.uk>
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 as
 # published by the Free Software Foundation.
 #
 #  Somewhat "inspired by" the mtd patchin script
 #
-#  $Id: patch-ker.sh,v 1.2 2007-02-12 16:55:25 wookey Exp $
 
 VERSION=0
 PATCHLEVEL=0
 SUBLEVEL=0
-LINUXDIR=$1
+COPYORLINK=$1
+LINUXDIR=$2
 
 # To be a Linux directory, it must have a Makefile
 
 
 # Display usage of this script
 usage () {
-       echo "usage:  $0  kernelpath"
+       echo "usage:  $0  c/l kernelpath"
+       echo " if c/l is c, then copy. If l then link"
        exit 1
 }
 
@@ -39,9 +40,19 @@ then
     usage;
 fi
 
+if [ $COPYORLINK = l ]; then
+   CPY="ln -s"
+elif [ $COPYORLINK = c ]; then
+   CPY="cp"
+else
+   echo "unknown copy or link type"
+   usage;
+fi
+
+
 # Check if kerneldir contains a Makefile
-if [ ! -f $LINUXDIR/Makefile ] 
-then 
+if [ ! -f $LINUXDIR/Makefile ]
+then
        echo "Directory $LINUXDIR does not exist or is not a kernel source directory";
        exit 1;
 fi
@@ -53,7 +64,7 @@ SUBLEVEL=`grep -s SUBLEVEL <$LINUXDIR/Makefile | head -n 1 | sed s/'SUBLEVEL = '
 
 # Can we handle this version?
 if [ $VERSION -ne 2  -o $PATCHLEVEL -lt 6  ]
-then 
+then
        echo "Cannot patch kernel version $VERSION.$PATCHLEVEL.$SUBLEVEL, must be 2.6.x or higher"
        exit 1;
 fi
@@ -80,12 +91,12 @@ else
     YAFFS_PATCHED=1
     echo "Updating $KCONFIG"
     mv -f $KCONFIG  $KCONFIGOLD
-    sed -n -e "/JFFS/,99999 ! p" $KCONFIGOLD >$KCONFIG
+    sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 ! p" $KCONFIGOLD >$KCONFIG
     echo "">>$KCONFIG
     echo "# Patched by YAFFS" >>$KCONFIG
     echo "source \"fs/yaffs2/Kconfig\"">>$KCONFIG
     echo "">>$KCONFIG
-    sed -n -e "/JFFS/,99999 p" $KCONFIGOLD >>$KCONFIG
+    sed -n -e "/[Jj][Ff][Ff][Ss]/,99999 p" $KCONFIGOLD >>$KCONFIG
 
    # now do fs/Makefile -- simply add the target at the end
     echo "Updating $MAKEFILE"
@@ -103,7 +114,7 @@ then
    echo "$YAFFSDIR exists, not patching"
 else
    mkdir $LINUXDIR/fs/yaffs2
-   cp Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile
-   cp Kconfig $LINUXDIR/fs/yaffs2
-   cp *.c *.h  $LINUXDIR/fs/yaffs2
+   $CPY  $PWD/Makefile.kernel $LINUXDIR/fs/yaffs2/Makefile
+   $CPY $PWD/Kconfig $LINUXDIR/fs/yaffs2
+   $CPY $PWD/*.c $PWD/*.h  $LINUXDIR/fs/yaffs2
 fi