1 // SPDX-License-Identifier: GPL-2.0+
4 * Richard Jones, rjones@nexus-tech.net
15 #include <asm/cache.h>
17 static 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
);
36 fatload
, 7, 0, do_fat_fsload
,
37 "load binary file from a dos filesystem",
38 "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
39 " - Load binary file 'filename' from 'dev' on 'interface'\n"
40 " to address 'addr' from dos filesystem.\n"
41 " 'pos' gives the file position to start loading from.\n"
42 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
43 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
44 " the load stops on end of file.\n"
45 " If either 'pos' or 'bytes' are not aligned to\n"
46 " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
47 " be printed and performance will suffer for the load."
50 static int do_fat_ls(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
53 return do_ls(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
57 fatls
, 4, 1, do_fat_ls
,
58 "list files in a directory (default /)",
59 "<interface> [<dev[:part]>] [directory]\n"
60 " - list files from 'dev' on 'interface' in a 'directory'"
63 static int do_fat_fsinfo(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
67 struct blk_desc
*dev_desc
;
68 struct disk_partition info
;
71 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
75 part
= blk_get_device_part_str(argv
[1], argv
[2], &dev_desc
, &info
, 1);
79 dev
= dev_desc
->devnum
;
80 if (fat_set_blk_dev(dev_desc
, &info
) != 0) {
81 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
85 return file_fat_detectfs();
89 fatinfo
, 3, 1, do_fat_fsinfo
,
90 "print information about filesystem",
91 "<interface> [<dev[:part]>]\n"
92 " - print information about filesystem from 'dev' on 'interface'"
95 #ifdef CONFIG_FAT_WRITE
96 static int do_fat_fswrite(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
99 return do_save(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
103 fatwrite
, 7, 0, do_fat_fswrite
,
104 "write file into a dos filesystem",
105 "<interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]\n"
106 " - write file 'filename' from the address 'addr' in RAM\n"
107 " to 'dev' on 'interface'"
110 static int do_fat_rm(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
113 return do_rm(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
117 fatrm
, 4, 1, do_fat_rm
,
119 "<interface> [<dev[:part]>] <filename>\n"
120 " - delete a file from 'dev' on 'interface'"
123 static int do_fat_mkdir(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
126 return do_mkdir(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
130 fatmkdir
, 4, 1, do_fat_mkdir
,
131 "create a directory",
132 "<interface> [<dev[:part]>] <directory>\n"
133 " - create a directory in 'dev' on 'interface'"