Browse Source

fix pmon ubifs mtd part detect.

Change-Id: Ieb318191cf2bf1ff409b87955ca383cbef13e328
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
NiuPengJu 6 years ago
committed by Chong Qiao
parent
commit
e7144b0b53
  1. 14
      pmon/fs/ubi/scan2.c
  2. 11
      pmon/fs/ubifs/ubifs.c
  3. 2
      pmon/fs/ubifs/ubifs.h

14
pmon/fs/ubi/scan2.c

@ -48,6 +48,7 @@
#include "ubi.h" #include "ubi.h"
#include <mtdfile.h>
#ifdef CONFIG_MTD_UBI_DEBUG_PARANOID #ifdef CONFIG_MTD_UBI_DEBUG_PARANOID
static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si); static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si);
#else #else
@ -912,12 +913,14 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
{ {
// puts("ubi_scan!!"); // puts("ubi_scan!!");
// printf("mtd=%p,mtd->priv=%p\n",ubi->mtd,ubi->mtd->priv); // printf("mtd=%p,mtd->priv=%p\n",ubi->mtd,ubi->mtd->priv);
int err, pnum; int err, pnum,i,num;
struct rb_node *rb1, *rb2; struct rb_node *rb1, *rb2;
struct ubi_scan_volume *sv; struct ubi_scan_volume *sv;
struct ubi_scan_leb *seb; struct ubi_scan_leb *seb;
struct ubi_scan_info *si; struct ubi_scan_info *si;
int mtdx_offset;
int mtdx_size;
mtdfile *priv;
si = kzalloc(sizeof(struct ubi_scan_info), GFP_KERNEL); si = kzalloc(sizeof(struct ubi_scan_info), GFP_KERNEL);
if (!si) if (!si)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
@ -938,7 +941,12 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
if (!vidh) if (!vidh)
goto out_ech; goto out_ech;
for (pnum = 0; pnum < ubi->peb_count; pnum++) { priv = (mtdfile *)(ubi->mtd->part);
mtdx_offset = priv->part_offset;
mtdx_size = priv->part_size_real;
pnum = mtdx_offset/ubi->mtd->erasesize;
num = mtdx_size /ubi->mtd->erasesize;
for (i=0; i < num; i++,pnum++) {
// puts("before con_resched!!"); // puts("before con_resched!!");
cond_resched(); cond_resched();
// puts("after con_resched!!"); // puts("after con_resched!!");

11
pmon/fs/ubifs/ubifs.c

@ -1101,7 +1101,7 @@ ubifs_open(int fd, const char *path, int flags, int mode)
mtdfile *p; mtdfile *p;
LIST_FOREACH(p, &mtdfiles, i_next) LIST_FOREACH(p, &mtdfiles, i_next)
{ {
if(p->mtd->index==mtdx) if(p->index==mtdx)
break; break;
} }
if(!p) if(!p)
@ -1110,6 +1110,7 @@ ubifs_open(int fd, const char *path, int flags, int mode)
return -1; return -1;
} }
mt=p->mtd; mt=p->mtd;
mt->part = p;
if((ubinum=ubi_attach_mtd_dev(mt, 0, 0))<0) if((ubinum=ubi_attach_mtd_dev(mt, 0, 0))<0)
{ {
puts("ubi_attach_mtd_dev error!!"); puts("ubi_attach_mtd_dev error!!");
@ -1130,6 +1131,14 @@ ubifs_open(int fd, const char *path, int flags, int mode)
/* ubifs_findfile will resolve symlinks, so we know that we get /* ubifs_findfile will resolve symlinks, so we know that we get
* the real file here */ * the real file here */
//printf("c->vi.ubi_num=%d,c->vi.vol_id=%d,c->vi.vol_size=%d,c->vi.vol_name=%s\n",c->vi.ubi_num,c->vi.vol_id,c->vi.size,c->vi.name); //printf("c->vi.ubi_num=%d,c->vi.vol_id=%d,c->vi.vol_size=%d,c->vi.vol_name=%s\n",c->vi.ubi_num,c->vi.vol_id,c->vi.size,c->vi.name);
if(!*filename||filename[strlen(filename)-1]=='/')
{
ubifs_ls(filename);
ubi_detach_mtd_dev(0, 1);
ubifs_sb = NULL;
return -1;
}
inum = ubifs_findfile(ubifs_sb, filename); inum = ubifs_findfile(ubifs_sb, filename);
if (!inum) { if (!inum) {
puts("inum not found"); puts("inum not found");

2
pmon/fs/ubifs/ubifs.h

@ -2103,7 +2103,7 @@ int ubifs_removexattr(struct dentry *dentry, const char *name);
/* super.c */ /* super.c */
struct inode *ubifs_iget(struct super_block *sb, unsigned long inum); struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
int ubifs_iput(struct inode *inode); int ubifs_iput(struct inode *inode);
int mount_ubifs(struct ubifs_info *c); static int mount_ubifs(struct ubifs_info *c);
/* recovery.c */ /* recovery.c */
int ubifs_recover_master_node(struct ubifs_info *c); int ubifs_recover_master_node(struct ubifs_info *c);

Loading…
Cancel
Save