cmd: fat: Use do_save() for fatwrite
do_save() function defined in fs.c also supports FAT file system re-use the same for fatwrite command. Also fix the FAT test script to match the expected output. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
This commit is contained in:
parent
f52e925669
commit
274227500a
2 changed files with 4 additions and 45 deletions
43
cmd/fat.c
43
cmd/fat.c
|
@ -98,48 +98,7 @@ U_BOOT_CMD(
|
||||||
static int do_fat_fswrite(struct cmd_tbl *cmdtp, int flag, int argc,
|
static int do_fat_fswrite(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
loff_t size;
|
return do_save(cmdtp, flag, argc, argv, FS_TYPE_FAT);
|
||||||
int ret;
|
|
||||||
unsigned long addr;
|
|
||||||
unsigned long count;
|
|
||||||
long offset;
|
|
||||||
struct blk_desc *dev_desc = NULL;
|
|
||||||
struct disk_partition info;
|
|
||||||
int dev = 0;
|
|
||||||
int part = 1;
|
|
||||||
void *buf;
|
|
||||||
|
|
||||||
if (argc < 5)
|
|
||||||
return cmd_usage(cmdtp);
|
|
||||||
|
|
||||||
part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
|
|
||||||
if (part < 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
dev = dev_desc->devnum;
|
|
||||||
|
|
||||||
if (fat_set_blk_dev(dev_desc, &info) != 0) {
|
|
||||||
printf("\n** Unable to use %s %d:%d for fatwrite **\n",
|
|
||||||
argv[1], dev, part);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
addr = simple_strtoul(argv[3], NULL, 16);
|
|
||||||
count = (argc <= 5) ? 0 : simple_strtoul(argv[5], NULL, 16);
|
|
||||||
/* offset should be a hex, but "-1" is allowed */
|
|
||||||
offset = (argc <= 6) ? 0 : simple_strtol(argv[6], NULL, 16);
|
|
||||||
|
|
||||||
buf = map_sysmem(addr, count);
|
|
||||||
ret = file_fat_write(argv[4], buf, offset, count, &size);
|
|
||||||
unmap_sysmem(buf);
|
|
||||||
if (ret < 0) {
|
|
||||||
printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
|
|
||||||
argv[4], argv[1], dev, part);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("%llu bytes written\n", size);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
U_BOOT_CMD(
|
U_BOOT_CMD(
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TestFsExt(object):
|
||||||
'%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE),
|
'%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE),
|
||||||
'%swrite host 0:0 %x /dir1/none/%s.w3 $filesize'
|
'%swrite host 0:0 %x /dir1/none/%s.w3 $filesize'
|
||||||
% (fs_type, ADDR, MIN_FILE)])
|
% (fs_type, ADDR, MIN_FILE)])
|
||||||
assert('Unable to write "/dir1/none/' in ''.join(output))
|
assert('Unable to write file /dir1/none/' in ''.join(output))
|
||||||
assert_fs_integrity(fs_type, fs_img)
|
assert_fs_integrity(fs_type, fs_img)
|
||||||
|
|
||||||
def test_fs_ext4(self, u_boot_console, fs_obj_ext):
|
def test_fs_ext4(self, u_boot_console, fs_obj_ext):
|
||||||
|
@ -216,7 +216,7 @@ class TestFsExt(object):
|
||||||
output = u_boot_console.run_command(
|
output = u_boot_console.run_command(
|
||||||
'%swrite host 0:0 %x /dir1/%s.w8 0x1400 %x'
|
'%swrite host 0:0 %x /dir1/%s.w8 0x1400 %x'
|
||||||
% (fs_type, ADDR, MIN_FILE, 0x100000 + 0x1400))
|
% (fs_type, ADDR, MIN_FILE, 0x100000 + 0x1400))
|
||||||
assert('Unable to write "/dir1' in output)
|
assert('Unable to write file /dir1' in output)
|
||||||
assert_fs_integrity(fs_type, fs_img)
|
assert_fs_integrity(fs_type, fs_img)
|
||||||
|
|
||||||
def test_fs_ext9(self, u_boot_console, fs_obj_ext):
|
def test_fs_ext9(self, u_boot_console, fs_obj_ext):
|
||||||
|
@ -231,7 +231,7 @@ class TestFsExt(object):
|
||||||
'%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE),
|
'%sload host 0:0 %x /%s' % (fs_type, ADDR, MIN_FILE),
|
||||||
'%swrite host 0:0 %x /dir1/%s.w9 0x1400 0x1400'
|
'%swrite host 0:0 %x /dir1/%s.w9 0x1400 0x1400'
|
||||||
% (fs_type, ADDR, MIN_FILE)])
|
% (fs_type, ADDR, MIN_FILE)])
|
||||||
assert('Unable to write "/dir1' in ''.join(output))
|
assert('Unable to write file /dir1' in ''.join(output))
|
||||||
assert_fs_integrity(fs_type, fs_img)
|
assert_fs_integrity(fs_type, fs_img)
|
||||||
|
|
||||||
def test_fs_ext10(self, u_boot_console, fs_obj_ext):
|
def test_fs_ext10(self, u_boot_console, fs_obj_ext):
|
||||||
|
|
Loading…
Reference in a new issue