]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_reiser.c
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 *argv
[])
56 block_dev_desc_t
*dev_desc
=NULL
;
63 dev
= (int)simple_strtoul (argv
[2], &ep
, 16);
64 dev_desc
= get_dev(argv
[1],dev
);
66 if (dev_desc
== NULL
) {
67 printf ("\n** Block device %s %d not supported\n", argv
[1], dev
);
73 puts ("\n** Invalid boot device, use `dev[:part]' **\n");
76 part
= (int)simple_strtoul(++ep
, NULL
, 16);
83 PRINTF("Using device %s %d:%d, directory: %s\n", argv
[1], dev
, part
, filename
);
85 if ((part_length
= reiserfs_set_blk_dev(dev_desc
, part
)) == 0) {
86 printf ("** Bad partition - %s %d:%d **\n", argv
[1], dev
, part
);
90 if (!reiserfs_mount(part_length
)) {
91 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv
[1], dev
, part
);
95 if (reiserfs_ls (filename
)) {
96 printf ("** Error reiserfs_ls() **\n");
104 reiserls
, 4, 1, do_reiserls
,
105 "list files in a directory (default /)",
106 "<interface> <dev[:part]> [directory]\n"
107 " - list files from 'dev' on 'interface' in a 'directory'"
110 /******************************************************************************
111 * Reiserfs boot command intepreter. Derived from diskboot
113 int do_reiserload (cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
115 char *filename
= NULL
;
118 ulong addr
= 0, part_length
, filelen
;
119 disk_partition_t info
;
120 block_dev_desc_t
*dev_desc
= NULL
;
127 addr_str
= getenv("loadaddr");
128 if (addr_str
!= NULL
) {
129 addr
= simple_strtoul (addr_str
, NULL
, 16);
131 addr
= CONFIG_SYS_LOAD_ADDR
;
133 filename
= getenv ("bootfile");
137 addr
= simple_strtoul (argv
[3], NULL
, 16);
138 filename
= getenv ("bootfile");
142 addr
= simple_strtoul (argv
[3], NULL
, 16);
147 addr
= simple_strtoul (argv
[3], NULL
, 16);
149 count
= simple_strtoul (argv
[5], NULL
, 16);
158 puts ("\n** No boot file defined **\n");
162 dev
= (int)simple_strtoul (argv
[2], &ep
, 16);
163 dev_desc
= get_dev(argv
[1],dev
);
164 if (dev_desc
==NULL
) {
165 printf ("\n** Block device %s %d not supported\n", argv
[1], dev
);
170 puts ("\n** Invalid boot device, use `dev[:part]' **\n");
173 part
= (int)simple_strtoul(++ep
, NULL
, 16);
176 PRINTF("Using device %s%d, partition %d\n", argv
[1], dev
, part
);
179 if (get_partition_info (dev_desc
, part
, &info
)) {
180 printf ("** Bad partition %d **\n", part
);
184 if (strncmp((char *)info
.type
, BOOT_PART_TYPE
, sizeof(info
.type
)) != 0) {
185 printf ("\n** Invalid partition type \"%.32s\""
186 " (expect \"" BOOT_PART_TYPE
"\")\n",
190 PRINTF ("\nLoading from block device %s device %d, partition %d: "
191 "Name: %.32s Type: %.32s File:%s\n",
192 argv
[1], dev
, part
, info
.name
, info
.type
, filename
);
194 PRINTF ("\nLoading from block device %s device %d, File:%s\n",
195 argv
[1], dev
, filename
);
199 if ((part_length
= reiserfs_set_blk_dev(dev_desc
, part
)) == 0) {
200 printf ("** Bad partition - %s %d:%d **\n", argv
[1], dev
, part
);
204 if (!reiserfs_mount(part_length
)) {
205 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv
[1], dev
, part
);
209 filelen
= reiserfs_open(filename
);
211 printf("** File not found %s\n", filename
);
214 if ((count
< filelen
) && (count
!= 0)) {
218 if (reiserfs_read((char *)addr
, filelen
) != filelen
) {
219 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename
, argv
[1], dev
, part
);
223 /* Loading ok, update default load address */
226 printf ("\n%ld bytes read\n", filelen
);
227 sprintf(buf
, "%lX", filelen
);
228 setenv("filesize", buf
);
234 reiserload
, 6, 0, do_reiserload
,
235 "load binary file from a Reiser filesystem",
236 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
237 " - load binary file 'filename' from 'dev' on 'interface'\n"
238 " to address 'addr' from dos filesystem"