1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2003 - 2004
4 * Sysgo Real-Time Solutions, AG <www.elinos.com>
5 * Pavel Bartusek <pba@sysgo.com>
15 #include <linux/ctype.h>
16 #include <asm/byteorder.h>
20 #if !CONFIG_IS_ENABLED(DOS_PARTITION)
21 #error DOS partition support must be selected
24 /* #define REISER_DEBUG */
27 #define PRINTF(fmt,args...) printf (fmt ,##args)
29 #define PRINTF(fmt,args...)
32 int do_reiserls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
36 struct blk_desc *dev_desc = NULL;
37 disk_partition_t info;
42 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
50 dev = dev_desc->devnum;
51 PRINTF("Using device %s %d:%d, directory: %s\n", argv[1], dev, part, filename);
53 reiserfs_set_blk_dev(dev_desc, &info);
55 if (!reiserfs_mount(info.size)) {
56 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
60 if (reiserfs_ls (filename)) {
61 printf ("** Error reiserfs_ls() **\n");
69 reiserls, 4, 1, do_reiserls,
70 "list files in a directory (default /)",
71 "<interface> <dev[:part]> [directory]\n"
72 " - list files from 'dev' on 'interface' in a 'directory'"
75 /******************************************************************************
76 * Reiserfs boot command intepreter. Derived from diskboot
78 int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
80 char *filename = NULL;
82 ulong addr = 0, filelen;
83 disk_partition_t info;
84 struct blk_desc *dev_desc = NULL;
90 addr_str = env_get("loadaddr");
91 if (addr_str != NULL) {
92 addr = simple_strtoul (addr_str, NULL, 16);
94 addr = CONFIG_SYS_LOAD_ADDR;
96 filename = env_get("bootfile");
100 addr = simple_strtoul (argv[3], NULL, 16);
101 filename = env_get("bootfile");
105 addr = simple_strtoul (argv[3], NULL, 16);
110 addr = simple_strtoul (argv[3], NULL, 16);
112 count = simple_strtoul (argv[5], NULL, 16);
116 return CMD_RET_USAGE;
120 puts ("\n** No boot file defined **\n");
124 part = blk_get_device_part_str(argv[1], argv[2], &dev_desc, &info, 1);
128 dev = dev_desc->devnum;
130 printf("Loading file \"%s\" from %s device %d%c%c\n",
131 filename, argv[1], dev,
132 part ? ':' : ' ', part ? part + '0' : ' ');
134 reiserfs_set_blk_dev(dev_desc, &info);
136 if (!reiserfs_mount(info.size)) {
137 printf ("** Bad Reiserfs partition or disk - %s %d:%d **\n", argv[1], dev, part);
141 filelen = reiserfs_open(filename);
143 printf("** File not found %s **\n", filename);
146 if ((count < filelen) && (count != 0)) {
150 if (reiserfs_read((char *)addr, filelen) != filelen) {
151 printf("\n** Unable to read \"%s\" from %s %d:%d **\n", filename, argv[1], dev, part);
155 /* Loading ok, update default load address */
158 printf ("\n%ld bytes read\n", filelen);
159 env_set_hex("filesize", filelen);
165 reiserload, 6, 0, do_reiserload,
166 "load binary file from a Reiser filesystem",
167 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
168 " - load binary file 'filename' from 'dev' on 'interface'\n"
169 " to address 'addr' from dos filesystem"