43f5873e83f2877dc5c5c96a7e077323039bad01
[yaffs2.git] / yaffs_packedtags1.c
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2007 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Charles Manning <charles@aleph1.co.uk>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  */
14
15 #include "yaffs_packedtags1.h"
16 #include "yportenv.h"
17
18 void yaffs_PackTags1(yaffs_PackedTags1 * pt, const yaffs_ExtendedTags * t)
19 {
20         pt->chunkId = t->chunkId;
21         pt->serialNumber = t->serialNumber;
22         pt->byteCount = t->byteCount;
23         pt->objectId = t->objectId;
24         pt->ecc = 0;
25         pt->deleted = (t->chunkDeleted) ? 0 : 1;
26         pt->unusedStuff = 0;
27         pt->shouldBeFF = 0xFFFFFFFF;
28
29 }
30
31 void yaffs_UnpackTags1(yaffs_ExtendedTags * t, const yaffs_PackedTags1 * pt)
32 {
33         static const __u8 allFF[] =
34             { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35 0xff };
36
37         if (memcmp(allFF, pt, sizeof(yaffs_PackedTags1))) {
38                 t->blockBad = 0;
39                 if (pt->shouldBeFF != 0xFFFFFFFF) {
40                         t->blockBad = 1;
41                 }
42                 t->chunkUsed = 1;
43                 t->objectId = pt->objectId;
44                 t->chunkId = pt->chunkId;
45                 t->byteCount = pt->byteCount;
46                 t->eccResult = YAFFS_ECC_RESULT_NO_ERROR;
47                 t->chunkDeleted = (pt->deleted) ? 0 : 1;
48                 t->serialNumber = pt->serialNumber;
49         } else {
50                 memset(t, 0, sizeof(yaffs_ExtendedTags));
51
52         }
53 }