[U-Boot-Users] RO jffs2 implementation for bootloader
Ladislav Michl
ladis at linux-mips.org
Fri May 18 12:59:04 CEST 2007
On Wed, May 16, 2007 at 02:45:02PM +0200, Matthieu CASTET wrote:
> I tried, but it doesn't work :
See patch below. It is not complete and most liklely will not fix your
problem. But at least it compiles and can be used as starting point ;-)
Based on top of cleanup I sent earlier.
Best regards,
ladis
--- fs/jffs2/jffs2_nand_private.h.orig 2007-05-18 11:07:53.000000000 +0200
+++ fs/jffs2/jffs2_nand_private.h 2007-05-18 12:39:10.000000000 +0200
@@ -30,6 +32,11 @@
struct b_list {
struct b_node *listTail;
struct b_node *listHead;
+#ifdef CFG_JFFS2_SORT_FRAGMENTS
+ struct b_node *listLast;
+ int (*listCompare)(struct b_node *new, struct b_node *node);
+ u32 listLoops;
+#endif
unsigned int listCount;
struct mem_block *listMemBase;
};
--- fs/jffs2/jffs2_nand_1pass.c.orig 2007-05-18 11:08:12.000000000 +0200
+++ fs/jffs2/jffs2_nand_1pass.c 2007-05-18 12:40:47.000000000 +0200
@@ -1,7 +1,5 @@
#include <common.h>
-#define CFG_JFFS2_SORT_FRAGMENTS
-
#if !defined(CFG_NAND_LEGACY) && (CONFIG_COMMANDS & CFG_CMD_JFFS2)
#include <malloc.h>
@@ -181,14 +179,7 @@
*/
static int compare_inodes(struct b_node *new, struct b_node *old)
{
- struct jffs2_raw_inode ojNew;
- struct jffs2_raw_inode ojOld;
- struct jffs2_raw_inode *jNew =
- (struct jffs2_raw_inode *)get_fl_mem(new->offset, sizeof(ojNew), &ojNew);
- struct jffs2_raw_inode *jOld =
- (struct jffs2_raw_inode *)get_fl_mem(old->offset, sizeof(ojOld), &ojOld);
-
- return jNew->version > jOld->version;
+ return ((struct b_inode *)new)->version > ((struct b_inode *)old)->version;
}
/* Sort directory entries so all entries in the same directory
@@ -198,38 +189,37 @@
*/
static int compare_dirents(struct b_node *new, struct b_node *old)
{
- struct jffs2_raw_dirent ojNew;
- struct jffs2_raw_dirent ojOld;
- struct jffs2_raw_dirent *jNew =
- (struct jffs2_raw_dirent *)get_fl_mem(new->offset, sizeof(ojNew), &ojNew);
- struct jffs2_raw_dirent *jOld =
- (struct jffs2_raw_dirent *)get_fl_mem(old->offset, sizeof(ojOld), &ojOld);
+ struct b_dirent *bNew = (struct b_dirent *) new;
+ struct b_dirent *bOld = (struct b_dirent *) old;
+/* TODO
int cmp;
-
+*/
/* ascending sort by pino */
- if (jNew->pino != jOld->pino)
- return jNew->pino > jOld->pino;
+ if (bNew->pino != bOld->pino)
+ return bNew->pino > bOld->pino;
/* pino is the same, so use ascending sort by nsize, so
* we don't do strncmp unless we really must.
*/
- if (jNew->nsize != jOld->nsize)
- return jNew->nsize > jOld->nsize;
+ if (bNew->nsize != bOld->nsize)
+ return bNew->nsize > bOld->nsize;
/* length is also the same, so use ascending sort by name
*/
- cmp = strncmp(jNew->name, jOld->name, jNew->nsize);
+ /* TODO: compare name
+ cmp = strncmp(bNew->name, bOld->name, jNew->nsize);
if (cmp != 0)
return cmp > 0;
+ */
/* we have duplicate names in this directory, so use ascending
* sort by version
*/
- if (jNew->version > jOld->version) {
+ if (bNew->version > bOld->version) {
/* since jNew is newer, we know jOld is not valid, so
* mark it with inode 0 and it will not be used
*/
- jOld->ino = 0;
+ bOld->ino = 0;
return 1;
}
@@ -270,35 +260,16 @@
u32 latestVersion = 0;
long ret;
-#ifdef CFG_JFFS2_SORT_FRAGMENTS
- /* Find file size before loading any data, so fragments that
- * start past the end of file can be ignored. A fragment
- * that is partially in the file is loaded, so extra data may
- * be loaded up to the next 4K boundary above the file size.
- * This shouldn't cause trouble when loading kernel images, so
- * we will live with it.
- */
- for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {
- if ((ino == jNode->ino)) {
- /* get actual file length from the newest node */
- if (jNode->version >= latestVersion) {
- totalSize = jNode->isize;
- latestVersion = jNode->version;
- }
- }
- }
-#endif
-
for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {
if ((ino != jNode->ino))
continue;
-#ifndef CFG_JFFS2_SORT_FRAGMENTS
+
/* get actual file length from the newest node */
if (jNode->version >= latestVersion) {
totalSize = jNode->isize;
latestVersion = jNode->version;
}
-#endif
+
if (dest || stat) {
unsigned char *src, *dst;
char data[4096 + sizeof(struct jffs2_raw_inode)];
More information about the U-Boot
mailing list