AnoopPuthanveetil / yaffs2utils

Automatically exported from code.google.com/p/yaffs2utils
GNU General Public License v2.0
0 stars 1 forks source link

unyaffs2 on Mac OS X #41

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile and run

What is the expected output? What do you see instead?
Expected: unyaffs2 extracts yaffs image
Result: First file OK, but filename for second file is "<first file>/<second 
file>", third file is named "<first file>/<second file>/<third file>" and so 
on. Of course the creation of these files fails.

What version of the product are you using? On what operating system?
unyaffs2 0.2.9, Mac OS X 10.7.5 (Lion)

Please provide any additional information below.

I analysed the unyaffs2 source code and found several bugs. After applying the 
attached patch file, the program works.

- Compile warning at all %lu printf formattings, because type off_t is long 
long on MAC OS X
   I found no really nice solution. I just casted all off_t arguments to long and %lu to %ld (off_t is signed at least on Linux and Mac OS X)

- In function unyaffs2_extract_hardlink the variable variant should'nt be a 
pointer
   The variable variant saves the contents of obj->variant. A pointer has no enough space for that, it must be the real structure/union.

- The program depends on a side effect of dirname, which modifies the argument 
of dirname.
   Mac OS X (and probably other BSD variants) don't have this side effect, they return a pointer to a static area. That is the main reason for the extraction issue on Mac OS X.
   To restore the variable unyaffs2_curfile, I save the string length into cur file_len and restore it on the end of the function.
   I didn't change mkyaffs2.

- Variable type not set in function unyaffs2_extract_objtree
   The variable type is only set to a reasonable value on a root object. I assume "type" should hold the information in obj->type, except on a root object, than it is a directory. So I changed the initialization of type and use type instead of obj->type in the rest of the function.

Original issue reported on code.google.com by b...@bernhard-ehlers.de on 1 Apr 2013 at 12:15

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by penguin.lin on 2 Apr 2013 at 4:21

GoogleCodeExporter commented 9 years ago

Original comment by penguin.lin on 2 Apr 2013 at 4:25

GoogleCodeExporter commented 9 years ago
I applied this patch to the 'latest' (20120815) download after patch failed to 
apply all the parts to version 0.2.9 of unyaffs2.c.

It corrected the behavior, and unyaffs2 now works for me on img files created 
with the latest SDK (5-22-2013 ADT download) on OS X 10.7.5 (Lion).

Thanks for this work and, of course, yaffs2utils.

Original comment by moap...@gmail.com on 15 Jul 2013 at 3:32