1 // SPDX-License-Identifier: GPL-2.0+
9 * UBIFS command support
17 #include <ubifs_uboot.h>
19 static int ubifs_initialized;
20 static int ubifs_mounted;
22 static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
32 debug("Using volume %s\n", vol_name);
34 if (ubifs_initialized == 0) {
36 ubifs_initialized = 1;
39 ret = uboot_ubifs_mount(vol_name);
48 int ubifs_is_mounted(void)
53 void cmd_ubifs_umount(void)
57 ubifs_initialized = 0;
60 static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
66 if (ubifs_initialized == 0) {
67 printf("No UBIFS volume mounted!\n");
76 static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
83 printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
89 debug("Using filename %s\n", filename);
91 ret = ubifs_ls(filename);
93 printf("** File not found %s **\n", filename);
94 ret = CMD_RET_FAILURE;
100 static int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc,
109 if (!ubifs_mounted) {
110 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
115 return CMD_RET_USAGE;
117 addr = simple_strtoul(argv[1], &endp, 16);
119 return CMD_RET_USAGE;
124 size = simple_strtoul(argv[3], &endp, 16);
126 return CMD_RET_USAGE;
128 debug("Loading file '%s' to address 0x%08x (size %d)\n", filename, addr, size);
130 ret = ubifs_load(filename, addr, size);
132 printf("** File not found %s **\n", filename);
133 ret = CMD_RET_FAILURE;
140 ubifsmount, 2, 0, do_ubifs_mount,
141 "mount UBIFS volume",
143 " - mount 'volume-name' volume"
147 ubifsumount, 1, 0, do_ubifs_umount,
148 "unmount UBIFS volume",
149 " - unmount current volume"
153 ubifsls, 2, 0, do_ubifs_ls,
154 "list files in a directory",
156 " - list files in a 'directory' (default '/')"
160 ubifsload, 4, 0, do_ubifs_load,
161 "load file from an UBIFS filesystem",
162 "<addr> <filename> [bytes]\n"
163 " - load file 'filename' to address 'addr'"