Merge branch 'master' of git://git.denx.de/u-boot-i2c
[oweals/u-boot.git] / fs / fat / fat_write.c
index 16f8400b39ca2b89821842bdae9c8202af23d21f..4a1bda0a37effd984885800ec4679be6f0f71666 100644 (file)
@@ -328,14 +328,14 @@ static void flush_dir_table(fsdata *mydata, dir_entry **dentptr);
 static void
 fill_dir_slot(fsdata *mydata, dir_entry **dentptr, const char *l_name)
 {
-       dir_slot *slotptr = (dir_slot *)get_vfatname_block;
+       dir_slot *slotptr = (dir_slot *)get_contents_vfatname_block;
        __u8 counter = 0, checksum;
        int idx = 0, ret;
        char s_name[16];
 
        /* Get short file name and checksum value */
        strncpy(s_name, (*dentptr)->name, 16);
-       checksum = mkcksum(s_name);
+       checksum = mkcksum((*dentptr)->name, (*dentptr)->ext);
 
        do {
                memset(slotptr, 0x00, sizeof(dir_slot));
@@ -373,7 +373,7 @@ static __u32 dir_curclust;
  * a slot) into 'l_name'. If successful also copy the real directory entry
  * into 'retdent'
  * If additional adjacent cluster for directory entries is read into memory,
- * then 'get_vfatname_block' is copied into 'get_dentfromdir_block' and
+ * then 'get_contents_vfatname_block' is copied into 'get_dentfromdir_block' and
  * the location of the real directory entry is returned by 'retdent'
  * Return 0 on success, -1 otherwise.
  */
@@ -416,13 +416,13 @@ get_long_file_name(fsdata *mydata, int curclust, __u8 *cluster,
 
                dir_curclust = curclust;
 
-               if (get_cluster(mydata, curclust, get_vfatname_block,
+               if (get_cluster(mydata, curclust, get_contents_vfatname_block,
                                mydata->clust_size * mydata->sect_size) != 0) {
                        debug("Error: reading directory block\n");
                        return -1;
                }
 
-               slotptr2 = (dir_slot *)get_vfatname_block;
+               slotptr2 = (dir_slot *)get_contents_vfatname_block;
                while (counter > 0) {
                        if (((slotptr2->id & ~LAST_LONG_ENTRY_MASK)
                            & 0xff) != counter)
@@ -433,7 +433,7 @@ get_long_file_name(fsdata *mydata, int curclust, __u8 *cluster,
 
                /* Save the real directory entry */
                realdent = (dir_entry *)slotptr2;
-               while ((__u8 *)slotptr2 > get_vfatname_block) {
+               while ((__u8 *)slotptr2 > get_contents_vfatname_block) {
                        slotptr2--;
                        slot2str(slotptr2, l_name, &idx);
                }
@@ -459,9 +459,9 @@ get_long_file_name(fsdata *mydata, int curclust, __u8 *cluster,
        *retdent = realdent;
 
        if (slotptr2) {
-               memcpy(get_dentfromdir_block, get_vfatname_block,
+               memcpy(get_dentfromdir_block, get_contents_vfatname_block,
                        mydata->clust_size * mydata->sect_size);
-               cur_position = (__u8 *)realdent - get_vfatname_block;
+               cur_position = (__u8 *)realdent - get_contents_vfatname_block;
                *retdent = (dir_entry *) &get_dentfromdir_block[cur_position];
        }
 
@@ -823,7 +823,6 @@ static dir_entry *empty_dentptr;
 static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
        char *filename, dir_entry *retdent, __u32 start)
 {
-       __u16 prevcksum = 0xffff;
        __u32 curclust = (startsect - mydata->data_begin) / mydata->clust_size;
 
        debug("get_dentfromdir: %s\n", filename);
@@ -857,8 +856,6 @@ static dir_entry *find_directory_entry(fsdata *mydata, int startsect,
 #ifdef CONFIG_SUPPORT_VFAT
                                if ((dentptr->attr & ATTR_VFAT) &&
                                    (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
-                                       prevcksum =
-                                       ((dir_slot *)dentptr)->alias_checksum;
                                        get_long_file_name(mydata, curclust,
                                                     get_dentfromdir_block,
                                                     &dentptr, l_name);
@@ -922,7 +919,6 @@ static int do_fat_write(const char *filename, void *buffer,
        unsigned long size)
 {
        dir_entry *dentptr, *retdent;
-       dir_slot *slotptr;
        __u32 startsect;
        __u32 start_cluster;
        boot_sector bs;
@@ -930,7 +926,7 @@ static int do_fat_write(const char *filename, void *buffer,
        fsdata datablock;
        fsdata *mydata = &datablock;
        int cursect;
-       int root_cluster, ret = -1, name_len;
+       int ret = -1, name_len;
        char l_filename[VFAT_MAXLEN_BYTES];
        int write_size = size;
 
@@ -945,8 +941,6 @@ static int do_fat_write(const char *filename, void *buffer,
        if (total_sector == 0)
                total_sector = cur_part_info.size;
 
-       root_cluster = bs.root_cluster;
-
        if (mydata->fatsize == 32)
                mydata->fatlength = bs.fat32_length;
        else
@@ -986,11 +980,11 @@ static int do_fat_write(const char *filename, void *buffer,
        if (disk_read(cursect,
                (mydata->fatsize == 32) ?
                (mydata->clust_size) :
-               PREFETCH_BLOCKS, do_fat_read_block) < 0) {
+               PREFETCH_BLOCKS, do_fat_read_at_block) < 0) {
                debug("Error: reading rootdir block\n");
                goto exit;
        }
-       dentptr = (dir_entry *) do_fat_read_block;
+       dentptr = (dir_entry *) do_fat_read_at_block;
 
        name_len = strlen(filename);
        if (name_len >= VFAT_MAXLEN_BYTES)
@@ -1047,8 +1041,6 @@ static int do_fat_write(const char *filename, void *buffer,
                        goto exit;
                }
        } else {
-               slotptr = (dir_slot *)empty_dentptr;
-
                /* Set short name to set alias checksum field in dir_slot */
                set_name(empty_dentptr, filename);
                fill_dir_slot(mydata, &empty_dentptr, filename);