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 ubifs_is_mounted(void)
80 void cmd_ubifs_umount(void)
84 printf("Unmounting UBIFS volume %s!\n",
85 ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name);
86 ubifs_umount(ubifs_sb->s_fs_info);
91 ubifs_initialized = 0;
94 int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
97 return cmd_usage(cmdtp);
99 if (ubifs_initialized == 0) {
100 printf("No UBIFS volume mounted!\n");
109 int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
111 char *filename = "/";
114 if (!ubifs_mounted) {
115 printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
121 debug("Using filename %s\n", filename);
123 ret = ubifs_ls(filename);
125 printf("%s not found!\n", filename);
130 int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
138 if (!ubifs_mounted) {
139 printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
144 return cmd_usage(cmdtp);
146 addr = simple_strtoul(argv[1], &endp, 16);
148 return cmd_usage(cmdtp);
153 size = simple_strtoul(argv[3], &endp, 16);
155 return cmd_usage(cmdtp);
157 debug("Loading file '%s' to address 0x%08x (size %d)\n", filename, addr, size);
159 ret = ubifs_load(filename, addr, size);
161 printf("%s not found!\n", filename);
167 ubifsmount, 2, 0, do_ubifs_mount,
168 "mount UBIFS volume",
170 " - mount 'volume-name' volume"
174 ubifsumount, 1, 0, do_ubifs_umount,
175 "unmount UBIFS volume",
176 " - unmount current volume"
180 ubifsls, 2, 0, do_ubifs_ls,
181 "list files in a directory",
183 " - list files in a 'directory' (default '/')"
187 ubifsload, 4, 0, do_ubifs_load,
188 "load file from an UBIFS filesystem",
189 "<addr> <filename> [bytes]\n"
190 " - load file 'filename' to address 'addr'"