]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cmd/ubifs.c
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
10 * UBIFS command support
18 #include <ubifs_uboot.h>
20 static int ubifs_initialized
;
21 static int ubifs_mounted
;
23 static int do_ubifs_mount(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
33 debug("Using volume %s\n", vol_name
);
35 if (ubifs_initialized
== 0) {
37 ubifs_initialized
= 1;
40 ret
= uboot_ubifs_mount(vol_name
);
49 int ubifs_is_mounted(void)
54 void cmd_ubifs_umount(void)
58 ubifs_initialized
= 0;
61 static int do_ubifs_umount(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
67 if (ubifs_initialized
== 0) {
68 printf("No UBIFS volume mounted!\n");
77 static int do_ubifs_ls(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
84 printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
90 debug("Using filename %s\n", filename
);
92 ret
= ubifs_ls(filename
);
94 printf("** File not found %s **\n", filename
);
95 ret
= CMD_RET_FAILURE
;
101 static int do_ubifs_load(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
110 if (!ubifs_mounted
) {
111 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
116 return CMD_RET_USAGE
;
118 addr
= simple_strtoul(argv
[1], &endp
, 16);
120 return CMD_RET_USAGE
;
125 size
= simple_strtoul(argv
[3], &endp
, 16);
127 return CMD_RET_USAGE
;
129 debug("Loading file '%s' to address 0x%08x (size %d)\n", filename
, addr
, size
);
131 ret
= ubifs_load(filename
, addr
, size
);
133 printf("** File not found %s **\n", filename
);
134 ret
= CMD_RET_FAILURE
;
141 ubifsmount
, 2, 0, do_ubifs_mount
,
142 "mount UBIFS volume",
144 " - mount 'volume-name' volume"
148 ubifsumount
, 1, 0, do_ubifs_umount
,
149 "unmount UBIFS volume",
150 " - unmount current volume"
154 ubifsls
, 2, 0, do_ubifs_ls
,
155 "list files in a directory",
157 " - list files in a 'directory' (default '/')"
161 ubifsload
, 4, 0, do_ubifs_load
,
162 "load file from an UBIFS filesystem",
163 "<addr> <filename> [bytes]\n"
164 " - load file 'filename' to address 'addr'"