From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] fat: cannot compare bytes and sectors
Date: Mon, 8 Aug 2011 23:39:29 +0400 [thread overview]
Message-ID: <201108082339.29933.sshtylyov@ru.mvista.com> (raw)
The code multiples the FAT size in sectors by the sector size and then tries to
compare that to the number of sectors in the 'getsize' variable. While fixing
this, also change the initial value of 'getsize' as the division of FATBUFSIZE
by the sector size gets us FATBUFBLOCKS.
Signed-off-by: Sergei Shtylyov <sshtylyov@mvista.com>
---
fs/fat/fat.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: u-boot/fs/fat/fat.c
===================================================================
--- u-boot.orig/fs/fat/fat.c
+++ u-boot/fs/fat/fat.c
@@ -209,16 +209,17 @@ static __u32 get_fatent (fsdata *mydata,
/* Read a new block of FAT entries into the cache. */
if (bufnum != mydata->fatbufnum) {
- __u32 getsize = FATBUFSIZE / mydata->sect_size;
+ __u32 getsize = FATBUFBLOCKS;
__u8 *bufptr = mydata->fatbuf;
__u32 fatlength = mydata->fatlength;
__u32 startblock = bufnum * FATBUFBLOCKS;
+ if (getsize > fatlength)
+ getsize = fatlength;
+
fatlength *= mydata->sect_size; /* We want it in bytes now */
startblock += mydata->fat_sect; /* Offset from start of disk */
- if (getsize > fatlength)
- getsize = fatlength;
if (disk_read(startblock, getsize, bufptr) < 0) {
debug("Error reading FAT blocks\n");
return ret;
next reply other threads:[~2011-08-08 19:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-08 19:39 Sergei Shtylyov [this message]
2011-10-01 19:51 ` [U-Boot] [PATCH 2/2] fat: cannot compare bytes and sectors Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201108082339.29933.sshtylyov@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox