yaffs Merge branch 'namechange'
[yaffs2.git] / yaffs_packedtags1.c
1 /*
2  * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 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 #include "yaffs_packedtags1.h"
15 #include "yportenv.h"
16
17 void yaffs_PackTags1(yaffs_PackedTags1 *pt, const yaffs_ext_tags *t)
18 {
19         pt->chunk_id = t->chunk_id;
20         pt->serial_number = t->serial_number;
21         pt->n_bytes = t->n_bytes;
22         pt->obj_id = t->obj_id;
23         pt->ecc = 0;
24         pt->deleted = (t->is_deleted) ? 0 : 1;
25         pt->unusedStuff = 0;
26         pt->shouldBeFF = 0xFFFFFFFF;
27
28 }
29
30 void yaffs_unpack_tags1(yaffs_ext_tags *t, const yaffs_PackedTags1 *pt)
31 {
32         static const __u8 allFF[] =
33             { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
34 0xff };
35
36         if (memcmp(allFF, pt, sizeof(yaffs_PackedTags1))) {
37                 t->block_bad = 0;
38                 if (pt->shouldBeFF != 0xFFFFFFFF)
39                         t->block_bad = 1;
40                 t->chunk_used = 1;
41                 t->obj_id = pt->obj_id;
42                 t->chunk_id = pt->chunk_id;
43                 t->n_bytes = pt->n_bytes;
44                 t->ecc_result = YAFFS_ECC_RESULT_NO_ERROR;
45                 t->is_deleted = (pt->deleted) ? 0 : 1;
46                 t->serial_number = pt->serial_number;
47         } else {
48                 memset(t, 0, sizeof(yaffs_ext_tags));
49         }
50 }