3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * UBIFS command support
36 #include "../fs/ubifs/ubifs.h"
38 static int ubifs_initialized;
39 static int ubifs_mounted;
41 extern struct super_block *ubifs_sb;
45 int ubifs_mount(char *vol_name);
46 void ubifs_umount(struct ubifs_info *c);
47 int ubifs_ls(char *dir_name);
48 int ubifs_load(char *filename, u32 addr, u32 size);
50 int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
56 return cmd_usage(cmdtp);
59 debug("Using volume %s\n", vol_name);
61 if (ubifs_initialized == 0) {
63 ubifs_initialized = 1;
66 ret = ubifs_mount(vol_name);
75 int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
78 return cmd_usage(cmdtp);
80 if (ubifs_initialized == 0) {
81 printf("No UBIFS volume mounted!\n");
86 ubifs_umount(ubifs_sb->s_fs_info);
90 ubifs_initialized = 0;
95 int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
100 if (!ubifs_mounted) {
101 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
107 debug("Using filename %s\n", filename);
109 ret = ubifs_ls(filename);
111 printf("%s not found!\n", filename);
116 int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
124 if (!ubifs_mounted) {
125 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
130 return cmd_usage(cmdtp);
132 addr = simple_strtoul(argv[1], &endp, 16);
134 return cmd_usage(cmdtp);
139 size = simple_strtoul(argv[3], &endp, 16);
141 return cmd_usage(cmdtp);
143 debug("Loading file '%s' to address 0x%08x (size %d)\n", filename, addr, size);
145 ret = ubifs_load(filename, addr, size);
147 printf("%s not found!\n", filename);
153 ubifsmount, 2, 0, do_ubifs_mount,
154 "mount UBIFS volume",
156 " - mount 'volume-name' volume"
160 ubifsumount, 1, 0, do_ubifs_umount,
161 "unmount UBIFS volume",
162 " - unmount current volume"
166 ubifsls, 2, 0, do_ubifs_ls,
167 "list files in a directory",
169 " - list files in a 'directory' (default '/')"
173 ubifsload, 4, 0, do_ubifs_load,
174 "load file from an UBIFS filesystem",
175 "<addr> <filename> [bytes]\n"
176 " - load file 'filename' to address 'addr'"