freemyipod r151 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r150‎ | r151 | r152 >
Date:15:10, 18 August 2010
Author:theseven
Status:new
Tags:
Comment:
Fix a bunch of nasty FAT driver bugs
Modified paths:
  • /embios/trunk/fat.c (modified) (history)

Diff [purge]

Index: embios/trunk/fat.c
@@ -1150,7 +1150,7 @@
11511151 }
11521152 if (rc==0)
11531153 /* end of dir */
1154 - memset(buf, 0, sizeof buf);
 1154+ memset(buf, 0, SECTOR_SIZE);
11551155
11561156 sector++;
11571157 idx = 0;
@@ -1201,7 +1201,7 @@
12021202 entry[FATDIR_FSTCLUSLO] = 0;
12031203 entry[FATLONG_TYPE] = 0;
12041204 entry[FATLONG_CHKSUM] = chksum;
1205 - DEBUGF("Longname entry %d: %s", idx, name+nameidx);
 1205+ DEBUGF("Longname entry %d (%d): %s", idx, nameidx, name+nameidx);
12061206 }
12071207 else {
12081208 /* shortname entry */
@@ -1236,6 +1236,7 @@
12371237 if (rc<1)
12381238 return rc * 10 - 7;
12391239
 1240+ DEBUGF("write_long_name: success");
12401241 return 0;
12411242 }
12421243
@@ -1391,7 +1392,7 @@
13921393 fat_release_sector_buffer();
13931394 return rc * 10 - 4;
13941395 }
1395 - memset(buf, 0, sizeof buf);
 1396+ memset(buf, 0, SECTOR_SIZE);
13961397
13971398 /* we must clear whole clusters */
13981399 for (; (entries_found < entries_needed) ||
@@ -1721,7 +1722,6 @@
17221723 #else
17231724 struct bpb* fat_bpb = &fat_bpbs[0];
17241725 #endif
1725 - unsigned char buf[4];
17261726 int i;
17271727 long sector;
17281728 int rc;
@@ -1746,13 +1746,18 @@
17471747 update_fat_entry(IF_MV2(fat_bpb,) newdir->file.firstcluster, FAT_EOF_MARK);
17481748
17491749 /* Clear the entire cluster */
1750 - memset(buf, 0, sizeof buf);
 1750+ unsigned char* buf = fat_get_sector_buffer();
 1751+ memset(buf, 0, SECTOR_SIZE);
17511752 sector = cluster2sec(IF_MV2(fat_bpb,) newdir->file.firstcluster);
17521753 for(i = 0;i < (int)fat_bpb->bpb_secperclus;i++) {
17531754 rc = transfer(IF_MV2(fat_bpb,) sector + i, 1, buf, true );
17541755 if (rc < 0)
 1756+ {
 1757+ fat_release_sector_buffer();
17551758 return rc * 10 - 2;
 1759+ }
17561760 }
 1761+ fat_release_sector_buffer();
17571762
17581763 /* Then add the "." entry */
17591764 rc = add_dir_entry(newdir, &dummyfile, ".", true, true);