From patchwork Sun Apr 24 03:34:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baidu Boy X-Patchwork-Id: 92630 X-Patchwork-Delegate: dzu@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3BE5CB6FBE for ; Sun, 24 Apr 2011 13:34:32 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6B6F6280B4; Sun, 24 Apr 2011 05:34:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lF3I4DDxKzHl; Sun, 24 Apr 2011 05:34:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6F46280A9; Sun, 24 Apr 2011 05:34:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C8EA2280A9 for ; Sun, 24 Apr 2011 05:34:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dvDClWkkL2iw for ; Sun, 24 Apr 2011 05:34:25 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pv0-f172.google.com (mail-pv0-f172.google.com [74.125.83.172]) by theia.denx.de (Postfix) with ESMTPS id 06F6A280A8 for ; Sun, 24 Apr 2011 05:34:23 +0200 (CEST) Received: by pvh1 with SMTP id 1so919031pvh.3 for ; Sat, 23 Apr 2011 20:34:18 -0700 (PDT) Received: by 10.68.41.9 with SMTP id b9mr4347378pbl.436.1303616058197; Sat, 23 Apr 2011 20:34:18 -0700 (PDT) Received: from LENOVOE5CA6843 ([121.229.190.251]) by mx.google.com with ESMTPS id q10sm1910513pbk.39.2011.04.23.20.34.13 (version=SSLv3 cipher=OTHER); Sat, 23 Apr 2011 20:34:17 -0700 (PDT) From: "Baidu Liu" To: , Date: Sun, 24 Apr 2011 11:34:00 +0800 Message-ID: <001c01cc0230$7dba7840$6401a8c0@LENOVOE5CA6843> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcwCMHL2M70hhMSNT1itq9y34Limfw== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3664 Subject: [U-Boot] [PATCH 1/7] JFFS2: Bug fix for summary support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 1/ Get the latest DIRENT For example, if you create a file in linux jffs2 which config summary support, then you delete the file , you will not see the file in linux jffs2. But you can also see this file in uboot after you reset the system. That is because all the nodes in jffs2 which config summary will not be marked as obsolete. The deleted file's DIRENT node will be seen in uboot. So what we need to do is to get the latest DIRENT whose ino in DIRENT is 0. Than we will not see this file in uboot which is what we want. 2/ Add CONFIG_SYS_JFFS2_SORT_FRAGMENTS definition,if we config jffs2 summary in uboot. All the inodes of a file will not marked as obsolete, if they do not sort in the list struct b_node *, the latest data in inode may be overwritten by the older one. Signed-off-by: Baidu Liu --- fs/jffs2/jffs2_1pass.c | 17 ++++++++++++----- fs/jffs2/jffs2_nand_1pass.c | 17 +++++++++++++---- include/jffs2/jffs2.h | 10 ++++++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index c4f7445..a34756e 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -748,8 +748,8 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest) if(dest) { src = ((uchar *) jNode) + sizeof(struct jffs2_raw_inode); - /* ignore data behind latest known EOF */ - if (jNode->offset > totalSize) { + /* ignore data which exceed file length */ + if (jNode->offset + jNode->dsize > totalSize) { put_fl_mem(jNode, pL->readbuf); continue; } @@ -836,9 +836,8 @@ jffs2_1pass_find_inode(struct b_lists * pL, const char *name, u32 pino) jDir = (struct jffs2_raw_dirent *) get_node_mem(b->offset, pL->readbuf); if ((pino == jDir->pino) && (len == jDir->nsize) && - (jDir->ino) && /* 0 for unlink */ (!strncmp((char *)jDir->name, name, len))) { /* a match */ - if (jDir->version < version) { + if (jDir->version < version) { /*ignore the old DIRENT*/ put_fl_mem(jDir, pL->readbuf); continue; } @@ -962,6 +961,14 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) struct jffs2_raw_inode ojNode; struct jffs2_raw_inode *jNode, *i = NULL; struct b_node *b2 = pL->frag.listHead; + + /* + we compare the DIRENT's ino with the latest DIRENT's ino + to determine whether this DIRENT is the latest one. + If the DIRENT is not the latest one,ignore it. + */ + if(jDir->ino != jffs2_1pass_find_inode(pL, jDir->name, pino)) + continue; while (b2) { jNode = (struct jffs2_raw_inode *) @@ -1520,7 +1527,7 @@ jffs2_1pass_build_lists(struct part_info * part) ret = jffs2_sum_scan_sumnode(part, sector_ofs, sumptr, sumlen, pL); - if (buf_size && sumlen > buf_size) + if (sumlen > buf_size) free(sumptr); if (ret < 0) { free(buf); diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c index 3982003..9bad690 100644 --- a/fs/jffs2/jffs2_nand_1pass.c +++ b/fs/jffs2/jffs2_nand_1pass.c @@ -305,8 +305,8 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest, if (dest) len += jNode->csize; nand_read(nand, jNode->offset, &len, inode); - /* ignore data behind latest known EOF */ - if (inode->offset > totalSize) + /* ignore data which exceed file length */ + if (inode->offset + inode->dsize > totalSize) continue; if (stat) { @@ -371,8 +371,9 @@ jffs2_1pass_find_inode(struct b_lists * pL, const char *name, u32 pino) /* we need to search all and return the inode with the highest version */ for (jDir = (struct b_dirent *)pL->dir.listHead; jDir; jDir = jDir->next) { - if ((pino == jDir->pino) && (jDir->ino) && /* 0 for unlink */ - (len == jDir->nsize) && (nhash == jDir->nhash)) { + if ((pino == jDir->pino) && + (len == jDir->nsize) && + (nhash == jDir->nhash)) { /* TODO: compare name */ if (jDir->version < version) continue; @@ -483,6 +484,14 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) struct b_inode *jNode = (struct b_inode *)pL->frag.listHead; struct b_inode *i = NULL; + /* + we compare the DIRENT's ino with the latest DIRENT's ino + to determine whether this DIRENT is the latest one. + If the DIRENT is not the latest one,ignore it. + */ + if(jDir.ino != jffs2_1pass_find_inode(pL, jDir->name, pino)) + continue; + while (jNode) { if (jNode->ino == jDir->ino && jNode->version >= i_version) { i_version = jNode->version; diff --git a/include/jffs2/jffs2.h b/include/jffs2/jffs2.h index 651f94c..5b006c0 100644 --- a/include/jffs2/jffs2.h +++ b/include/jffs2/jffs2.h @@ -41,6 +41,16 @@ #include #include +#ifdef CONFIG_JFFS2_SUMMARY +#ifndef CONFIG_SYS_JFFS2_SORT_FRAGMENTS +/* +we should define CONFIG_SYS_JFFS2_SORT_FRAGMENTS,if +CONFIG_JFFS2_SUMMARY is enabled. +*/ +#define CONFIG_SYS_JFFS2_SORT_FRAGMENTS +#endif +#endif + #define JFFS2_SUPER_MAGIC 0x72b6 /* Values we may expect to find in the 'magic' field */