]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - cmd/fat.c
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
,
106 struct blk_desc
*dev_desc
= NULL
;
107 struct disk_partition info
;
113 return cmd_usage(cmdtp
);
115 part
= blk_get_device_part_str(argv
[1], argv
[2], &dev_desc
, &info
, 1);
119 dev
= dev_desc
->devnum
;
121 if (fat_set_blk_dev(dev_desc
, &info
) != 0) {
122 printf("\n** Unable to use %s %d:%d for fatwrite **\n",
126 addr
= simple_strtoul(argv
[3], NULL
, 16);
127 count
= (argc
<= 5) ? 0 : simple_strtoul(argv
[5], NULL
, 16);
128 /* offset should be a hex, but "-1" is allowed */
129 offset
= (argc
<= 6) ? 0 : simple_strtol(argv
[6], NULL
, 16);
131 buf
= map_sysmem(addr
, count
);
132 ret
= file_fat_write(argv
[4], buf
, offset
, 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
, 7, 0, do_fat_fswrite
,
147 "write file into a dos filesystem",
148 "<interface> <dev[:part]> <addr> <filename> [<bytes> [<offset>]]\n"
149 " - write file 'filename' from the address 'addr' in RAM\n"
150 " to 'dev' on 'interface'"
153 static int do_fat_rm(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
156 return do_rm(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
160 fatrm
, 4, 1, do_fat_rm
,
162 "<interface> [<dev[:part]>] <filename>\n"
163 " - delete a file from 'dev' on 'interface'"
166 static int do_fat_mkdir(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
169 return do_mkdir(cmdtp
, flag
, argc
, argv
, FS_TYPE_FAT
);
173 fatmkdir
, 4, 1, do_fat_mkdir
,
174 "create a directory",
175 "<interface> [<dev[:part]>] <directory>\n"
176 " - create a directory in 'dev' on 'interface'"