3 * Richard Jones, rjones@nexus-tech.net
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
36 int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
42 block_dev_desc_t *dev_desc=NULL;
43 disk_partition_t info;
47 printf("usage: fatload <interface> [<dev[:part]>] "
48 "<addr> <filename> [bytes]\n");
52 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info);
57 if (fat_register_device(dev_desc,part)!=0) {
58 printf("\n** Unable to use %s %d:%d for fatload **\n",
62 offset = simple_strtoul(argv[3], NULL, 16);
64 count = simple_strtoul(argv[5], NULL, 16);
67 size = file_fat_read(argv[4], (unsigned char *)offset, count);
70 printf("\n** Unable to read \"%s\" from %s %d:%d **\n",
71 argv[4], argv[1], dev, part);
75 printf("\n%ld bytes read\n", size);
77 sprintf(buf, "%lX", size);
78 setenv("filesize", buf);
85 fatload, 6, 0, do_fat_fsload,
86 "load binary file from a dos filesystem",
87 "<interface> [<dev[:part]>] <addr> <filename> [bytes]\n"
88 " - load binary file 'filename' from 'dev' on 'interface'\n"
89 " to address 'addr' from dos filesystem"
92 int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
96 block_dev_desc_t *dev_desc=NULL;
97 disk_partition_t info;
100 printf("usage: fatls <interface> [<dev[:part]>] [directory]\n");
104 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info);
109 if (fat_register_device(dev_desc,part)!=0) {
110 printf("\n** Unable to use %s %d:%d for fatls **\n",
115 ret = file_fat_ls(argv[3]);
117 ret = file_fat_ls(filename);
120 printf("No Fat FS detected\n");
125 fatls, 4, 1, do_fat_ls,
126 "list files in a directory (default /)",
127 "<interface> [<dev[:part]>] [directory]\n"
128 " - list files from 'dev' on 'interface' in a 'directory'"
131 int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
134 block_dev_desc_t *dev_desc;
135 disk_partition_t info;
138 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
142 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info);
147 if (fat_register_device(dev_desc,part)!=0) {
148 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
152 return file_fat_detectfs();
156 fatinfo, 3, 1, do_fat_fsinfo,
157 "print information about filesystem",
158 "<interface> [<dev[:part]>]\n"
159 " - print information about filesystem from 'dev' on 'interface'"
162 #ifdef CONFIG_FAT_WRITE
163 static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
164 int argc, char * const argv[])
169 block_dev_desc_t *dev_desc = NULL;
170 disk_partition_t info;
176 return cmd_usage(cmdtp);
178 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info);
184 if (fat_register_device(dev_desc, part) != 0) {
185 printf("\n** Unable to use %s %d:%d for fatwrite **\n",
189 addr = simple_strtoul(argv[3], NULL, 16);
190 count = simple_strtoul(argv[5], NULL, 16);
192 size = file_fat_write(argv[4], (void *)addr, count);
194 printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
195 argv[4], argv[1], dev, part);
199 printf("%ld bytes written\n", size);
205 fatwrite, 6, 0, do_fat_fswrite,
206 "write file into a dos filesystem",
207 "<interface> <dev[:part]> <addr> <filename> <bytes>\n"
208 " - write file 'filename' from the address 'addr' in RAM\n"
209 " to 'dev' on 'interface'"