Re: [U-Boot] [PATCH v7 2/6] fat: prepare for API change for files greater than 2GB
Hello Simon, On Tue, Nov 11, 2014 at 4:27 PM, Simon Glass s...@chromium.org wrote: Hi, On 10 November 2014 13:17, Suriyan Ramasami suriya...@gmail.com wrote: Change the internal fat functions to use loff_t for offsets. Signed-off-by: Suriyan Ramasami suriya...@gmail.com --- Changes in v7: * Split it so that its bisectable. A few bits below but with these fixed: Acked-by: Simon Glass s...@chromium.org common/cmd_fat.c | 9 ++-- common/env_fat.c | 4 +- fs/fat/fat.c | 133 +++-- fs/fat/fat_write.c | 61 +--- fs/fat/file.c | 4 +- include/fat.h | 13 +++--- 6 files changed, 128 insertions(+), 96 deletions(-) diff --git a/common/cmd_fat.c b/common/cmd_fat.c index 633fbf1..c00fb28 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -100,7 +100,8 @@ U_BOOT_CMD( static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - long size; + loff_t size; + int ret; unsigned long addr; unsigned long count; block_dev_desc_t *dev_desc = NULL; @@ -127,15 +128,15 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, count = simple_strtoul(argv[5], NULL, 16); buf = map_sysmem(addr, count); - size = file_fat_write(argv[4], buf, count); + ret = file_fat_write(argv[4], buf, 0, count, size); unmap_sysmem(buf); - if (size == -1) { + if (ret 0) { printf(\n** Unable to write \%s\ from %s %d:%d **\n, argv[4], argv[1], dev, part); return 1; } - printf(%ld bytes written\n, size); + printf(%llu bytes written\n, size); return 0; } diff --git a/common/env_fat.c b/common/env_fat.c index 8db0160..9a6ce63 100644 --- a/common/env_fat.c +++ b/common/env_fat.c @@ -41,6 +41,7 @@ int saveenv(void) disk_partition_t info; int dev, part; int err; + loff_t size; err = env_export(env_new); if (err) @@ -59,7 +60,8 @@ int saveenv(void) return 1; } - err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t)); + err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t), +size); if (err == -1) { printf(\n** Unable to write \%s\ from %s%d:%d **\n, FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part); diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 561921f..29d0825 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -317,32 +317,33 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size) /* * Read at most 'maxsize' bytes from 'pos' in the file associated with 'dentptr' * into 'buffer'. - * Return the number of bytes read or -1 on fatal errors. + * Update the number of bytes read in *gotsize or return -1 on fatal errors. */ __u8 get_contents_vfatname_block[MAX_CLUSTSIZE] __aligned(ARCH_DMA_MINALIGN); -static long -get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, -__u8 *buffer, unsigned long maxsize) +static int put this on the same line as the next OK +get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, +__u8 *buffer, loff_t maxsize, loff_t *gotsize) { - unsigned long filesize = FAT2CPU32(dentptr-size), gotsize = 0; + loff_t filesize = FAT2CPU32(dentptr-size); unsigned int bytesperclust = mydata-clust_size * mydata-sect_size; __u32 curclust = START(dentptr); __u32 endclust, newclust; - unsigned long actsize; + loff_t actsize; - debug(Filesize: %ld bytes\n, filesize); + *gotsize = 0; + debug(Filesize: %llu bytes\n, filesize); if (pos = filesize) { - debug(Read position past EOF: %lu\n, pos); - return gotsize; + debug(Read position past EOF: %llu\n, pos); + return 0; } if (maxsize 0 filesize pos + maxsize) filesize = pos + maxsize; - debug(%ld bytes\n, filesize); + debug(%llu bytes\n, filesize); actsize = bytesperclust; @@ -352,7 +353,7 @@ get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, if (CHECK_CLUST(curclust, mydata-fatsize)) { debug(curclust: 0x%x\n, curclust); debug(Invalid FAT entry\n); - return gotsize; + return 0; } actsize += bytesperclust; } @@ -373,16 +374,16 @@ get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, filesize -= actsize; actsize -= pos; memcpy(buffer, get_contents_vfatname_block + pos, actsize); -
Re: [U-Boot] [PATCH v7 2/6] fat: prepare for API change for files greater than 2GB
Hi, On 10 November 2014 13:17, Suriyan Ramasami suriya...@gmail.com wrote: Change the internal fat functions to use loff_t for offsets. Signed-off-by: Suriyan Ramasami suriya...@gmail.com --- Changes in v7: * Split it so that its bisectable. A few bits below but with these fixed: Acked-by: Simon Glass s...@chromium.org common/cmd_fat.c | 9 ++-- common/env_fat.c | 4 +- fs/fat/fat.c | 133 +++-- fs/fat/fat_write.c | 61 +--- fs/fat/file.c | 4 +- include/fat.h | 13 +++--- 6 files changed, 128 insertions(+), 96 deletions(-) diff --git a/common/cmd_fat.c b/common/cmd_fat.c index 633fbf1..c00fb28 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -100,7 +100,8 @@ U_BOOT_CMD( static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - long size; + loff_t size; + int ret; unsigned long addr; unsigned long count; block_dev_desc_t *dev_desc = NULL; @@ -127,15 +128,15 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, count = simple_strtoul(argv[5], NULL, 16); buf = map_sysmem(addr, count); - size = file_fat_write(argv[4], buf, count); + ret = file_fat_write(argv[4], buf, 0, count, size); unmap_sysmem(buf); - if (size == -1) { + if (ret 0) { printf(\n** Unable to write \%s\ from %s %d:%d **\n, argv[4], argv[1], dev, part); return 1; } - printf(%ld bytes written\n, size); + printf(%llu bytes written\n, size); return 0; } diff --git a/common/env_fat.c b/common/env_fat.c index 8db0160..9a6ce63 100644 --- a/common/env_fat.c +++ b/common/env_fat.c @@ -41,6 +41,7 @@ int saveenv(void) disk_partition_t info; int dev, part; int err; + loff_t size; err = env_export(env_new); if (err) @@ -59,7 +60,8 @@ int saveenv(void) return 1; } - err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t)); + err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t), +size); if (err == -1) { printf(\n** Unable to write \%s\ from %s%d:%d **\n, FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part); diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 561921f..29d0825 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -317,32 +317,33 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size) /* * Read at most 'maxsize' bytes from 'pos' in the file associated with 'dentptr' * into 'buffer'. - * Return the number of bytes read or -1 on fatal errors. + * Update the number of bytes read in *gotsize or return -1 on fatal errors. */ __u8 get_contents_vfatname_block[MAX_CLUSTSIZE] __aligned(ARCH_DMA_MINALIGN); -static long -get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, -__u8 *buffer, unsigned long maxsize) +static int put this on the same line as the next +get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, +__u8 *buffer, loff_t maxsize, loff_t *gotsize) { - unsigned long filesize = FAT2CPU32(dentptr-size), gotsize = 0; + loff_t filesize = FAT2CPU32(dentptr-size); unsigned int bytesperclust = mydata-clust_size * mydata-sect_size; __u32 curclust = START(dentptr); __u32 endclust, newclust; - unsigned long actsize; + loff_t actsize; - debug(Filesize: %ld bytes\n, filesize); + *gotsize = 0; + debug(Filesize: %llu bytes\n, filesize); if (pos = filesize) { - debug(Read position past EOF: %lu\n, pos); - return gotsize; + debug(Read position past EOF: %llu\n, pos); + return 0; } if (maxsize 0 filesize pos + maxsize) filesize = pos + maxsize; - debug(%ld bytes\n, filesize); + debug(%llu bytes\n, filesize); actsize = bytesperclust; @@ -352,7 +353,7 @@ get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, if (CHECK_CLUST(curclust, mydata-fatsize)) { debug(curclust: 0x%x\n, curclust); debug(Invalid FAT entry\n); - return gotsize; + return 0; } actsize += bytesperclust; } @@ -373,16 +374,16 @@ get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, filesize -= actsize; actsize -= pos; memcpy(buffer, get_contents_vfatname_block + pos, actsize); - gotsize += actsize; + *gotsize += actsize; if
[U-Boot] [PATCH v7 2/6] fat: prepare for API change for files greater than 2GB
Change the internal fat functions to use loff_t for offsets. Signed-off-by: Suriyan Ramasami suriya...@gmail.com --- Changes in v7: * Split it so that its bisectable. common/cmd_fat.c | 9 ++-- common/env_fat.c | 4 +- fs/fat/fat.c | 133 +++-- fs/fat/fat_write.c | 61 +--- fs/fat/file.c | 4 +- include/fat.h | 13 +++--- 6 files changed, 128 insertions(+), 96 deletions(-) diff --git a/common/cmd_fat.c b/common/cmd_fat.c index 633fbf1..c00fb28 100644 --- a/common/cmd_fat.c +++ b/common/cmd_fat.c @@ -100,7 +100,8 @@ U_BOOT_CMD( static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - long size; + loff_t size; + int ret; unsigned long addr; unsigned long count; block_dev_desc_t *dev_desc = NULL; @@ -127,15 +128,15 @@ static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, count = simple_strtoul(argv[5], NULL, 16); buf = map_sysmem(addr, count); - size = file_fat_write(argv[4], buf, count); + ret = file_fat_write(argv[4], buf, 0, count, size); unmap_sysmem(buf); - if (size == -1) { + if (ret 0) { printf(\n** Unable to write \%s\ from %s %d:%d **\n, argv[4], argv[1], dev, part); return 1; } - printf(%ld bytes written\n, size); + printf(%llu bytes written\n, size); return 0; } diff --git a/common/env_fat.c b/common/env_fat.c index 8db0160..9a6ce63 100644 --- a/common/env_fat.c +++ b/common/env_fat.c @@ -41,6 +41,7 @@ int saveenv(void) disk_partition_t info; int dev, part; int err; + loff_t size; err = env_export(env_new); if (err) @@ -59,7 +60,8 @@ int saveenv(void) return 1; } - err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t)); + err = file_fat_write(FAT_ENV_FILE, (void *)env_new, sizeof(env_t), +size); if (err == -1) { printf(\n** Unable to write \%s\ from %s%d:%d **\n, FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part); diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 561921f..29d0825 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -317,32 +317,33 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size) /* * Read at most 'maxsize' bytes from 'pos' in the file associated with 'dentptr' * into 'buffer'. - * Return the number of bytes read or -1 on fatal errors. + * Update the number of bytes read in *gotsize or return -1 on fatal errors. */ __u8 get_contents_vfatname_block[MAX_CLUSTSIZE] __aligned(ARCH_DMA_MINALIGN); -static long -get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, -__u8 *buffer, unsigned long maxsize) +static int +get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, +__u8 *buffer, loff_t maxsize, loff_t *gotsize) { - unsigned long filesize = FAT2CPU32(dentptr-size), gotsize = 0; + loff_t filesize = FAT2CPU32(dentptr-size); unsigned int bytesperclust = mydata-clust_size * mydata-sect_size; __u32 curclust = START(dentptr); __u32 endclust, newclust; - unsigned long actsize; + loff_t actsize; - debug(Filesize: %ld bytes\n, filesize); + *gotsize = 0; + debug(Filesize: %llu bytes\n, filesize); if (pos = filesize) { - debug(Read position past EOF: %lu\n, pos); - return gotsize; + debug(Read position past EOF: %llu\n, pos); + return 0; } if (maxsize 0 filesize pos + maxsize) filesize = pos + maxsize; - debug(%ld bytes\n, filesize); + debug(%llu bytes\n, filesize); actsize = bytesperclust; @@ -352,7 +353,7 @@ get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, if (CHECK_CLUST(curclust, mydata-fatsize)) { debug(curclust: 0x%x\n, curclust); debug(Invalid FAT entry\n); - return gotsize; + return 0; } actsize += bytesperclust; } @@ -373,16 +374,16 @@ get_contents(fsdata *mydata, dir_entry *dentptr, unsigned long pos, filesize -= actsize; actsize -= pos; memcpy(buffer, get_contents_vfatname_block + pos, actsize); - gotsize += actsize; + *gotsize += actsize; if (!filesize) - return gotsize; + return 0; buffer += actsize; curclust = get_fatent(mydata, curclust); if (CHECK_CLUST(curclust, mydata-fatsize)) { debug(curclust: 0x%x\n, curclust);