x-load git: add patch for beagleboard to fix u-boot in fat32 partitions
authorKoen Kooi <koen@openembedded.org>
Tue, 16 Nov 2010 15:11:50 +0000 (16:11 +0100)
committerKoen Kooi <koen@openembedded.org>
Tue, 16 Nov 2010 15:12:29 +0000 (16:12 +0100)
recipes/x-load/x-load-git/beagleboard/0001-Fix-reading-FAT32-root-dirs-that-span-1-cluster.patch [new file with mode: 0644]
recipes/x-load/x-load_git.bb

diff --git a/recipes/x-load/x-load-git/beagleboard/0001-Fix-reading-FAT32-root-dirs-that-span-1-cluster.patch b/recipes/x-load/x-load-git/beagleboard/0001-Fix-reading-FAT32-root-dirs-that-span-1-cluster.patch
new file mode 100644 (file)
index 0000000..02787c3
--- /dev/null
@@ -0,0 +1,83 @@
+From e710d42095e5abb7f392ed1c3a0927b37a72a833 Mon Sep 17 00:00:00 2001
+From: Nick Gasson <nick@nickg.me.uk>
+Date: Sat, 13 Nov 2010 18:57:35 +0000
+Subject: [PATCH] Fix reading FAT32 root dirs that span >1 cluster
+
+Unlike FAT12/16, FAT32 does not guarantee that root directories will
+occupy consecutive clusters. To get each cluster after the first you
+must access the FAT as with any other directory. This patch implements
+this and bumps up the largest valid cluster number to support large
+e.g. 64MB partitions.
+---
+ fs/fat/fat.c |   20 +++++++++++++++-----
+ 1 files changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/fs/fat/fat.c b/fs/fat/fat.c
+index c6bdb13..44ecb4a 100644
+--- a/fs/fat/fat.c
++++ b/fs/fat/fat.c
+@@ -384,7 +384,7 @@ get_contents(fsdata *mydata, dir_entry *dentptr, __u8 *buffer,
+                       newclust = get_fatent(mydata, endclust);
+                       if((newclust -1)!=endclust)
+                               goto getit;
+-                      if (newclust <= 0x0001 || newclust >= 0xfff0) {
++                      if (newclust <= 0x0001 || newclust >= 0xfffff0) {
+                               FAT_DPRINT("curclust: 0x%x\n", newclust);
+                               FAT_DPRINT("Invalid FAT entry\n");
+                               return gotsize;
+@@ -419,7 +419,7 @@ getit:
+               filesize -= actsize;
+               buffer += actsize;
+               curclust = get_fatent(mydata, endclust);
+-              if (curclust <= 0x0001 || curclust >= 0xfff0) {
++              if (curclust <= 0x0001 || curclust >= 0xfffff0) {
+                       FAT_DPRINT("curclust: 0x%x\n", curclust);
+                       FAT_ERROR("Invalid FAT entry\n");
+                       return gotsize;
+@@ -580,7 +580,7 @@ static dir_entry *get_dentfromdir (fsdata * mydata, int startsect,
+           return retdent;
+       }
+       curclust = get_fatent (mydata, curclust);
+-      if (curclust <= 0x0001 || curclust >= 0xfff0) {
++      if (curclust <= 0x0001 || curclust >= 0xfffff0) {
+           FAT_DPRINT ("curclust: 0x%x\n", curclust);
+           FAT_ERROR ("Invalid FAT entry\n");
+           return NULL;
+@@ -679,7 +679,7 @@ do_fat_read(const char *filename, void *buffer, unsigned long maxsize,
+     dir_entry *dentptr;
+     __u16 prevcksum = 0xffff;
+     char *subname = "";
+-    int rootdir_size, cursect;
++    int rootdir_size, cursect, curclus;
+     int idx, isdir = 0;
+     int files = 0, dirs = 0;
+     long ret = 0;
+@@ -697,6 +697,7 @@ do_fat_read(const char *filename, void *buffer, unsigned long maxsize,
+     mydata->fat_sect = bs.reserved;
+     cursect = mydata->rootdir_sect
+           = mydata->fat_sect + mydata->fatlength * bs.fats;
++    curclus = bs.root_cluster;   // For FAT32 only
+     mydata->clust_size = bs.cluster_size;
+     if (mydata->fatsize == 32) {
+       rootdir_size = mydata->clust_size;
+@@ -818,7 +819,16 @@ do_fat_read(const char *filename, void *buffer, unsigned long maxsize,
+           goto rootdir_done;  /* We got a match */
+       }
+-      cursect++;
++
++      if (mydata->fatsize != 32)
++         cursect++;
++      else {
++         // FAT32 does not guarantee contiguous root directory
++         curclus = get_fatent (mydata, curclus);
++         cursect = (curclus * mydata->clust_size) + mydata->data_begin;
++
++         FAT_DPRINT ("root clus %d sector %d\n", curclus, cursect);
++      }
+     }
+   rootdir_done:
+-- 
+1.6.6.1
+
index eb4a2de..9daaf6c 100644 (file)
@@ -9,7 +9,7 @@ SRCREV_beagleboard = "1c9276af4d6a5b7014a7630a1abeddf3b3177563"
 
 PV = "1.42+${PR}+gitr${SRCREV}"
 PV_beagleboard = "1.44+${PR}+gitr${SRCREV}"
-PR ="r16"
+PR ="r17"
 PE = "1"
 
 SRC_URI = "git://gitorious.org/x-load-omap3/mainline.git;branch=master;protocol=git"
@@ -18,7 +18,8 @@ SRC_URI_append_beagleboard = " \
                               file://name.patch \
                               file://bb8547fcbc54ecc7a75f9ad45a31042a04d8a2ce.patch \
                               file://xm-mem.patch \
-                             "
+                              file://0001-Fix-reading-FAT32-root-dirs-that-span-1-cluster.patch \
+"
 
 SRC_URI_append_omap3-touchbook = " \
                               file://name.patch \