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;
48 printf( "usage: fatload <interface> <dev[:part]> "
49 "<addr> <filename> [bytes]\n");
53 dev = (int)simple_strtoul(argv[2], &ep, 16);
54 dev_desc = get_dev(argv[1],dev);
55 if (dev_desc == NULL) {
56 puts("\n** Invalid boot device **\n");
61 puts("\n** Invalid boot device, use `dev[:part]' **\n");
64 part = (int)simple_strtoul(++ep, NULL, 16);
66 if (fat_register_device(dev_desc,part)!=0) {
67 printf("\n** Unable to use %s %d:%d for fatload **\n",
71 offset = simple_strtoul(argv[3], NULL, 16);
73 count = simple_strtoul(argv[5], NULL, 16);
76 size = file_fat_read(argv[4], (unsigned char *)offset, count);
79 printf("\n** Unable to read \"%s\" from %s %d:%d **\n",
80 argv[4], argv[1], dev, part);
84 printf("\n%ld bytes read\n", size);
86 sprintf(buf, "%lX", size);
87 setenv("filesize", buf);
94 fatload, 6, 0, do_fat_fsload,
95 "load binary file from a dos filesystem",
96 "<interface> <dev[:part]> <addr> <filename> [bytes]\n"
97 " - load binary file 'filename' from 'dev' on 'interface'\n"
98 " to address 'addr' from dos filesystem"
101 int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
103 char *filename = "/";
108 block_dev_desc_t *dev_desc=NULL;
111 printf("usage: fatls <interface> <dev[:part]> [directory]\n");
114 dev = (int)simple_strtoul(argv[2], &ep, 16);
115 dev_desc = get_dev(argv[1],dev);
116 if (dev_desc == NULL) {
117 puts("\n** Invalid boot device **\n");
122 puts("\n** Invalid boot device, use `dev[:part]' **\n");
125 part = (int)simple_strtoul(++ep, NULL, 16);
127 if (fat_register_device(dev_desc,part)!=0) {
128 printf("\n** Unable to use %s %d:%d for fatls **\n",
133 ret = file_fat_ls(argv[3]);
135 ret = file_fat_ls(filename);
138 printf("No Fat FS detected\n");
143 fatls, 4, 1, do_fat_ls,
144 "list files in a directory (default /)",
145 "<interface> <dev[:part]> [directory]\n"
146 " - list files from 'dev' on 'interface' in a 'directory'"
149 int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
154 block_dev_desc_t *dev_desc=NULL;
157 printf("usage: fatinfo <interface> <dev[:part]>\n");
160 dev = (int)simple_strtoul(argv[2], &ep, 16);
161 dev_desc = get_dev(argv[1],dev);
162 if (dev_desc == NULL) {
163 puts("\n** Invalid boot device **\n");
168 puts("\n** Invalid boot device, use `dev[:part]' **\n");
171 part = (int)simple_strtoul(++ep, NULL, 16);
173 if (fat_register_device(dev_desc,part)!=0) {
174 printf("\n** Unable to use %s %d:%d for fatinfo **\n",
178 return file_fat_detectfs();
182 fatinfo, 3, 1, do_fat_fsinfo,
183 "print information about filesystem",
184 "<interface> <dev[:part]>\n"
185 " - print information about filesystem from 'dev' on 'interface'"