1 // SPDX-License-Identifier: GPL-2.0+
15 #include <asm/cache.h>
17 int do_fat_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
19 return do_size(cmdtp, flag, argc, argv, FS_TYPE_FAT);
23 fatsize, 4, 0, do_fat_size,
24 "determine a file's size",
25 "<interface> <dev[:part]> <filename>\n"
26 " - Find file 'filename' from 'dev' on 'interface'\n"
27 " and determine its size."
30 int do_fat_fsload(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
32 return do_load(cmdtp, flag, argc, argv, FS_TYPE_FAT);
37 fatload, 7, 0, do_fat_fsload,
38 "load binary file from a dos filesystem",
39 "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
40 " - Load binary file 'filename' from 'dev' on 'interface'\n"
41 " to address 'addr' from dos filesystem.\n"
42 " 'pos' gives the file position to start loading from.\n"
43 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
44 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
45 " the load stops on end of file.\n"
46 " If either 'pos' or 'bytes' are not aligned to\n"
47 " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
48 " be printed and performance will suffer for the load."
51 static int do_fat_ls(struct cmd_tbl *cmdtp, int flag, int argc,
54 return do_ls(cmdtp, flag, argc, argv, FS_TYPE_FAT);
58 fatls, 4, 1, do_fat_ls,
59 "list files in a directory (default /)",
60 "<interface> [<dev[:part]>] [directory]\n"
61 " - list files from 'dev' on 'interface' in a 'directory'"
64 static int do_fat_fsinfo(struct cmd_tbl *cmdtp, int flag, int argc,
68 struct blk_desc *dev_desc;
69 struct disk_partition info;
72 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
76 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
80 dev = dev_desc->devnum;
81 if (fat_set_blk_dev(dev_desc, &info) != 0) {
82 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
86 return file_fat_detectfs();
90 fatinfo, 3, 1, do_fat_fsinfo,
91 "print information about filesystem",
92 "<interface> [<dev[:part]>]\n"
93 " - print information about filesystem from 'dev' on 'interface'"
96 #ifdef CONFIG_FAT_WRITE
97 static int do_fat_fswrite(struct cmd_tbl *cmdtp, int flag, int argc,
100 return do_save(cmdtp, flag, argc, argv, FS_TYPE_FAT);
104 fatwrite, 7, 0, do_fat_fswrite,
105 "write file into a dos filesystem",
106 "<interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]\n"
107 " - write file 'filename' from the address 'addr' in RAM\n"
108 " to 'dev' on 'interface'"
111 static int do_fat_rm(struct cmd_tbl *cmdtp, int flag, int argc,
114 return do_rm(cmdtp, flag, argc, argv, FS_TYPE_FAT);
118 fatrm, 4, 1, do_fat_rm,
120 "<interface> [<dev[:part]>] <filename>\n"
121 " - delete a file from 'dev' on 'interface'"
124 static int do_fat_mkdir(struct cmd_tbl *cmdtp, int flag, int argc,
127 return do_mkdir(cmdtp, flag, argc, argv, FS_TYPE_FAT);
131 fatmkdir, 4, 1, do_fat_mkdir,
132 "create a directory",
133 "<interface> [<dev[:part]>] <directory>\n"
134 " - create a directory in 'dev' on 'interface'"