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[])
40 unsigned long count = 0;
41 unsigned long pos = 0;
43 block_dev_desc_t *dev_desc=NULL;
44 disk_partition_t info;
48 printf("usage: fatload <interface> [<dev[:part]>] "
49 "<addr> <filename> [bytes [pos]]\n");
53 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
58 if (fat_register_device(dev_desc,part)!=0) {
59 printf("\n** Unable to use %s %d:%d for fatload **\n",
63 offset = simple_strtoul(argv[3], NULL, 16);
65 count = simple_strtoul(argv[5], NULL, 16);
67 pos = simple_strtoul(argv[6], NULL, 16);
68 size = file_fat_read_at(argv[4], pos, (unsigned char *)offset, count);
71 printf("\n** Unable to read \"%s\" from %s %d:%d **\n",
72 argv[4], argv[1], dev, part);
76 printf("\n%ld bytes read\n", size);
78 sprintf(buf, "%lX", size);
79 setenv("filesize", buf);
86 fatload, 7, 0, do_fat_fsload,
87 "load binary file from a dos filesystem",
88 "<interface> [<dev[:part]>] <addr> <filename> [bytes [pos]]\n"
89 " - Load binary file 'filename' from 'dev' on 'interface'\n"
90 " to address 'addr' from dos filesystem.\n"
91 " 'pos' gives the file position to start loading from.\n"
92 " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
93 " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
94 " the load stops on end of file."
97 int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
101 block_dev_desc_t *dev_desc=NULL;
102 disk_partition_t info;
105 printf("usage: fatls <interface> [<dev[:part]>] [directory]\n");
109 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
114 if (fat_register_device(dev_desc,part)!=0) {
115 printf("\n** Unable to use %s %d:%d for fatls **\n",
120 ret = file_fat_ls(argv[3]);
122 ret = file_fat_ls(filename);
125 printf("No Fat FS detected\n");
130 fatls, 4, 1, do_fat_ls,
131 "list files in a directory (default /)",
132 "<interface> [<dev[:part]>] [directory]\n"
133 " - list files from 'dev' on 'interface' in a 'directory'"
136 int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
139 block_dev_desc_t *dev_desc;
140 disk_partition_t info;
143 printf("usage: fatinfo <interface> [<dev[:part]>]\n");
147 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
152 if (fat_register_device(dev_desc,part)!=0) {
153 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
157 return file_fat_detectfs();
161 fatinfo, 3, 1, do_fat_fsinfo,
162 "print information about filesystem",
163 "<interface> [<dev[:part]>]\n"
164 " - print information about filesystem from 'dev' on 'interface'"
167 #ifdef CONFIG_FAT_WRITE
168 static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
169 int argc, char * const argv[])
174 block_dev_desc_t *dev_desc = NULL;
175 disk_partition_t info;
180 return cmd_usage(cmdtp);
182 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
188 if (fat_register_device(dev_desc, part) != 0) {
189 printf("\n** Unable to use %s %d:%d for fatwrite **\n",
193 addr = simple_strtoul(argv[3], NULL, 16);
194 count = simple_strtoul(argv[5], NULL, 16);
196 size = file_fat_write(argv[4], (void *)addr, count);
198 printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
199 argv[4], argv[1], dev, part);
203 printf("%ld bytes written\n", size);
209 fatwrite, 6, 0, do_fat_fswrite,
210 "write file into a dos filesystem",
211 "<interface> <dev[:part]> <addr> <filename> <bytes>\n"
212 " - write file 'filename' from the address 'addr' in RAM\n"
213 " to 'dev' on 'interface'"