]>
Commit | Line | Data |
---|---|---|
0e8cc8bd WJ |
1 | /* |
2 | * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. | |
3 | * | |
753ac610 | 4 | * Copyright (C) 2002-2011 Aleph One Ltd. |
0e8cc8bd WJ |
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 | ||
753ac610 CM |
17 | static const u8 all_ff[20] = { |
18 | 0xff, 0xff, 0xff, 0xff, | |
19 | 0xff, 0xff, 0xff, 0xff, | |
20 | 0xff, 0xff, 0xff, 0xff, | |
21 | 0xff, 0xff, 0xff, 0xff, | |
22 | 0xff, 0xff, 0xff, 0xff | |
23 | }; | |
24 | ||
25 | void yaffs_pack_tags1(struct yaffs_packed_tags1 *pt, | |
26 | const struct yaffs_ext_tags *t) | |
0e8cc8bd | 27 | { |
753ac610 CM |
28 | pt->chunk_id = t->chunk_id; |
29 | pt->serial_number = t->serial_number; | |
30 | pt->n_bytes = t->n_bytes; | |
31 | pt->obj_id = t->obj_id; | |
0e8cc8bd | 32 | pt->ecc = 0; |
753ac610 CM |
33 | pt->deleted = (t->is_deleted) ? 0 : 1; |
34 | pt->unused_stuff = 0; | |
35 | pt->should_be_ff = 0xffffffff; | |
0e8cc8bd WJ |
36 | } |
37 | ||
753ac610 CM |
38 | void yaffs_unpack_tags1(struct yaffs_ext_tags *t, |
39 | const struct yaffs_packed_tags1 *pt) | |
0e8cc8bd | 40 | { |
0e8cc8bd | 41 | |
753ac610 CM |
42 | if (memcmp(all_ff, pt, sizeof(struct yaffs_packed_tags1))) { |
43 | t->block_bad = 0; | |
44 | if (pt->should_be_ff != 0xffffffff) | |
45 | t->block_bad = 1; | |
46 | t->chunk_used = 1; | |
47 | t->obj_id = pt->obj_id; | |
48 | t->chunk_id = pt->chunk_id; | |
49 | t->n_bytes = pt->n_bytes; | |
50 | t->ecc_result = YAFFS_ECC_RESULT_NO_ERROR; | |
51 | t->is_deleted = (pt->deleted) ? 0 : 1; | |
52 | t->serial_number = pt->serial_number; | |
0e8cc8bd | 53 | } else { |
753ac610 | 54 | memset(t, 0, sizeof(struct yaffs_ext_tags)); |
0e8cc8bd WJ |
55 | } |
56 | } |