yaffs_packedtags1.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #include "yaffs_packedtags1.h"
  14. #include "yportenv.h"
  15. void yaffs_PackTags1(yaffs_PackedTags1 * pt, const yaffs_ExtendedTags * t)
  16. {
  17. pt->chunkId = t->chunkId;
  18. pt->serialNumber = t->serialNumber;
  19. pt->byteCount = t->byteCount;
  20. pt->objectId = t->objectId;
  21. pt->ecc = 0;
  22. pt->deleted = (t->chunkDeleted) ? 0 : 1;
  23. pt->unusedStuff = 0;
  24. pt->shouldBeFF = 0xFFFFFFFF;
  25. }
  26. void yaffs_UnpackTags1(yaffs_ExtendedTags * t, const yaffs_PackedTags1 * pt)
  27. {
  28. static const __u8 allFF[] =
  29. { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  30. 0xff };
  31. if (memcmp(allFF, pt, sizeof(yaffs_PackedTags1))) {
  32. t->blockBad = 0;
  33. if (pt->shouldBeFF != 0xFFFFFFFF) {
  34. t->blockBad = 1;
  35. }
  36. t->chunkUsed = 1;
  37. t->objectId = pt->objectId;
  38. t->chunkId = pt->chunkId;
  39. t->byteCount = pt->byteCount;
  40. t->eccResult = YAFFS_ECC_RESULT_NO_ERROR;
  41. t->chunkDeleted = (pt->deleted) ? 0 : 1;
  42. t->serialNumber = pt->serialNumber;
  43. } else {
  44. memset(t, 0, sizeof(yaffs_ExtendedTags));
  45. }
  46. }