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[])
54 block_dev_desc_t *dev_desc=NULL;
55 disk_partition_t info;
60 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
69 PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
71 reiserfs_set_blk_dev(dev_desc, &info);
73 if (!reiserfs_mount(info.size)) {
74 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
78 if (reiserfs_ls (filename)) {
79 printf ("** Error reiserfs_ls() **\n");
87 reiserls, 4, 1, do_reiserls,
88 "list files in a directory (default /)",
89 "<interface> <dev[:part]> [directory]\n"
90 " - list files from 'dev' on 'interface' in a 'directory'"
93 /******************************************************************************
94 * Reiserfs boot command intepreter. Derived from diskboot
96 int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
98 char *filename = NULL;
100 ulong addr = 0, filelen;
101 disk_partition_t info;
102 block_dev_desc_t *dev_desc = NULL;
109 addr_str = getenv("loadaddr");
110 if (addr_str != NULL) {
111 addr = simple_strtoul (addr_str, NULL, 16);
113 addr = CONFIG_SYS_LOAD_ADDR;
115 filename = getenv ("bootfile");
119 addr = simple_strtoul (argv[3], NULL, 16);
120 filename = getenv ("bootfile");
124 addr = simple_strtoul (argv[3], NULL, 16);
129 addr = simple_strtoul (argv[3], NULL, 16);
131 count = simple_strtoul (argv[5], NULL, 16);
135 return CMD_RET_USAGE;
139 puts ("\n** No boot file defined **\n");
143 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
149 printf("Loading file \"%s\" from %s device %d%c%c\n",
150 filename, argv[1], dev,
151 part ? ':' : ' ', part ? part + '0' : ' ');
153 reiserfs_set_blk_dev(dev_desc, &info);
155 if (!reiserfs_mount(info.size)) {
156 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
160 filelen = reiserfs_open(filename);
162 printf("** File not found %s\n", filename);
165 if ((count < filelen) && (count != 0)) {
169 if (reiserfs_read((char *)addr, filelen) != filelen) {
170 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
174 /* Loading ok, update default load address */
177 printf ("\n%ld bytes read\n", filelen);
178 sprintf(buf, "%lX", filelen);
179 setenv("filesize", buf);
185 reiserload, 6, 0, do_reiserload,
186 "load binary file from a Reiser filesystem",
187 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
188 " - load binary file 'filename' from 'dev' on 'interface'\n"
189 " to address 'addr' from dos filesystem"