Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2011 - 2012 Samsung Electronics |
| 3 | * EXT4 filesystem implementation in Uboot by |
| 4 | * Uma Shankar <uma.shankar@samsung.com> |
| 5 | * Manjunatha C Achar <a.manjunatha@samsung.com> |
| 6 | * |
| 7 | * Ext4fs support |
| 8 | * made from existing cmd_ext2.c file of Uboot |
| 9 | * |
| 10 | * (C) Copyright 2004 |
| 11 | * esd gmbh <www.esd-electronics.com> |
| 12 | * Reinhard Arlt <reinhard.arlt@esd-electronics.com> |
| 13 | * |
| 14 | * made from cmd_reiserfs by |
| 15 | * |
| 16 | * (C) Copyright 2003 - 2004 |
| 17 | * Sysgo Real-Time Solutions, AG <www.elinos.com> |
| 18 | * Pavel Bartusek <pba@sysgo.com> |
| 19 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 20 | * SPDX-License-Identifier: GPL-2.0+ |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * Changelog: |
| 25 | * 0.1 - Newly created file for ext4fs support. Taken from cmd_ext2.c |
| 26 | * file in uboot. Added ext4fs ls load and write support. |
| 27 | */ |
| 28 | |
| 29 | #include <common.h> |
| 30 | #include <part.h> |
| 31 | #include <config.h> |
| 32 | #include <command.h> |
| 33 | #include <image.h> |
| 34 | #include <linux/ctype.h> |
| 35 | #include <asm/byteorder.h> |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 36 | #include <ext4fs.h> |
| 37 | #include <linux/stat.h> |
| 38 | #include <malloc.h> |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 39 | #include <fs.h> |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 40 | |
| 41 | #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE) |
| 42 | #include <usb.h> |
| 43 | #endif |
| 44 | |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 45 | int do_ext4_size(cmd_tbl_t *cmdtp, int flag, int argc, |
| 46 | char *const argv[]) |
| 47 | { |
| 48 | return do_size(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
| 49 | } |
| 50 | |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 51 | int do_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc, |
| 52 | char *const argv[]) |
| 53 | { |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 54 | return do_load(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | int do_ext4_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) |
| 58 | { |
Stephen Warren | 045fa1e | 2012-10-22 06:43:51 +0000 | [diff] [blame] | 59 | return do_ls(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 60 | } |
| 61 | |
Uma Shankar | ed34f34 | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 62 | #if defined(CONFIG_CMD_EXT4_WRITE) |
Uma Shankar | ed34f34 | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 63 | int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc, |
Suriyan Ramasami | 9f12cd0 | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 64 | char *const argv[]) |
Uma Shankar | ed34f34 | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 65 | { |
Suriyan Ramasami | 9f12cd0 | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 66 | return do_save(cmdtp, flag, argc, argv, FS_TYPE_EXT); |
Uma Shankar | ed34f34 | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 67 | } |
| 68 | |
Suriyan Ramasami | 9f12cd0 | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 69 | U_BOOT_CMD(ext4write, 7, 1, do_ext4_write, |
| 70 | "create a file in the root directory", |
| 71 | "<interface> <dev[:part]> <addr> <absolute filename path>\n" |
| 72 | " [sizebytes] [file offset]\n" |
| 73 | " - create a file in / directory"); |
Uma Shankar | ed34f34 | 2012-05-25 21:22:49 +0530 | [diff] [blame] | 74 | |
| 75 | #endif |
| 76 | |
Stephen Warren | cf65981 | 2014-06-11 12:47:26 -0600 | [diff] [blame] | 77 | U_BOOT_CMD( |
| 78 | ext4size, 4, 0, do_ext4_size, |
| 79 | "determine a file's size", |
| 80 | "<interface> <dev[:part]> <filename>\n" |
| 81 | " - Find file 'filename' from 'dev' on 'interface'\n" |
| 82 | " and determine its size." |
| 83 | ); |
| 84 | |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 85 | U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls, |
| 86 | "list files in a directory (default /)", |
| 87 | "<interface> <dev[:part]> [directory]\n" |
Stephen Warren | b6a3044 | 2012-10-30 12:04:18 +0000 | [diff] [blame] | 88 | " - list files from 'dev' on 'interface' in a 'directory'"); |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 89 | |
Suriyan Ramasami | 9f12cd0 | 2014-11-17 14:39:36 -0800 | [diff] [blame] | 90 | U_BOOT_CMD(ext4load, 7, 0, do_ext4_load, |
Uma Shankar | a159643 | 2012-05-25 21:21:44 +0530 | [diff] [blame] | 91 | "load binary file from a Ext4 filesystem", |
Pavel Machek | 2a72dcc | 2014-07-29 12:37:25 +0200 | [diff] [blame] | 92 | "<interface> [<dev[:part]> [addr [filename [bytes [pos]]]]]\n" |
Stephen Warren | b6a3044 | 2012-10-30 12:04:18 +0000 | [diff] [blame] | 93 | " - load binary file 'filename' from 'dev' on 'interface'\n" |
Wolfgang Denk | b770e88 | 2013-10-05 21:07:25 +0200 | [diff] [blame] | 94 | " to address 'addr' from ext4 filesystem"); |