2 * (C) Copyright 2003 - 2004
3 * Sysgo Real-Time Solutions, AG <www.elinos.com>
4 * Pavel Bartusek <pba@sysgo.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <linux/ctype.h>
34 #include <asm/byteorder.h>
38 #ifndef CONFIG_DOS_PARTITION
39 #error DOS partition support must be selected
42 /* #define REISER_DEBUG */
45 #define PRINTF(fmt,args...) printf (fmt ,##args)
47 #define PRINTF(fmt,args...)
50 int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
56 block_dev_desc_t *dev_desc=NULL;
60 return cmd_usage(cmdtp);
62 dev = (int)simple_strtoul (argv[2], &ep, 16);
63 dev_desc = get_dev(argv[1],dev);
65 if (dev_desc == NULL) {
66 printf ("\n** Block device %s %d not supported\n", argv[1], dev);
72 puts ("\n** Invalid boot device, use `dev[:part]' **\n");
75 part = (int)simple_strtoul(++ep, NULL, 16);
82 PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
84 if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) {
85 printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
89 if (!reiserfs_mount(part_length)) {
90 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
94 if (reiserfs_ls (filename)) {
95 printf ("** Error reiserfs_ls() **\n");
103 reiserls, 4, 1, do_reiserls,
104 "list files in a directory (default /)",
105 "<interface> <dev[:part]> [directory]\n"
106 " - list files from 'dev' on 'interface' in a 'directory'"
109 /******************************************************************************
110 * Reiserfs boot command intepreter. Derived from diskboot
112 int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
114 char *filename = NULL;
117 ulong addr = 0, part_length, filelen;
118 disk_partition_t info;
119 block_dev_desc_t *dev_desc = NULL;
126 addr_str = getenv("loadaddr");
127 if (addr_str != NULL) {
128 addr = simple_strtoul (addr_str, NULL, 16);
130 addr = CONFIG_SYS_LOAD_ADDR;
132 filename = getenv ("bootfile");
136 addr = simple_strtoul (argv[3], NULL, 16);
137 filename = getenv ("bootfile");
141 addr = simple_strtoul (argv[3], NULL, 16);
146 addr = simple_strtoul (argv[3], NULL, 16);
148 count = simple_strtoul (argv[5], NULL, 16);
152 return cmd_usage(cmdtp);
156 puts ("\n** No boot file defined **\n");
160 dev = (int)simple_strtoul (argv[2], &ep, 16);
161 dev_desc = get_dev(argv[1],dev);
162 if (dev_desc==NULL) {
163 printf ("\n** Block device %s %d not supported\n", argv[1], dev);
168 puts ("\n** Invalid boot device, use `dev[:part]' **\n");
171 part = (int)simple_strtoul(++ep, NULL, 16);
174 PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part);
177 if (get_partition_info (dev_desc, part, &info)) {
178 printf ("** Bad partition %d **\n", part);
182 if (strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) {
183 printf ("\n** Invalid partition type \"%.32s\""
184 " (expect \"" BOOT_PART_TYPE "\")\n",
188 PRINTF ("\nLoading from block device %s device %d, partition %d: "
189 "Name: %.32s Type: %.32s File:%s\n",
190 argv[1], dev, part, info.name, info.type, filename);
192 PRINTF ("\nLoading from block device %s device %d, File:%s\n",
193 argv[1], dev, filename);
197 if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) {
198 printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
202 if (!reiserfs_mount(part_length)) {
203 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
207 filelen = reiserfs_open(filename);
209 printf("** File not found %s\n", filename);
212 if ((count < filelen) && (count != 0)) {
216 if (reiserfs_read((char *)addr, filelen) != filelen) {
217 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
221 /* Loading ok, update default load address */
224 printf ("\n%ld bytes read\n", filelen);
225 sprintf(buf, "%lX", filelen);
226 setenv("filesize", buf);
232 reiserload, 6, 0, do_reiserload,
233 "load binary file from a Reiser filesystem",
234 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
235 " - load binary file 'filename' from 'dev' on 'interface'\n"
236 " to address 'addr' from dos filesystem"