[Yaffs] Re: YAFFS fs images not working the way I expect

David Wuertele dave-gnus@bfnet.com
Wed, 27 Oct 2004 15:06:24 -0700


Charles> Have a look at the code for mkyaffs. This should give you a
Charles> good kick-off point for programming YAFFS.

OK, after perusing mkyaffs.c, I am about to write a program for
extracting data from a yaffs partition.

Instead of using

        dd if=/dev/mtd/2 of=/yaffs.img

I will use

        myprog /dev/mtd/2 > /yaffs.img

I think that "myprog" can be written by copying mkyaffs.c to
readyaffs.c, removing the erase code, and changing the part that
writes the data to this:

    if(addr) {
        for(offset = 0; offset <meminfo.erasesize; offset+=512) {
     	    lseek(fd,addr+offset,SEEK_SET);
     	    if(read(fd,imgpage,512) == 512) {
     	        oob.start = addr+offset;
     	        oob.length=16;
     	        oob.ptr=&imgpage[512];
     	        ioctl(fd,MEMREADOOB,&oob);
     	        write (1, imgpage, 528);
     	    }
     	}
     }

Then, if I did this right, I should be able to run 

    /sbin/mkyaffs /dev/mtd/2 /yaffs.img

...and everything will run normally.

Does that look right?

Dave