]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - cmd/ubifs.c
1 // SPDX-License-Identifier: GPL-2.0+
4 * Stefan Roese, DENX Software Engineering, sr@denx.de.
9 * UBIFS command support
18 #include <ubifs_uboot.h>
20 static int ubifs_initialized
;
21 static int ubifs_mounted
;
23 int cmd_ubifs_mount(char *vol_name
)
27 debug("Using volume %s\n", vol_name
);
29 if (ubifs_initialized
== 0) {
31 ubifs_initialized
= 1;
34 ret
= uboot_ubifs_mount(vol_name
);
36 return CMD_RET_FAILURE
;
43 static int do_ubifs_mount(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
53 return cmd_ubifs_mount(vol_name
);
56 int ubifs_is_mounted(void)
61 int cmd_ubifs_umount(void)
63 if (ubifs_initialized
== 0) {
64 printf("No UBIFS volume mounted!\n");
65 return CMD_RET_FAILURE
;
70 ubifs_initialized
= 0;
75 static int do_ubifs_umount(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
81 return cmd_ubifs_umount();
84 static int do_ubifs_ls(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
91 printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
92 return CMD_RET_FAILURE
;
97 debug("Using filename %s\n", filename
);
99 ret
= ubifs_ls(filename
);
101 printf("** File not found %s **\n", filename
);
102 ret
= CMD_RET_FAILURE
;
108 static int do_ubifs_load(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
117 if (!ubifs_mounted
) {
118 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
119 return CMD_RET_FAILURE
;
123 return CMD_RET_USAGE
;
125 addr
= hextoul(argv
[1], &endp
);
127 return CMD_RET_USAGE
;
132 size
= hextoul(argv
[3], &endp
);
134 return CMD_RET_USAGE
;
136 debug("Loading file '%s' to address 0x%08lx (size %d)\n", filename
, addr
, size
);
138 ret
= ubifs_load(filename
, addr
, size
);
140 printf("** File not found %s **\n", filename
);
141 ret
= CMD_RET_FAILURE
;
148 ubifsmount
, 2, 0, do_ubifs_mount
,
149 "mount UBIFS volume",
151 " - mount 'volume-name' volume"
155 ubifsumount
, 1, 0, do_ubifs_umount
,
156 "unmount UBIFS volume",
157 " - unmount current volume"
161 ubifsls
, 2, 0, do_ubifs_ls
,
162 "list files in a directory",
164 " - list files in a 'directory' (default '/')"
168 ubifsload
, 4, 0, do_ubifs_load
,
169 "load file from an UBIFS filesystem",
170 "<addr> <filename> [bytes]\n"
171 " - load file 'filename' to address 'addr'"