2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
4 * Copyright (C) 2002-2018 Aleph One Ltd.
6 * Created by Charles Manning <charles@aleph1.co.uk>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include "yaffs_packedtags1.h"
16 static const u8 all_ff[20] = {
17 0xff, 0xff, 0xff, 0xff,
18 0xff, 0xff, 0xff, 0xff,
19 0xff, 0xff, 0xff, 0xff,
20 0xff, 0xff, 0xff, 0xff,
21 0xff, 0xff, 0xff, 0xff
24 void yaffs_pack_tags1(struct yaffs_packed_tags1 *pt,
25 const struct yaffs_ext_tags *t)
27 pt->chunk_id = t->chunk_id;
28 pt->serial_number = t->serial_number;
29 pt->n_bytes = t->n_bytes;
30 pt->obj_id = t->obj_id;
32 pt->deleted = (t->is_deleted) ? 0 : 1;
34 pt->should_be_ff = 0xffffffff;
37 void yaffs_unpack_tags1(struct yaffs_ext_tags *t,
38 const struct yaffs_packed_tags1 *pt)
40 if (memcmp(all_ff, pt, sizeof(struct yaffs_packed_tags1))) {
42 if (pt->should_be_ff != 0xffffffff)
45 t->obj_id = pt->obj_id;
46 t->chunk_id = pt->chunk_id;
47 t->n_bytes = pt->n_bytes;
48 t->ecc_result = YAFFS_ECC_RESULT_NO_ERROR;
49 t->is_deleted = (pt->deleted) ? 0 : 1;
50 t->serial_number = pt->serial_number;
52 memset(t, 0, sizeof(struct yaffs_ext_tags));