Blame view
cmd/ubifs.c
2.81 KB
ce6d0c8de UBIFS: Add UBIFS ... |
1 2 3 4 |
/* * (C) Copyright 2008 * Stefan Roese, DENX Software Engineering, sr@denx.de. * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
ce6d0c8de UBIFS: Add UBIFS ... |
6 7 8 9 10 11 12 13 14 15 16 17 |
*/ /* * UBIFS command support */ #undef DEBUG #include <common.h> #include <config.h> #include <command.h> |
ad15749b6 ubifs: Modify ubi... |
18 |
#include <ubifs_uboot.h> |
cb9c09d48 UBIFS: Add ubifsu... |
19 |
|
ce6d0c8de UBIFS: Add UBIFS ... |
20 21 |
static int ubifs_initialized; static int ubifs_mounted; |
0e350f81e common: commands:... |
22 23 |
static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
ce6d0c8de UBIFS: Add UBIFS ... |
24 25 26 |
{ char *vol_name; int ret; |
47e26b1bf cmd_usage(): simp... |
27 |
if (argc != 2) |
4c12eeb8b Convert cmd_usage... |
28 |
return CMD_RET_USAGE; |
47e26b1bf cmd_usage(): simp... |
29 |
|
ce6d0c8de UBIFS: Add UBIFS ... |
30 31 32 33 34 35 36 37 |
vol_name = argv[1]; debug("Using volume %s ", vol_name); if (ubifs_initialized == 0) { ubifs_init(); ubifs_initialized = 1; } |
ff94bc40a mtd, ubi, ubifs: ... |
38 |
ret = uboot_ubifs_mount(vol_name); |
ce6d0c8de UBIFS: Add UBIFS ... |
39 40 41 42 43 44 45 |
if (ret) return -1; ubifs_mounted = 1; return 0; } |
2f15cfd18 UBI/UBIFS: Automa... |
46 47 48 49 50 51 52 |
int ubifs_is_mounted(void) { return ubifs_mounted; } void cmd_ubifs_umount(void) { |
ad15749b6 ubifs: Modify ubi... |
53 |
uboot_ubifs_umount(); |
2f15cfd18 UBI/UBIFS: Automa... |
54 55 56 |
ubifs_mounted = 0; ubifs_initialized = 0; } |
0e350f81e common: commands:... |
57 58 |
static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
cb9c09d48 UBIFS: Add ubifsu... |
59 60 |
{ if (argc != 1) |
4c12eeb8b Convert cmd_usage... |
61 |
return CMD_RET_USAGE; |
cb9c09d48 UBIFS: Add ubifsu... |
62 63 64 65 66 67 |
if (ubifs_initialized == 0) { printf("No UBIFS volume mounted! "); return -1; } |
2f15cfd18 UBI/UBIFS: Automa... |
68 |
cmd_ubifs_umount(); |
cb9c09d48 UBIFS: Add ubifsu... |
69 70 71 |
return 0; } |
0e350f81e common: commands:... |
72 73 |
static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
ce6d0c8de UBIFS: Add UBIFS ... |
74 75 76 77 78 |
{ char *filename = "/"; int ret; if (!ubifs_mounted) { |
9a2ea578b UBIFS: Change "ub... |
79 80 |
printf("UBIFS not mounted, use ubifsmount to mount volume first! "); |
ce6d0c8de UBIFS: Add UBIFS ... |
81 82 83 84 85 86 87 88 89 |
return -1; } if (argc == 2) filename = argv[1]; debug("Using filename %s ", filename); ret = ubifs_ls(filename); |
7cdebc328 cmd_ubifs: normal... |
90 91 92 93 94 |
if (ret) { printf("** File not found %s ** ", filename); ret = CMD_RET_FAILURE; } |
ce6d0c8de UBIFS: Add UBIFS ... |
95 96 97 |
return ret; } |
0e350f81e common: commands:... |
98 99 |
static int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
ce6d0c8de UBIFS: Add UBIFS ... |
100 101 |
{ char *filename; |
2896b5851 Command improveme... |
102 |
char *endp; |
ce6d0c8de UBIFS: Add UBIFS ... |
103 104 105 106 107 108 109 110 111 |
int ret; u32 addr; u32 size = 0; if (!ubifs_mounted) { printf("UBIFS not mounted, use ubifs mount to mount volume first! "); return -1; } |
47e26b1bf cmd_usage(): simp... |
112 |
if (argc < 3) |
4c12eeb8b Convert cmd_usage... |
113 |
return CMD_RET_USAGE; |
ce6d0c8de UBIFS: Add UBIFS ... |
114 |
|
2896b5851 Command improveme... |
115 |
addr = simple_strtoul(argv[1], &endp, 16); |
47e26b1bf cmd_usage(): simp... |
116 |
if (endp == argv[1]) |
4c12eeb8b Convert cmd_usage... |
117 |
return CMD_RET_USAGE; |
2896b5851 Command improveme... |
118 |
|
ce6d0c8de UBIFS: Add UBIFS ... |
119 |
filename = argv[2]; |
2896b5851 Command improveme... |
120 121 |
if (argc == 4) { size = simple_strtoul(argv[3], &endp, 16); |
47e26b1bf cmd_usage(): simp... |
122 |
if (endp == argv[3]) |
4c12eeb8b Convert cmd_usage... |
123 |
return CMD_RET_USAGE; |
2896b5851 Command improveme... |
124 |
} |
ce6d0c8de UBIFS: Add UBIFS ... |
125 126 127 128 |
debug("Loading file '%s' to address 0x%08x (size %d) ", filename, addr, size); ret = ubifs_load(filename, addr, size); |
7cdebc328 cmd_ubifs: normal... |
129 130 131 132 133 |
if (ret) { printf("** File not found %s ** ", filename); ret = CMD_RET_FAILURE; } |
ce6d0c8de UBIFS: Add UBIFS ... |
134 135 136 137 138 139 |
return ret; } U_BOOT_CMD( ubifsmount, 2, 0, do_ubifs_mount, |
852dbfdd5 more command usag... |
140 |
"mount UBIFS volume", |
2896b5851 Command improveme... |
141 142 143 |
"<volume-name> " " - mount 'volume-name' volume" |
a89c33db9 General help mess... |
144 |
); |
ce6d0c8de UBIFS: Add UBIFS ... |
145 |
|
388a29d02 various cmd_* fil... |
146 |
U_BOOT_CMD( |
cb9c09d48 UBIFS: Add ubifsu... |
147 148 149 150 151 152 |
ubifsumount, 1, 0, do_ubifs_umount, "unmount UBIFS volume", " - unmount current volume" ); U_BOOT_CMD( |
388a29d02 various cmd_* fil... |
153 |
ubifsls, 2, 0, do_ubifs_ls, |
a89c33db9 General help mess... |
154 155 156 157 158 |
"list files in a directory", "[directory] " " - list files in a 'directory' (default '/')" ); |
ce6d0c8de UBIFS: Add UBIFS ... |
159 |
|
388a29d02 various cmd_* fil... |
160 161 |
U_BOOT_CMD( ubifsload, 4, 0, do_ubifs_load, |
a89c33db9 General help mess... |
162 163 164 165 166 |
"load file from an UBIFS filesystem", "<addr> <filename> [bytes] " " - load file 'filename' to address 'addr'" ); |