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>
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(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
37 struct blk_desc *dev_desc = NULL;
38 struct disk_partition 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(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
81 char *filename = NULL;
83 ulong addr = 0, filelen;
84 struct disk_partition info;
85 struct blk_desc *dev_desc = NULL;
91 addr_str = env_get("loadaddr");
92 if (addr_str != NULL) {
93 addr = simple_strtoul (addr_str, NULL, 16);
95 addr = CONFIG_SYS_LOAD_ADDR;
97 filename = env_get("bootfile");
101 addr = simple_strtoul (argv[3], NULL, 16);
102 filename = env_get("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 */
157 image_load_addr = addr;
159 printf ("\n%ld bytes read\n", filelen);
160 env_set_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"