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,
31 #if defined(CONFIG_CMD_REISER)
35 #include <linux/ctype.h>
36 #include <asm/byteorder.h>
40 #ifndef CONFIG_DOS_PARTITION
41 #error DOS partition support must be selected
44 /* #define REISER_DEBUG */
47 #define PRINTF(fmt,args...) printf (fmt ,##args)
49 #define PRINTF(fmt,args...)
52 int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
58 block_dev_desc_t *dev_desc=NULL;
62 printf ("Usage:\n%s\n", cmdtp->usage);
65 dev = (int)simple_strtoul (argv[2], &ep, 16);
66 dev_desc = get_dev(argv[1],dev);
68 if (dev_desc == NULL) {
69 printf ("\n** Block device %s %d not supported\n", argv[1], dev);
75 puts ("\n** Invalid boot device, use `dev[:part]' **\n");
78 part = (int)simple_strtoul(++ep, NULL, 16);
85 PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
87 if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) {
88 printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
92 if (!reiserfs_mount(part_length)) {
93 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
97 if (reiserfs_ls (filename)) {
98 printf ("** Error reiserfs_ls() **\n");
106 reiserls, 4, 1, do_reiserls,
107 "reiserls- list files in a directory (default /)\n",
108 "<interface> <dev[:part]> [directory]\n"
109 " - list files from 'dev' on 'interface' in a 'directory'\n"
112 /******************************************************************************
113 * Reiserfs boot command intepreter. Derived from diskboot
115 int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
117 char *filename = NULL;
120 ulong addr = 0, part_length, filelen;
121 disk_partition_t info;
122 block_dev_desc_t *dev_desc = NULL;
129 addr_str = getenv("loadaddr");
130 if (addr_str != NULL) {
131 addr = simple_strtoul (addr_str, NULL, 16);
133 addr = CFG_LOAD_ADDR;
135 filename = getenv ("bootfile");
139 addr = simple_strtoul (argv[3], NULL, 16);
140 filename = getenv ("bootfile");
144 addr = simple_strtoul (argv[3], NULL, 16);
149 addr = simple_strtoul (argv[3], NULL, 16);
151 count = simple_strtoul (argv[5], NULL, 16);
155 printf ("Usage:\n%s\n", cmdtp->usage);
160 puts ("\n** No boot file defined **\n");
164 dev = (int)simple_strtoul (argv[2], &ep, 16);
165 dev_desc = get_dev(argv[1],dev);
166 if (dev_desc==NULL) {
167 printf ("\n** Block device %s %d not supported\n", argv[1], dev);
172 puts ("\n** Invalid boot device, use `dev[:part]' **\n");
175 part = (int)simple_strtoul(++ep, NULL, 16);
178 PRINTF("Using device %s%d, partition %d\n", argv[1], dev, part);
181 if (get_partition_info (dev_desc, part, &info)) {
182 printf ("** Bad partition %d **\n", part);
186 if (strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) {
187 printf ("\n** Invalid partition type \"%.32s\""
188 " (expect \"" BOOT_PART_TYPE "\")\n",
192 PRINTF ("\nLoading from block device %s device %d, partition %d: "
193 "Name: %.32s Type: %.32s File:%s\n",
194 argv[1], dev, part, info.name, info.type, filename);
196 PRINTF ("\nLoading from block device %s device %d, File:%s\n",
197 argv[1], dev, filename);
201 if ((part_length = reiserfs_set_blk_dev(dev_desc, part)) == 0) {
202 printf ("** Bad partition - %s %d:%d **\n", argv[1], dev, part);
206 if (!reiserfs_mount(part_length)) {
207 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
211 filelen = reiserfs_open(filename);
213 printf("** File not found %s\n", filename);
216 if ((count < filelen) && (count != 0)) {
220 if (reiserfs_read((char *)addr, filelen) != filelen) {
221 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
225 /* Loading ok, update default load address */
228 printf ("\n%ld bytes read\n", filelen);
229 sprintf(buf, "%lX", filelen);
230 setenv("filesize", buf);
236 reiserload, 6, 0, do_reiserload,
237 "reiserload- load binary file from a Reiser filesystem\n",
238 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
239 " - load binary file 'filename' from 'dev' on 'interface'\n"
240 " to address 'addr' from dos filesystem\n"