*** empty log message ***
[yaffs2.git] / direct / yaffs_packedtags.c
1 #include "yaffs_packedtags.h"
2 #include <string.h>
3
4 void yaffs_PackTags(yaffs_PackedTags *pt, yaffs_ExtendedTags *t)
5 {
6         pt->chunkId = t->chunkId;
7         pt->serialNumber = t->serialNumber;
8         pt->byteCount = t->byteCount;
9         pt->objectId = t->objectId;
10         pt->ecc = 0;
11         pt->deleted = (t->chunkDeleted) ? 0 : 1;
12         pt->unusedStuff = 0;
13         pt->shouldBeFF = 0xFFFFFFFF;
14         
15 }
16
17 void yaffs_UnpackTags(yaffs_ExtendedTags *t, yaffs_PackedTags *pt)
18 {
19         static __u8 allFF[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff};
20         
21         if(memcmp(allFF,pt,sizeof(yaffs_PackedTags)))
22         {
23                 t->blockBad = 0;
24                 if(pt->shouldBeFF != 0xFFFFFFFF)
25                 {
26                         t->blockBad = 1;
27                 }
28                 t->chunkUsed = 1;
29                 t->objectId = pt->objectId;
30                 t->chunkId = pt->chunkId;
31                 t->byteCount = pt->byteCount;
32                 t->eccResult =  YAFFS_ECC_RESULT_NO_ERROR;
33                 t->chunkDeleted = (pt->deleted) ? 0 : 1;
34                 t->serialNumber = pt->serialNumber;
35         }
36         else
37         {
38                 memset(t,0,sizeof(yaffs_ExtendedTags));
39                 
40         }
41 }
42