1 // SPDX-License-Identifier: GPL-2.0+
4 * Richard Jones, rjones@nexus-tech.net
16 #include <asm/cache.h>
18 int do_fat_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
20 return do_size(cmdtp, flag, argc, argv, FS_TYPE_FAT);
24 fatsize, 4, 0, do_fat_size,
25 "determine a file's size",
26 "<interface> <dev[:part]> <filename>\n"
27 " - Find file 'filename' from 'dev' on 'interface'\n"
28 " and determine its size."
31 int do_fat_fsload(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
33 return do_load(cmdtp, flag, argc, argv, FS_TYPE_FAT);
38 fatload, 7, 0, do_fat_fsload,
39 "load binary file from a dos filesystem",
40 "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
41 " - Load binary file 'filename' from 'dev' on 'interface'\n"
42 " to address 'addr' from dos filesystem.\n"
43 " 'pos' gives the file position to start loading from.\n"
44 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
45 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
46 " the load stops on end of file.\n"
47 " If either 'pos' or 'bytes' are not aligned to\n"
48 " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
49 " be printed and performance will suffer for the load."
52 static int do_fat_ls(struct cmd_tbl *cmdtp, int flag, int argc,
55 return do_ls(cmdtp, flag, argc, argv, FS_TYPE_FAT);
59 fatls, 4, 1, do_fat_ls,
60 "list files in a directory (default /)",
61 "<interface> [<dev[:part]>] [directory]\n"
62 " - list files from 'dev' on 'interface' in a 'directory'"
65 static int do_fat_fsinfo(struct cmd_tbl *cmdtp, int flag, int argc,
69 struct blk_desc *dev_desc;
70 struct disk_partition info;
73 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
77 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
81 dev = dev_desc->devnum;
82 if (fat_set_blk_dev(dev_desc, &info) != 0) {
83 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
87 return file_fat_detectfs();
91 fatinfo, 3, 1, do_fat_fsinfo,
92 "print information about filesystem",
93 "<interface> [<dev[:part]>]\n"
94 " - print information about filesystem from 'dev' on 'interface'"
97 #ifdef CONFIG_FAT_WRITE
98 static int do_fat_fswrite(struct cmd_tbl *cmdtp, int flag, int argc,
101 return do_save(cmdtp, flag, argc, argv, FS_TYPE_FAT);
105 fatwrite, 7, 0, do_fat_fswrite,
106 "write file into a dos filesystem",
107 "<interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]\n"
108 " - write file 'filename' from the address 'addr' in RAM\n"
109 " to 'dev' on 'interface'"
112 static int do_fat_rm(struct cmd_tbl *cmdtp, int flag, int argc,
115 return do_rm(cmdtp, flag, argc, argv, FS_TYPE_FAT);
119 fatrm, 4, 1, do_fat_rm,
121 "<interface> [<dev[:part]>] <filename>\n"
122 " - delete a file from 'dev' on 'interface'"
125 static int do_fat_mkdir(struct cmd_tbl *cmdtp, int flag, int argc,
128 return do_mkdir(cmdtp, flag, argc, argv, FS_TYPE_FAT);
132 fatmkdir, 4, 1, do_fat_mkdir,
133 "create a directory",
134 "<interface> [<dev[:part]>] <directory>\n"
135 " - create a directory in 'dev' on 'interface'"