1 // SPDX-License-Identifier: GPL-2.0+
4 * Stefan Roese, DENX Software Engineering, sr@denx.de.
9 * UBIFS command support
17 #include <ubifs_uboot.h>
19 static int ubifs_initialized;
20 static int ubifs_mounted;
22 int cmd_ubifs_mount(char *vol_name)
26 debug("Using volume %s\n", vol_name);
28 if (ubifs_initialized == 0) {
30 ubifs_initialized = 1;
33 ret = uboot_ubifs_mount(vol_name);
41 static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
51 return cmd_ubifs_mount(vol_name);
54 int ubifs_is_mounted(void)
59 int cmd_ubifs_umount(void)
61 if (ubifs_initialized == 0) {
62 printf("No UBIFS volume mounted!\n");
68 ubifs_initialized = 0;
73 static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
79 return cmd_ubifs_umount();
82 static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
89 printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
95 debug("Using filename %s\n", filename);
97 ret = ubifs_ls(filename);
99 printf("** File not found %s **\n", filename);
100 ret = CMD_RET_FAILURE;
106 static int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc,
115 if (!ubifs_mounted) {
116 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
121 return CMD_RET_USAGE;
123 addr = simple_strtoul(argv[1], &endp, 16);
125 return CMD_RET_USAGE;
130 size = simple_strtoul(argv[3], &endp, 16);
132 return CMD_RET_USAGE;
134 debug("Loading file '%s' to address 0x%08x (size %d)\n", filename, addr, size);
136 ret = ubifs_load(filename, addr, size);
138 printf("** File not found %s **\n", filename);
139 ret = CMD_RET_FAILURE;
146 ubifsmount, 2, 0, do_ubifs_mount,
147 "mount UBIFS volume",
149 " - mount 'volume-name' volume"
153 ubifsumount, 1, 0, do_ubifs_umount,
154 "unmount UBIFS volume",
155 " - unmount current volume"
159 ubifsls, 2, 0, do_ubifs_ls,
160 "list files in a directory",
162 " - list files in a 'directory' (default '/')"
166 ubifsload, 4, 0, do_ubifs_load,
167 "load file from an UBIFS filesystem",
168 "<addr> <filename> [bytes]\n"
169 " - load file 'filename' to address 'addr'"