ext4fs ls load support
A message that is not in the archive (sent off-list or not yet received): 27542660.71361332746650945.JavaMail.weblogic@epml04
PATCH v4 1/2 ext4fs ls load support
Dear UMA SHANKAR,
please do not top post / full quote.
Quoted 3 lines · In message <27542660.71361332746650945.JavaMail.weblogic@epml04> you wrote:
Currently, Our ext4 implementation is capable of listing and reading (ls and load) ext2 partitions as well. But, we wanted the ext4 code to be separate from ext2 implementation.
This does not make much sense to me.
Quoted 2 lines
So, I propose, we can let both these implementations be there in uboot under different CONFIG Options (as is the case currently).
What would be the rationale here?
I think more and more people are going to use ext4. It makes no sense to have different commands and different options to support both ext2 (and ext3, to some degree) and ext4 (and ext3?) file systems. And especially, it makes no sense to dusplicate large amounts of code.
Please use common code whererver possible.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I knew then (in 1970) that a 4-kbyte minicomputer would cost as much
as a house. So I reasoned that after college, I'd have to live
cheaply in an apartment and put all my money into owning a computer."
- Apple co-founder Steve Wozniak, EE Times, June 6, 1988, pg 45PATCH v4 1/2 ext4fs ls load support
In reply to a message not in the archiveQuoted 4 lines · UMA SHANKAR
Dear Rob Herring, Thanks for evaluating and testing our code. Currently, Our ext4 implementation is capable of listing and reading (ls and load) ext2 partitions as well. But, we wanted the ext4 code to be separate from ext2 implementation.
Why?
Quoted 5 lines
Your comment: --- Using ext2 commands on an ext4 partition will hang now.
ext2load command will only read ext2 partitions, and will definitely not work on ext4 (even without our implementation).
I'm not saying it should work, but it shouldn't hang. IIRC without your patch, it would return with an error. So you have changed something in the core ext2 code that makes it hang. But it's not something I think you need to worry about as the ext4 version of code should just replace the ext2 version and the issue will go away.
Rob
Quoted 353 lines
? So, I propose, we can let both these implementations be there in uboot under different CONFIG Options (as is the case currently). ? Thanks & Regards, Uma Shankar
------- Original Message ------- Sender : Rob Herring<[email protected]> Date : Mar 22, 2012 21:19 (GMT+05:30) Title : Re: [U-Boot] [PATCH V4 1/2] ext4fs ls load support
Quoted 15 lines · uma.shankar at samsung.com
From: uma.shankar
Signed-off-by: Uma Shankar Signed-off-by: Manjunatha C Achar
Signed-off-by: Iqbal Shareef Signed-off-by: Hakgoo Lee --- Changes for v3: - Copyright has been updated in respective files - ext4fs has been made independant ofext2fs.c- Fixed API namespace - Removed endianness conversion API, used uboot defined API for the same - Fixed coding style issues - Moved README.ext4 file into doc folderChanges for v2: - Code cleanup, changed comment style - camel case removed, resolved code alignment issues - memory allocation logic changed, removed busybox logic - Modified ext4 load to remove grub dependency (GPLv3) - Introduced new Config for ext4 write
Quoted 5 lines
Changes for v1: - Removed checkpatch warnings and errors - Moved common API's of ext2 and ext4 to one generic header file
Makefile| 2 +- common/Makefile | 1 +common/cmd_ext4.c| 266 +++++++++++++++I don't think we need yet another version of filesystem commands that just duplicates the same code.
I tested this patch and can read ext2 partitions with the ext4ls/load commands. Using ext2 commands on an ext4 partition will hang now. You should merge your ext4 command changes into the existing ext2 commands so that commands work on either ext2/3 or ext4 partitions.
Really, I would like to see all the block based device and file commands collapsed down into just fsls and fsload commands and then detect (or specify if necessary) the fs type. But that's a bigger problem.
Rob
Quoted 307 lines
fs/Makefile | 1 +
fs/ext2/dev.c| 1 +fs/ext2/ext2fs.c| 181 ++---------fs/ext4/Makefile|
51 +++fs/ext4/dev.c| 145 ++++++++fs/ext4/ext4_common.c
| 875 +++++++++++++++++++++++++++++++++++++++++++++++++fs/ext4/ext4_common.h| 63 ++++fs/ext4/ext4fs.c| 228
+++++++++++++include/ext4fs.h| 132 ++++++++include/ext_common.h| 188 +++++++++++ 13 files changed, 1977 insertions(+), 157 deletions(-) create mode 100644common/cmd_ext4.ccreate mode 100644fs/ext4/Makefilecreate mode 100644fs/ext4/dev.ccreate mode 100644fs/ext4/ext4_common.ccreate mode 100644fs/ext4/ext4_common.hcreate mode 100644fs/ext4/ext4fs.ccreate mode 100644include/ext4fs.hcreate mode 100644include/ext_common.hMakefile index 7e9491d..e77f6be 100644 --- renamed from Makefile +0
-0a/Makefile +++ b/Makefile @@ -235,7 +235,7 @@ LIBS +=
dts/libdts.oendif LIBS += arch/$(ARCH)/lib/lib$(ARCH).o LIBS +=fs/cramfs/libcramfs.ofs/fat/libfat.ofs/fdos/libfdos.ofs/jffs2/libjffs2.o\ -fs/reiserfs/libreiserfs.ofs/ext2/libext2fs.ofs/yaffs2/libyaffs2.o\ +fs/reiserfs/libreiserfs.ofs/ext2/libext2fs.ofs/ext4/libext4fs.ofs/yaffs2/libyaffs2.o\fs/ubifs/libubifs.oLIBS +=net/libnet.oLIBS +=disk/libdisk.odiff --git a/common/Makefile b/common/Makefile index 2d9ae8c..f5243f6 100644 --- a/common/Makefile +++ b/common/Makefile @@ -86,6 +86,7 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += cmd_eeprom.o COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o COBJS-$(CONFIG_SYS_HUSH_PARSER) += cmd_exit.o +COBJS-$(CONFIG_CMD_EXT4) += cmd_ext4.o COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o diff --gita/common/cmd_ext4.cb/common/cmd_ext4.cnew file mode 100644 index 0000000..2c53d2c ---/dev/null+++b/common/cmd_ext4.c@@ -0,0 +1,266 @@ +/* + * (C) Copyright 2011 - 2012 Samsung Electronics + * EXT4 filesystem implementation in Uboot by + * Uma Shankar + * Manjunatha C Achar + * + * Ext4fs support + * made from existingcmd_ext2.cfile of Uboot + * + * (C) Copyright 2004 + * esd gmbh +
* Reinhard Arlt + * + * made fromcmd_reiserfsby + * + * (C) Copyright 2003 - 2004 + * Sysgo Real-Time Solutions, AG + * Pavel Bartusek + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + */ + +/* + *
Changelog: + * 0.1 - Newly created file for ext4fs support. Taken
fromcmd_ext2.c+ * file in uboot. Added ext4fs ls and load
support. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdefined(CONFIG_CMD_USB)&&defined(CONFIG_USB_STORAGE)+#include +#endif + +#if !defined(CONFIG_DOS_PARTITION) && !defined(CONFIG_EFI_PARTITION) +#error DOS or EFI partition support must be selected +#endif + +uint64_ttotal_sector; +uint64_tpart_offset; + +#defineDOS_PART_MAGIC_OFFSET0x1fe+#defineDOS_FS_TYPE_OFFSET0x36+#defineDOS_FS32_TYPE_OFFSET0x52+ +static intdo_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[])+{ + char *filename = NULL; + char *ep; + int dev; + unsigned long part = 1; + ulong addr = 0; + ulongpart_length; + int filelen; +disk_partition_tinfo; + structext_filesystem*fs; + char buf[12]; + unsigned long count; + const char*addr_str; + + count = 0; + addr =simple_strtoul(argv[3], NULL, 16); + filename =getenv("bootfile"); + switch (argc) { + case 3: +addr_str=getenv("loadaddr"); + if (addr_str!= NULL) + addr =simple_strtoul(addr_str, NULL, 16); + else + addr =CONFIG_SYS_LOAD_ADDR; + + break; + case 4: + break; + case 5: + filename = argv[4]; + break; + case 6: + filename = argv[4]; + count =simple_strtoul(argv[5], NULL, 16); + break; + + default: + returncmd_usage(cmdtp); + } + + if (!filename) { +puts("** No boot file defined **\n"); + return 1; + } + + dev = (int)simple_strtoul(argv[2], &ep, 16); +ext4_dev_desc=get_dev(argv[1], dev); + if (ext4_dev_desc== NULL) { +printf("** Block device %s %d not supported\n", argv[1], dev); + return 1; + } + if (init_fs(ext4_dev_desc)) + return 1; + + fs =get_fs(); + if (*ep) { + if (*ep != ':') { + puts("** Invalid boot device, use `dev[:part]' **\n"); + return 1; + } + part =simple_strtoul(++ep, NULL, 16); + } + + if (part != 0) { + if (get_partition_info(fs->dev_desc, part, &info)) { +printf("** Bad partition %lu **\n", part); + return 1; + } + + if (strncmp((char
*)info.type,BOOT_PART_TYPE, +strlen(BOOT_PART_TYPE)) != 0) {
+ printf("** Invalid partition type \"%s\"" + " (expect \""BOOT_PART_TYPE"\")\n", info.type); + return 1; + } +
printf("Loading file \"%s\" " + "from %s device %d:%lu
%s\n", + filename, argv[1], dev, part, info.name); + } else
{ +printf("Loading file \"%s\" from %s device %d\n", + filename, argv[1], dev); + } + +part_length=ext4fs_set_blk_dev(fs->dev_desc, part); + if (part_length== 0) { +printf("**Bad partition - %s %d:%lu **\n", argv[1], dev, part); +ext4fs_close(); + return 1; + } + + if (!ext4fs_mount(part_length)) { +printf("** Bad ext2 partition or disk - %s %d:%lu **\n", + argv[1], dev, part); +ext4fs_close(); + return 1; + } + + filelen =ext4fs_open(filename); + if (filelen < 0) { +printf("** File not found %s\n", filename); +ext4fs_close(); + return 1; + } + if ((count < filelen) && (count != 0)) + filelen = count; + + if (ext4fs_read((char *)addr, filelen)!= filelen) { + printf("**
Unable to read \"%s\" from %s %d:%lu **\n", + filename,
argv[1], dev, part); +ext4fs_close(); + return 1; + } + +ext4fs_close(); +deinit_fs(fs->dev_desc); + /* Loading ok, update default load address */ +load_addr= addr; + +printf("%d bytes read\n", filelen); +sprintf(buf, "%X", filelen); +setenv("filesize", buf); + + return 0; +} + +static intdo_ext4_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])+{ + const char *filename = "/"; + int dev; + unsigned long part = 1; + char *ep; + structext_filesystem*fs; + intpart_length; + + if (argc < 3) + returncmd_usage(cmdtp); + + dev = (int)simple_strtoul(argv[2], &ep, 16); +ext4_dev_desc=get_dev(argv[1], dev); + + if (ext4_dev_desc== NULL) { +printf("\n** Block device %s %d not supported\n", argv[1], dev); + return 1; + } + + if (init_fs(ext4_dev_desc)) + return 1; + + fs =get_fs(); + if (*ep) { + if (*ep != ':') { + puts("\n** Invalid boot device, use `dev[:part]' **\n"); + return 1; + } + part =simple_strtoul(++ep, NULL, 16); + } + + if (argc == 4) + filename = argv[3]; + +part_length=ext4fs_set_blk_dev(fs->dev_desc, part);
+ if (part_length== 0) { +printf("** Bad partition - %s %d:%lu **\n", argv[1], dev, part); +ext4fs_close(); + return 1; + } + + if (!ext4fs_mount(part_length)) { + printf("** Bad ext2 partition
or disk - %s %d:%lu **\n", + argv[1], dev, part); +ext4fs_close(); + return 1; + } + if (ext4fs_ls(filename)) { +printf("** Error ext2fs_ls() **\n"); +ext4fs_close(); + return 1;
+ }; + +ext4fs_close(); +deinit_fs(fs->dev_desc); + + return 0;
+} + +U_BOOT_CMD(ext4ls, 4, 1,do_ext4_ls, + "list files in a
directory (default /)", + " [directory]\n" + " - list files
from 'dev' on 'interface' in a 'directory'"); +
+U_BOOT_CMD(ext4load, 6, 0,do_ext4_load, + "load binary file
from a Ext2 filesystem", + " [addr] [filename] [bytes]\n" + "
- load binary file 'filename' from 'dev' on 'interface'\n" + "
to address 'addr' from ext2 filesystem"); diff --git a/fs/Makefile b/fs/Makefile index 22aad12..00a8f37 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -23,6 +23,7 @@ #subdirs-$(CONFIG_CMD_CRAMFS) := cramfs +subdirs-$(CONFIG_CMD_EXT4) += ext4 subdirs-$(CONFIG_CMD_EXT2) += ext2 subdirs-$(CONFIG_CMD_FAT) += fat subdirs-$(CONFIG_CMD_FDOS) += fdos diff --git
a/fs/ext2/dev.cb/fs/ext2/dev.cindex 874e211..315ff53 100644 ---a/fs/ext2/dev.c+++b/fs/ext2/dev.c@@ -27,6 +27,7 @@ #include #include #include +#includestatic
block_dev_desc_t*ext2fs_block_dev_desc; staticdisk_partition_tpart_info; diff --gita/fs/ext2/ext2fs.cb/fs/ext2/ext2fs.cindex f621741..a4f3094 100644 ---a/fs/ext2/ext2fs.c+++b/fs/ext2/ext2fs.c@@ -25,152 +25,16 @@#include #include +#include #include #include
extern int
ext2fs_devread(int sector, intbyte_offset, intbyte_len, char *buf);-/* Magic value used to identify an ext2 filesystem. */ -#define
EXT2_MAGIC0xEF53-/* Amount of indirect blocks in an inode. */Makefile index 7e9491d..e77f6be 100644 --- renamed from Makefile +0
-2-#define INDIRECT_BLOCKS 12 -/* Maximum lenght of a pathname. */ -#define EXT2_PATH_MAX 4096 -/* Maximum nesting of symlinks, usedto prevent a loop. */ -#define
EXT2_MAX_SYMLINKCNT8 - -/* Filetype used in directory entry. */ -#defineFILETYPE_UNKNOWN0 -#defineFILETYPE_REG1 -#defineFILETYPE_DIRECTORY2 -#defineFILETYPE_SYMLINK7 - -/* Filetype information as used in inodes. */ -#defineFILETYPE_INO_MASK0170000 -#defineFILETYPE_INO_REG0100000 -#defineFILETYPE_INO_DIRECTORY0040000 -#defineFILETYPE_INO_SYMLINK0120000 - -/* Bits used as offset in sector
*/ -#defineDISK_SECTOR_BITS9 - -/* Log2 size of ext2 block
in 512 blocks. */ -#defineLOG2_EXT2_BLOCK_SIZE(data)(__le32_to_cpu(data->sblock.log2_block_size) + 1) - -/* Log2 size of ext2 block in bytes. */ -#defineLOG2_BLOCK_SIZE(data)(__le32_to_cpu(data->sblock.log2_block_size) + 10) - -/* The size
of an ext2 block in bytes. */ -#defineEXT2_BLOCK_SIZE(data)(1
<<LOG2_BLOCK_SIZE(data)) - -/* The ext2 superblock. */ -structext2_sblock{ -uint32_ttotal_inodes; -uint32_ttotal_blocks; -uint32_treserved_blocks; -uint32_tfree_blocks; -uint32_tfree_inodes; -uint32_tfirst_data_block; -uint32_tlog2_block_size; -uint32_tlog2_fragment_size; -uint32_tblocks_per_group; -uint32_tfragments_per_group; -uint32_tinodes_per_group; -uint32_tmtime; -uint32_tutime; -uint16_tmnt_count; -uint16_tmax_mnt_count; -uint16_tmagic; -uint16_tfs_state; -uint16_terror_handling; -uint16_tminor_revision_level; -uint32_tlastcheck; -uint32_tcheckinterval; -uint32_tcreator_os; -uint32_trevision_level; -uint16_tuid_reserved; -uint16_tgid_reserved; -uint32_tfirst_inode; -uint16_tinode_size; -uint16_tblock_group_number;
-uint32_tfeature_compatibility; -uint32_tfeature_incompat; -uint32_tfeature_ro_compat; -uint32_tunique_id[4]; - char volume_name[16]; - char last_mounted_on[64]; -uint32_tcompression_info; -}; - -/* The ext2 blockgroup. */ -structext2_block_group{ -uint32_tblock_id; -uint32_tinode_id; -uint32_tinode_table_id; -uint16_tfree_blocks; -uint16_tfree_inodes; -uint16_tused_dir_cnt; -uint32_treserved[3]; -};
- -/* The ext2 inode. */ -structext2_inode{ -uint16_tmode; -uint16_tuid; -uint32_tsize; -uint32_tatime; -uint32_tctime;
-uint32_tmtime; -uint32_tdtime; -uint16_tgid; -uint16_tnlinks; -uint32_tblockcnt; /* Blocks of 512 bytes!! */ -uint32_tflags; -uint32_tosd1; - union { - struct datablocks { -uint32_tdir_blocks[INDIRECT_BLOCKS]; -uint32_tindir_block; -uint32_tdouble_indir_block; -uint32_ttripple_indir_block; - } blocks; - char symlink[60]; - } b; -uint32_tversion; -uint32_tacl; -uint32_tdir_acl; -uint32_tfragment_addr; -uint32_tosd2[3]; -}; - -/* The header of an ext2 directory entry. */ -structext2_dirent{ -uint32_tinode; -uint16_tdirentlen; -uint8_tnamelen; -uint8_tfiletype; -}; - -structext2fs_node{ - structext2_data*data; - structext2_inodeinode; - int ino; - intinode_read; -}; - -/* Information about a "mounted" ext2 filesystem. */ -structext2_data{ - structext2_sblocksblock; - structext2_inode*inode; - structext2fs_nodediropen; -}; - - -typedef structext2fs_node*ext2fs_node_t;struct
ext2_data*ext2fs_root= NULL; -ext2fs_node_text2fs_file= NULL; +structext2fs_node*ext2fs_file; int symlinknest = 0;uint32_t*indir1_block= NULL; intindir1_size= 0; @@ -243,14 +107,16 @@ static intext2fs_read_inode}-void
ext2fs_free_node(ext2fs_node_tnode,ext2fs_node_tcurrroot) { +voidext2fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot)+{ if ((node !=&ext2fs_root->diropen) && (node != currroot)) { free (node); } }-static int
ext2fs_read_block(ext2fs_node_tnode, int fileblock) { +static intext2fs_read_block(struct ext2fs_node *node, int fileblock)+{ structext2_data*data =node->data; structext2_inode*inode =&node->inode; int blknr; @@ -396,7 +262,8 @@ static intext2fs_read_block(ext2fs_node_tnode, int fileblock) {int
ext2fs_read_file- (ext2fs_node_tnode, int pos, unsigned int len, char *buf) { + (structext2fs_node*node, int pos, unsigned int len, char *buf) +{ int i; int blockcnt; int log2blocksize =LOG2_EXT2_BLOCK_SIZE(node->data); @@ -455,8 +322,8 @@ intext2fs_read_filereturn (len); }- -static int
ext2fs_iterate_dir(ext2fs_node_tdir, char *name,ext2fs_node_t* fnode, int *ftype) +intext2fs_iterate_dir(struct ext2fs_node *dir, char *name, + struct ext2fs_node **fnode, int *ftype){ unsigned int fpos = 0; int status; @@ -485,7 +352,7 @@ static intext2fs_iterate_dir(ext2fs_node_tdir, char *name,ext2fs_node_t* fn } if (dirent.namelen != 0) { char filename[dirent.namelen + 1]; -ext2fs_node_tfdiro; + structext2fs_node*fdiro; int type =FILETYPE_UNKNOWN;status =
ext2fs_read_file(diro, @@ -587,8 +454,8 @@ static intext2fs_iterate_dir(ext2fs_node_tdir, char *name,ext2fs_node_t* fn return (0); }- -static char
*ext2fs_read_symlink(ext2fs_node_tnode) { +static char *ext2fs_read_symlink(structext2fs_node*node) +{ char *symlink; structext2fs_node*diro = node; int status; @@ -625,15 +492,16 @@ static char*ext2fs_read_symlink(ext2fs_node_tnode) {int
ext2fs_find_file1- (const char *currpath, -ext2fs_node_tcurrroot,ext2fs_node_t* currfound, int *foundtype) { + (const char *currpath, structext2fs_node*currroot, + structext2fs_node**currfound, int *foundtype) +{ char fpath[strlen (currpath) + 1]; char *name = fpath; char *next; int status; int type =FILETYPE_DIRECTORY; -ext2fs_node_tcurrnode = currroot; -ext2fs_node_toldnode = currroot; + structext2fs_node*currnode = currroot; + structext2fs_node*oldnode = currroot;strncpy (fpath, currpath, strlen (currpath) + 1);
Makefile index 7e9491d..e77f6be 100644 --- renamed from Makefile +0
-0@@ -729,8 +597,9 @@ int ext2fs_find_file1 int ext2fs_find_file - (const char *path, - ext2fs_node_t rootnode, ext2fs_node_t * foundnode, int expecttype) { + (const char *path,struct
ext2fs_node*rootnode, + structext2fs_node**foundnode, int expecttype) +{ int status; int foundtype =FILETYPE_DIRECTORY;Makefile index 7e9491d..e77f6be 100644 --- renamed from Makefile +0
-0@@ -756,7 +625,7 @@ int ext2fs_find_fileint
ext2fs_ls(const char *dirname) { -ext2fs_node_tdirnode; + structext2fs_node*dirnode; int status;if (
ext2fs_root== NULL) { @@ -776,7 +645,7 @@ intext2fs_ls(const char *dirname) {int
ext2fs_open(const char *filename) { -ext2fs_node_tfdiro = NULL; + structext2fs_node*fdiro = NULL; int status; int len;Makefile index 7e9491d..e77f6be 100644 --- renamed from Makefile +0
-1@@ -806,8 +675,8 @@ fail: } -int ext2fs_close (void - ) { +int ext2fs_close(void) +{ if((
ext2fs_file!= NULL) && (ext2fs_root!= NULL)) {ext2fs_free_node(ext2fs_file,&ext2fs_root->diropen);ext2fs_file= NULL; diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile new file mode 100644 index 0000000..7add4ab ---/dev/null+++ b/fs/ext4/Makefile @@ -0,0 +1,51 @@ +# +# (C) Copyright 2006 +# Wolfgang Denk, DENX Software Engineering, wd at denx.de. +# +# (C) Copyright 2003 +# Pavel Bartusek, Sysgo Real-Time Solutions AG, pba at sysgo.de +# +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +LIB =
Quoted 8 lines
Quoted 8 lines
$(obj)libext4fs.o + +AOBJS = +COBJS-$(CONFIG_CMD_EXT4) := ext4fs.o ext4_common.o dev.o + +SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y)) + + +all: $(LIB) $(AOBJS) + +$(LIB): $(obj).depend $(OBJS) + $(call
cmd_link_o_target, $(OBJS)) +
+#########################################################################
+
Quoted 5 lines
Makefile index 7e9491d..e77f6be 100644 ---
Quoted 5 lines
Makefile index 7e9491d..e77f6be 100644 --- renamed from Makefile +3
-0+# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +#########################################################################
fs/ext4/dev.c +0 -0
Quoted 36 lines
Quoted 36 lines
new file mode 100644 index 0000000..2054be3 ---
/dev/null+++b/fs/ext4/dev.c@@ -0,0 +1,145 @@ +/* + * (C) Copyright 2011 - 2012 Samsung Electronics + * EXT4 filesystem implementation in Uboot by
+ * Uma Shankar + * Manjunatha C Achar + * + * made from existingext2/dev.cfile of Uboot + * (C) Copyright 2004 + * esd gmbh + * Reinhard Arlt + * + * based on code offs/reiserfs/dev.cby + * + *
(C) Copyright 2003 - 2004 + * Sysgo AG, , Pavel Bartusek + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */
+ +/* + * Changelog: + * 0.1 - Newly created file for ext4fs
support. Taken from + *fs/ext2/dev.cfile in uboot. + */
+ +#include +#include +#include + +staticblock_dev_desc_t*ext4fs_block_dev_desc; +staticdisk_partition_tpart_info; + +intext4fs_set_blk_dev(block_dev_desc_t *rbdd, int part)+{ +ext4fs_block_dev_desc= rbdd; + + if (part == 0) { + /* disk doesn't use partition table */ + part_info.start = 0; + part_info.size =rbdd->lba; + part_info.blksz =rbdd->blksz; + } else { + if (get_partition_info(ext4fs_block_dev_desc, + part, &part_info)) + return 0; + } + return part_info.size; +} + +intext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)+{ + char sec_buf[SECTOR_SIZE]; + unsignedblock_len; + + /*
Check partition boundaries */ + if ((sector < 0) + || ((sector
+ ((byte_offset+byte_len- 1) >>SECTOR_BITS)) >= + part_info.size)) { +printf("%s read outside partition %d\n", __func__, sector); + return 0; + } + + /* Get the read to the beginning of a partition */ + sector +=byte_offset>>SECTOR_BITS; +byte_offset&=SECTOR_SIZE- 1; + + debug("
PATCH v4 1/2 ext4fs ls load support
Dear Rob Herring/ Wolfgang,
As discussed in earlier mail chain, our current ext4 implementation is capable enough to list(ls) and read(load) ext2 partitons as well.
Also the current ext4 implementation is optimized to 7-8 times greater read throughput than ext2load.
I propose that we can remove the existing ext2 code and let it be replaced with ext4.
All users using ext2ls and ext2load command can replace them with ext4ls and ext4load respectively.
The ext4 code is based on ext2 implementation and we have added the names of respective owners(ext2 code authors) in the file headers.
Please suggest what could be the best approach.
Thanks & Regards,
Manjunatha C achar
--------------------------------------------------
From: "Rob Herring" <[email protected]>
Sent: Monday, March 26, 2012 6:40 PM
To: <[email protected]>
Cc: <[email protected]>; "MANJUNATHAC ACHAR" <[email protected]>; <[email protected]>; "IQBAL SHAREEF" <[email protected]>; "HAKGOO LEE" <[email protected]>; <[email protected]>
Subject: Re: [U-Boot] [PATCH V4 1/2] ext4fs ls load support
Quoted 25 lines · UMA SHANKAR
Quoted 4 lines
Dear Rob Herring, Thanks for evaluating and testing our code. Currently, Our ext4 implementation is capable of listing and reading (ls and load) ext2 partitions as well. But, we wanted the ext4 code to be separate from ext2 implementation.
Why?
Quoted 5 lines
Your comment: --- Using ext2 commands on an ext4 partition will hang now.
ext2load command will only read ext2 partitions, and will definitely not work on ext4 (even without our implementation).
I'm not saying it should work, but it shouldn't hang. IIRC without your patch, it would return with an error. So you have changed something in the core ext2 code that makes it hang. But it's not something I think you need to worry about as the ext4 version of code should just replace the ext2 version and the issue will go away.
Rob
Quoted 3 lines
? So, I propose, we can let both these implementations be there in uboot under different CONFIG Options (as is the case currently). ? Thanks & Regards, Uma Shankar
PATCH v4 1/2 ext4fs ls load support
Quoted 7 lines · manjunatha
Dear Rob Herring/ Wolfgang,
As discussed in earlier mail chain, our current ext4 implementation is capable enough to list(ls) and read(load) ext2 partitons as well.
Also the current ext4 implementation is optimized to 7-8 times greater read throughput than ext2load.
Cool. IIRC, there was just recently some discussion on the list about ext2 performance problems.
Quoted 2 lines
I propose that we can remove the existing ext2 code and let it be replaced with ext4.
That's exactly what I proposed. Although, I think your patch should be done as modifications to cmd_ext2.c rather than deleting it and adding a new cmd_ext4.c.
Quoted 2 lines
All users using ext2ls and ext2load command can replace them with ext4ls and ext4load respectively.
I think you need to keep the command names to not break existing users' scripts. So either we just stick with ext2ls/ext2load or define additional ext4* commands which call the same functions as the ext2 version. I don't really care, but would lean toward the former.
Rob
Quoted 53 lines
The ext4 code is based on ext2 implementation and we have added the names of respective owners(ext2 code authors) in the file headers.
Please suggest what could be the best approach.
Thanks & Regards,
Manjunatha C achar
--------------------------------------------------
From: "Rob Herring" <[email protected]>
Sent: Monday, March 26, 2012 6:40 PM
To: <[email protected]>
Cc: <[email protected]>; "MANJUNATHAC ACHAR" <[email protected]>; <[email protected]>; "IQBAL SHAREEF" <[email protected]>; "HAKGOO LEE" <[email protected]>; <[email protected]>
Subject: Re: [U-Boot] [PATCH V4 1/2] ext4fs ls load supportQuoted 25 lines · UMA SHANKAR
Quoted 4 lines
Dear Rob Herring, Thanks for evaluating and testing our code. Currently, Our ext4 implementation is capable of listing and reading (ls and load) ext2 partitions as well. But, we wanted the ext4 code to be separate from ext2 implementation.
Why?
Quoted 5 lines
Your comment: --- Using ext2 commands on an ext4 partition will hang now.
ext2load command will only read ext2 partitions, and will definitely not work on ext4 (even without our implementation).
I'm not saying it should work, but it shouldn't hang. IIRC without your patch, it would return with an error. So you have changed something in the core ext2 code that makes it hang. But it's not something I think you need to worry about as the ext4 version of code should just replace the ext2 version and the issue will go away.
Rob
Quoted 3 lines
? So, I propose, we can let both these implementations be there in uboot under different CONFIG Options (as is the case currently). ? Thanks & Regards, Uma Shankar
PATCH v4 1/2 ext4fs ls load support
Hi Manjunatha & Rob
Quoted 11 lines · Rob Herring
Quoted 7 lines · manjunatha
Dear Rob Herring/ Wolfgang,
As discussed in earlier mail chain, our current ext4 implementation is capable enough to list(ls) and read(load) ext2 partitons as well.
Also the current ext4 implementation is optimized to 7-8 times greater read throughput than ext2load.
Cool. IIRC, there was just recently some discussion on the list about ext2 performance problems.
I am very keen to see this ext4 support hit maturity as I too am seeing sub-par performance reading from an ext2 filesystem on an SD card. (I'm a bit sad that I simply have not had the time to test drive it myself)
Quoted 6 lines
Quoted 2 lines
I propose that we can remove the existing ext2 code and let it be replaced with ext4.
That's exactly what I proposed. Although, I think your patch should be done as modifications to
cmd_ext2.crather than deleting it and adding a newcmd_ext4.c
That depends on what the delta between the ext2 and ext4 code is. If the delta is large (i.e. the patches are not intuitive to read) then I would suggest the following sequence:
1. Introduce the ext4 code with dedicated ext4ls, ext4load and ext4write functions as 100% seperate code (i.e. do not modify existing ext2 code)
2. Delete the ext2 code and modify ext2ls and ext2load to use the new ext4 functions (also add ext2write assuming these patches support writing to ext2)
Quoted 7 lines
Quoted 2 lines
All users using ext2ls and ext2load command can replace them with ext4ls and ext4load respectively.
I think you need to keep the command names to not break existing users' scripts. So either we just stick with ext2ls/ext2load or define additional ext4* commands which call the same functions as the ext2 version. I don't really care, but would lean toward the former.
As above - I don't see using ext2* to access an ext4 filesystem as very intuitive (or ext4* to access an ext2 filesystem) - The user does not need to know what happens under the hood, but the command interface should always make sense.
Regards,
Graeme