]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_ext4.c
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>
8 * made from existing cmd_ext2.c file of Uboot
11 * esd gmbh <www.esd-electronics.com>
12 * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
14 * made from cmd_reiserfs by
16 * (C) Copyright 2003 - 2004
17 * Sysgo Real-Time Solutions, AG <www.elinos.com>
18 * Pavel Bartusek <pba@sysgo.com>
20 * SPDX-License-Identifier: GPL-2.0+
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.
34 #include <linux/ctype.h>
35 #include <asm/byteorder.h>
37 #include <linux/stat.h>
41 #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
45 int do_ext4_load(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
48 return do_load(cmdtp
, flag
, argc
, argv
, FS_TYPE_EXT
);
51 int do_ext4_ls(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
53 return do_ls(cmdtp
, flag
, argc
, argv
, FS_TYPE_EXT
);
56 #if defined(CONFIG_CMD_EXT4_WRITE)
57 int do_ext4_write(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
60 const char *filename
= "/";
62 unsigned long ram_address
;
63 unsigned long file_size
;
64 disk_partition_t info
;
65 block_dev_desc_t
*dev_desc
;
68 return cmd_usage(cmdtp
);
70 part
= get_device_and_partition(argv
[1], argv
[2], &dev_desc
, &info
, 1);
76 /* get the filename */
79 /* get the address in hexadecimal format (string to int) */
80 ram_address
= simple_strtoul(argv
[3], NULL
, 16);
82 /* get the filesize in base 10 format */
83 file_size
= simple_strtoul(argv
[5], NULL
, 10);
85 /* set the device as block device */
86 ext4fs_set_blk_dev(dev_desc
, &info
);
88 /* mount the filesystem */
89 if (!ext4fs_mount(info
.size
)) {
90 printf("Bad ext4 partition %s %d:%d\n", argv
[1], dev
, part
);
95 if (ext4fs_write(filename
, (unsigned char *)ram_address
, file_size
)) {
96 printf("** Error ext4fs_write() **\n");
109 U_BOOT_CMD(ext4write
, 6, 1, do_ext4_write
,
110 "create a file in the root directory",
111 "<interface> <dev[:part]> <addr> <absolute filename path> [sizebytes]\n"
112 " - create a file in / directory");
116 U_BOOT_CMD(ext4ls
, 4, 1, do_ext4_ls
,
117 "list files in a directory (default /)",
118 "<interface> <dev[:part]> [directory]\n"
119 " - list files from 'dev' on 'interface' in a 'directory'");
121 U_BOOT_CMD(ext4load
, 6, 0, do_ext4_load
,
122 "load binary file from a Ext4 filesystem",
123 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
124 " - load binary file 'filename' from 'dev' on 'interface'\n"
125 " to address 'addr' from ext4 filesystem");