X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=fs%2Ffat%2Ffat_write.c;h=9f5e9118522e8dd371da428cf4fb1593a6af0af7;hb=17998eff9021b7b579c0387e934d8c52603fe247;hp=4a1bda0a37effd984885800ec4679be6f0f71666;hpb=f04821a8ca714459481bd9fd315af2b5f92d99a6;p=u-boot diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 4a1bda0a37..9f5e911852 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -3,23 +3,7 @@ * * R/W (V)FAT 12/16/32 filesystem implementation by Donggeun Kim * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -28,6 +12,7 @@ #include #include #include +#include #include "fat.c" static void uppercase(char *str, int len) @@ -35,7 +20,7 @@ static void uppercase(char *str, int len) int i; for (i = 0; i < len; i++) { - TOUPPER(*str); + *str = toupper(*str); str++; } } @@ -72,7 +57,7 @@ static void set_name(dir_entry *dirent, const char *filename) if (len == 0) return; - memcpy(s_name, filename, len); + strcpy(s_name, filename); uppercase(s_name, len); period = strchr(s_name, '.'); @@ -119,7 +104,6 @@ static int flush_fat_buffer(fsdata *mydata) __u8 *bufptr = mydata->fatbuf; __u32 startblock = mydata->fatbufnum * FATBUFBLOCKS; - fatlength *= mydata->sect_size; startblock += mydata->fat_sect; if (getsize > fatlength) @@ -248,7 +232,6 @@ static __u32 get_fatent_value(fsdata *mydata, __u32 entry) return ret; } -#ifdef CONFIG_SUPPORT_VFAT /* * Set the file name information from 'name' into 'slotptr', */ @@ -468,8 +451,6 @@ get_long_file_name(fsdata *mydata, int curclust, __u8 *cluster, return 0; } -#endif - /* * Set the entry at index 'entry' in a FAT (16/32) table. */ @@ -571,9 +552,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, debug("clustnum: %d, startsect: %d\n", clustnum, startsect); - if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) { - debug("Error writing data\n"); - return -1; + if ((size / mydata->sect_size) > 0) { + if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) { + debug("Error writing data\n"); + return -1; + } } if (size % mydata->sect_size) { @@ -853,16 +836,14 @@ static dir_entry *find_directory_entry(fsdata *mydata, int startsect, continue; } if ((dentptr->attr & ATTR_VOLUME)) { -#ifdef CONFIG_SUPPORT_VFAT - if ((dentptr->attr & ATTR_VFAT) && + if (vfat_enabled && + (dentptr->attr & ATTR_VFAT) && (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) { get_long_file_name(mydata, curclust, get_dentfromdir_block, &dentptr, l_name); debug("vfatname: |%s|\n", l_name); - } else -#endif - { + } else { /* Volume label or VFAT entry */ dentptr++; if (is_next_clust(mydata, dentptr))