3 * Richard Jones, rjones@nexus-tech.net
5 * SPDX-License-Identifier: GPL-2.0+
20 int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
22 return do_load(cmdtp, flag, argc, argv, FS_TYPE_FAT);
27 fatload, 7, 0, do_fat_fsload,
28 "load binary file from a dos filesystem",
29 "<interface> [<dev[:part]>] <addr> <filename> [bytes [pos]]\n"
30 " - Load binary file 'filename' from 'dev' on 'interface'\n"
31 " to address 'addr' from dos filesystem.\n"
32 " 'pos' gives the file position to start loading from.\n"
33 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
34 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
35 " the load stops on end of file.\n"
36 " If either 'pos' or 'bytes' are not aligned to\n"
37 " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
38 " be printed and performance will suffer for the load."
41 static int do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
43 return do_ls(cmdtp, flag, argc, argv, FS_TYPE_FAT);
47 fatls, 4, 1, do_fat_ls,
48 "list files in a directory (default /)",
49 "<interface> [<dev[:part]>] [directory]\n"
50 " - list files from 'dev' on 'interface' in a 'directory'"
53 static int do_fat_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc,
57 block_dev_desc_t *dev_desc;
58 disk_partition_t info;
61 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
65 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
70 if (fat_set_blk_dev(dev_desc, &info) != 0) {
71 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
75 return file_fat_detectfs();
79 fatinfo, 3, 1, do_fat_fsinfo,
80 "print information about filesystem",
81 "<interface> [<dev[:part]>]\n"
82 " - print information about filesystem from 'dev' on 'interface'"
85 #ifdef CONFIG_FAT_WRITE
86 static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
87 int argc, char * const argv[])
92 block_dev_desc_t *dev_desc = NULL;
93 disk_partition_t info;
98 return cmd_usage(cmdtp);
100 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
106 if (fat_set_blk_dev(dev_desc, &info) != 0) {
107 printf("\n** Unable to use %s %d:%d for fatwrite **\n",
111 addr = simple_strtoul(argv[3], NULL, 16);
112 count = simple_strtoul(argv[5], NULL, 16);
114 size = file_fat_write(argv[4], (void *)addr, count);
116 printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
117 argv[4], argv[1], dev, part);
121 printf("%ld bytes written\n", size);
127 fatwrite, 6, 0, do_fat_fswrite,
128 "write file into a dos filesystem",
129 "<interface> <dev[:part]> <addr> <filename> <bytes>\n"
130 " - write file 'filename' from the address 'addr' in RAM\n"
131 " to 'dev' on 'interface'"