Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 2 | /* |
| 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 Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 20 | */ |
| 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 | |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 28 | #include <part.h> |
| 29 | #include <config.h> |
| 30 | #include <command.h> |
| 31 | #include <image.h> |
| 32 | #include <linux/ctype.h> |
| 33 | #include <asm/byteorder.h> |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 34 | #include <ext4fs.h> |
| 35 | #include <linux/stat.h> |
| 36 | #include <malloc.h> |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 37 | #include <fs.h> |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 38 | |
| 39 | #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) |
| 40 | #include <usb.h> |
| 41 | #endif |
| 42 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 43 | int do_ext4_size(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 44 | { |
| 45 | return do_size(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
| 46 | } |
| 47 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 48 | int do_ext4_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 49 | { |
Wolfgang Denk | a10c7a5 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 50 | return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 51 | } |
| 52 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 53 | int do_ext4_ls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 54 | { |
Stephen Warren | eefbc3f | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 55 | return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 56 | } |
| 57 | |
Uma Shankar | a74a99a | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 58 | #if defined(CONFIG_CMD_EXT4_WRITE) |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 59 | int do_ext4_write(struct cmd_tbl *cmdtp, int flag, int argc, |
Suriyan Ramasami | b3a2d5a | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 60 | char *const argv[]) |
Uma Shankar | a74a99a | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 61 | { |
Suriyan Ramasami | b3a2d5a | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 62 | return do_save(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
Uma Shankar | a74a99a | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 63 | } |
| 64 | |
Suriyan Ramasami | b3a2d5a | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 65 | U_BOOT_CMD(ext4write, 7, 1, do_ext4_write, |
| 66 | "create a file in the root directory", |
| 67 | "<interface> <dev[:part]> <addr> <absolute filename path>\n" |
| 68 | " [sizebytes] [file offset]\n" |
| 69 | " - create a file in / directory"); |
Uma Shankar | a74a99a | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 70 | |
| 71 | #endif |
| 72 | |
Stephen Warren | 3eb58f5 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 73 | U_BOOT_CMD( |
| 74 | ext4size, 4, 0, do_ext4_size, |
| 75 | "determine a file's size", |
| 76 | "<interface> <dev[:part]> <filename>\n" |
| 77 | " - Find file 'filename' from 'dev' on 'interface'\n" |
| 78 | " and determine its size." |
| 79 | ); |
| 80 | |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 81 | U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls, |
| 82 | "list files in a directory (default /)", |
| 83 | "<interface> <dev[:part]> [directory]\n" |
Stephen Warren | efd4a31 | 2012-10-30 12:04:18 +0000 | [diff] [blame] | 84 | " - list files from 'dev' on 'interface' in a 'directory'"); |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 85 | |
Suriyan Ramasami | b3a2d5a | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 86 | U_BOOT_CMD(ext4load, 7, 0, do_ext4_load, |
Uma Shankar | 71014b6 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 87 | "load binary file from a Ext4 filesystem", |
Pavel Machek | 3d8b293 | 2014-07-29 12:37:25 +0200 | [diff] [blame] | 88 | "<interface> [<dev[:part]> [addr [filename [bytes [pos]]]]]\n" |
Stephen Warren | efd4a31 | 2012-10-30 12:04:18 +0000 | [diff] [blame] | 89 | " - load binary file 'filename' from 'dev' on 'interface'\n" |
Wolfgang Denk | a10c7a5 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 90 | " to address 'addr' from ext4 filesystem"); |