fat: Remove FAT Directory Bread message
[linux-2.6.git] / fs / yaffs2 / 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_pack_tags1(struct yaffs_packed_tags1 *pt,
18                       const struct yaffs_ext_tags *t)
19 {
20         pt->chunk_id = t->chunk_id;
21         pt->serial_number = t->serial_number;
22         pt->n_bytes = t->n_bytes;
23         pt->obj_id = t->obj_id;
24         pt->ecc = 0;
25         pt->deleted = (t->is_deleted) ? 0 : 1;
26         pt->unused_stuff = 0;
27         pt->should_be_ff = 0xFFFFFFFF;
28
29 }
30
31 void yaffs_unpack_tags1(struct yaffs_ext_tags *t,
32                         const struct yaffs_packed_tags1 *pt)
33 {
34         static const u8 all_ff[] =
35             { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
36                 0xff
37         };
38
39         if (memcmp(all_ff, pt, sizeof(struct yaffs_packed_tags1))) {
40                 t->block_bad = 0;
41                 if (pt->should_be_ff != 0xFFFFFFFF)
42                         t->block_bad = 1;
43                 t->chunk_used = 1;
44                 t->obj_id = pt->obj_id;
45                 t->chunk_id = pt->chunk_id;
46                 t->n_bytes = pt->n_bytes;
47                 t->ecc_result = YAFFS_ECC_RESULT_NO_ERROR;
48                 t->is_deleted = (pt->deleted) ? 0 : 1;
49                 t->serial_number = pt->serial_number;
50         } else {
51                 memset(t, 0, sizeof(struct yaffs_ext_tags));
52         }
53 }