]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cmd/fat.c
3 * Richard Jones, rjones@nexus-tech.net
5 * SPDX-License-Identifier: GPL-2.0+
22 int do_fat_size(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
24 return do_size(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
28 fatsize
, 4, 0, do_fat_size
,
29 "determine a file's size",
30 "<interface> <dev[:part]> <filename>\n"
31 " - Find file 'filename' from 'dev' on 'interface'\n"
32 " and determine its size."
35 int do_fat_fsload (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
37 return do_load(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
42 fatload
, 7, 0, do_fat_fsload
,
43 "load binary file from a dos filesystem",
44 "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
45 " - Load binary file 'filename' from 'dev' on 'interface'\n"
46 " to address 'addr' from dos filesystem.\n"
47 " 'pos' gives the file position to start loading from.\n"
48 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
49 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
50 " the load stops on end of file.\n"
51 " If either 'pos' or 'bytes' are not aligned to\n"
52 " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
53 " be printed and performance will suffer for the load."
56 static int do_fat_ls(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char * const argv
[])
58 return do_ls(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
62 fatls
, 4, 1, do_fat_ls
,
63 "list files in a directory (default /)",
64 "<interface> [<dev[:part]>] [directory]\n"
65 " - list files from 'dev' on 'interface' in a 'directory'"
68 static int do_fat_fsinfo(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
72 struct blk_desc
*dev_desc
;
73 disk_partition_t info
;
76 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
80 part
= blk_get_device_part_str(argv
[1], argv
[2], &dev_desc
, &info
, 1);
84 dev
= dev_desc
->devnum
;
85 if (fat_set_blk_dev(dev_desc
, &info
) != 0) {
86 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
90 return file_fat_detectfs();
94 fatinfo
, 3, 1, do_fat_fsinfo
,
95 "print information about filesystem",
96 "<interface> [<dev[:part]>]\n"
97 " - print information about filesystem from 'dev' on 'interface'"
100 #ifdef CONFIG_FAT_WRITE
101 static int do_fat_fswrite(cmd_tbl_t
*cmdtp
, int flag
,
102 int argc
, char * const argv
[])
108 struct blk_desc
*dev_desc
= NULL
;
109 disk_partition_t info
;
115 return cmd_usage(cmdtp
);
117 part
= blk_get_device_part_str(argv
[1], argv
[2], &dev_desc
, &info
, 1);
121 dev
= dev_desc
->devnum
;
123 if (fat_set_blk_dev(dev_desc
, &info
) != 0) {
124 printf("\n** Unable to use %s %d:%d for fatwrite **\n",
128 addr
= simple_strtoul(argv
[3], NULL
, 16);
129 count
= (argc
<= 5) ? 0 : simple_strtoul(argv
[5], NULL
, 16);
131 buf
= map_sysmem(addr
, count
);
132 ret
= file_fat_write(argv
[4], buf
, 0, count
, &size
);
135 printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
136 argv
[4], argv
[1], dev
, part
);
140 printf("%llu bytes written\n", size
);
146 fatwrite
, 6, 0, do_fat_fswrite
,
147 "write file into a dos filesystem",
148 "<interface> <dev[:part]> <addr> <filename> [<bytes>]\n"
149 " - write file 'filename' from the address 'addr' in RAM\n"
150 " to 'dev' on 'interface'"