2 * (C) Copyright 2003 - 2004
3 * Sysgo Real-Time Solutions, AG <www.elinos.com>
4 * Pavel Bartusek <pba@sysgo.com>
6 * SPDX-License-Identifier: GPL-2.0+
16 #include <linux/ctype.h>
17 #include <asm/byteorder.h>
21 #if !CONFIG_IS_ENABLED(DOS_PARTITION)
22 #error DOS partition support must be selected
25 /* #define REISER_DEBUG */
28 #define PRINTF(fmt,args...) printf (fmt ,##args)
30 #define PRINTF(fmt,args...)
33 int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
37 struct blk_desc *dev_desc = NULL;
38 disk_partition_t info;
43 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
51 dev = dev_desc->devnum;
52 PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
54 reiserfs_set_blk_dev(dev_desc, &info);
56 if (!reiserfs_mount(info.size)) {
57 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
61 if (reiserfs_ls (filename)) {
62 printf ("** Error reiserfs_ls() **\n");
70 reiserls, 4, 1, do_reiserls,
71 "list files in a directory (default /)",
72 "<interface> <dev[:part]> [directory]\n"
73 " - list files from 'dev' on 'interface' in a 'directory'"
76 /******************************************************************************
77 * Reiserfs boot command intepreter. Derived from diskboot
79 int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
81 char *filename = NULL;
83 ulong addr = 0, filelen;
84 disk_partition_t info;
85 struct blk_desc *dev_desc = NULL;
91 addr_str = getenv("loadaddr");
92 if (addr_str != NULL) {
93 addr = simple_strtoul (addr_str, NULL, 16);
95 addr = CONFIG_SYS_LOAD_ADDR;
97 filename = getenv ("bootfile");
101 addr = simple_strtoul (argv[3], NULL, 16);
102 filename = getenv ("bootfile");
106 addr = simple_strtoul (argv[3], NULL, 16);
111 addr = simple_strtoul (argv[3], NULL, 16);
113 count = simple_strtoul (argv[5], NULL, 16);
117 return CMD_RET_USAGE;
121 puts ("\n** No boot file defined **\n");
125 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
129 dev = dev_desc->devnum;
131 printf("Loading file \"%s\" from %s device %d%c%c\n",
132 filename, argv[1], dev,
133 part ? ':' : ' ', part ? part + '0' : ' ');
135 reiserfs_set_blk_dev(dev_desc, &info);
137 if (!reiserfs_mount(info.size)) {
138 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
142 filelen = reiserfs_open(filename);
144 printf("** File not found %s **\n", filename);
147 if ((count < filelen) && (count != 0)) {
151 if (reiserfs_read((char *)addr, filelen) != filelen) {
152 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
156 /* Loading ok, update default load address */
159 printf ("\n%ld bytes read\n", filelen);
160 setenv_hex("filesize", filelen);
166 reiserload, 6, 0, do_reiserload,
167 "load binary file from a Reiser filesystem",
168 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
169 " - load binary file 'filename' from 'dev' on 'interface'\n"
170 " to address 'addr' from dos filesystem"