blob: 4791b69fd96d0bf526fa5bab83b54ae88668930c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Uma Shankar71014b62012-05-25 21:21:44 +05302/*
3 * (C) Copyright 2011 - 2012 Samsung Electronics
4 * EXT4 filesystem implementation in Uboot by
5 * Uma Shankar <uma.shankar@samsung.com>
6 * Manjunatha C Achar <a.manjunatha@samsung.com>
7 *
8 * Ext4fs support
9 * made from existing cmd_ext2.c file of Uboot
10 *
11 * (C) Copyright 2004
12 * esd gmbh <www.esd-electronics.com>
13 * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
14 *
15 * made from cmd_reiserfs by
16 *
17 * (C) Copyright 2003 - 2004
18 * Sysgo Real-Time Solutions, AG <www.elinos.com>
19 * Pavel Bartusek <pba@sysgo.com>
Uma Shankar71014b62012-05-25 21:21:44 +053020 */
21
22/*
23 * Changelog:
24 * 0.1 - Newly created file for ext4fs support. Taken from cmd_ext2.c
25 * file in uboot. Added ext4fs ls load and write support.
26 */
27
28#include <common.h>
29#include <part.h>
30#include <config.h>
31#include <command.h>
32#include <image.h>
33#include <linux/ctype.h>
34#include <asm/byteorder.h>
Uma Shankar71014b62012-05-25 21:21:44 +053035#include <ext4fs.h>
36#include <linux/stat.h>
37#include <malloc.h>
Stephen Warreneefbc3f2012-10-22 06:43:51 +000038#include <fs.h>
Uma Shankar71014b62012-05-25 21:21:44 +053039
40#if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
41#include <usb.h>
42#endif
43
Simon Glassed38aef2020-05-10 11:40:03 -060044int do_ext4_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Stephen Warren3eb58f52014-06-11 12:47:26 -060045{
46 return do_size(cmdtp, flag, argc, argv, FS_TYPE_EXT);
47}
48
Simon Glassed38aef2020-05-10 11:40:03 -060049int do_ext4_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Uma Shankar71014b62012-05-25 21:21:44 +053050{
Wolfgang Denka10c7a52013-10-05 21:07:25 +020051 return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT);
Uma Shankar71014b62012-05-25 21:21:44 +053052}
53
Simon Glassed38aef2020-05-10 11:40:03 -060054int do_ext4_ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Uma Shankar71014b62012-05-25 21:21:44 +053055{
Stephen Warreneefbc3f2012-10-22 06:43:51 +000056 return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EXT);
Uma Shankar71014b62012-05-25 21:21:44 +053057}
58
Uma Shankara74a99a2012-05-25 21:22:49 +053059#if defined(CONFIG_CMD_EXT4_WRITE)
Simon Glassed38aef2020-05-10 11:40:03 -060060int do_ext4_write(struct cmd_tbl *cmdtp, int flag, int argc,
Suriyan Ramasamib3a2d5a2014-11-17 14:39:36 -080061 char *const argv[])
Uma Shankara74a99a2012-05-25 21:22:49 +053062{
Suriyan Ramasamib3a2d5a2014-11-17 14:39:36 -080063 return do_save(cmdtp, flag, argc, argv, FS_TYPE_EXT);
Uma Shankara74a99a2012-05-25 21:22:49 +053064}
65
Suriyan Ramasamib3a2d5a2014-11-17 14:39:36 -080066U_BOOT_CMD(ext4write, 7, 1, do_ext4_write,
67 "create a file in the root directory",
68 "<interface> <dev[:part]> <addr> <absolute filename path>\n"
69 " [sizebytes] [file offset]\n"
70 " - create a file in / directory");
Uma Shankara74a99a2012-05-25 21:22:49 +053071
72#endif
73
Stephen Warren3eb58f52014-06-11 12:47:26 -060074U_BOOT_CMD(
75 ext4size, 4, 0, do_ext4_size,
76 "determine a file's size",
77 "<interface> <dev[:part]> <filename>\n"
78 " - Find file 'filename' from 'dev' on 'interface'\n"
79 " and determine its size."
80);
81
Uma Shankar71014b62012-05-25 21:21:44 +053082U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls,
83 "list files in a directory (default /)",
84 "<interface> <dev[:part]> [directory]\n"
Stephen Warrenefd4a312012-10-30 12:04:18 +000085 " - list files from 'dev' on 'interface' in a 'directory'");
Uma Shankar71014b62012-05-25 21:21:44 +053086
Suriyan Ramasamib3a2d5a2014-11-17 14:39:36 -080087U_BOOT_CMD(ext4load, 7, 0, do_ext4_load,
Uma Shankar71014b62012-05-25 21:21:44 +053088 "load binary file from a Ext4 filesystem",
Pavel Machek3d8b2932014-07-29 12:37:25 +020089 "<interface> [<dev[:part]> [addr [filename [bytes [pos]]]]]\n"
Stephen Warrenefd4a312012-10-30 12:04:18 +000090 " - load binary file 'filename' from 'dev' on 'interface'\n"
Wolfgang Denka10c7a52013-10-05 21:07:25 +020091 " to address 'addr' from ext4 filesystem");