sqfs_utils.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020 Bootlin
  4. *
  5. * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
  6. */
  7. #ifndef SQFS_UTILS_H
  8. #define SQFS_UTILS_H
  9. #include <linux/bitops.h>
  10. #include <linux/kernel.h>
  11. #include <stdbool.h>
  12. #define SQFS_FRAGMENT_INDEX_OFFSET(A) ((A) % SQFS_MAX_ENTRIES)
  13. #define SQFS_FRAGMENT_INDEX(A) ((A) / SQFS_MAX_ENTRIES)
  14. #define SQFS_BLOCK_SIZE(A) ((A) & GENMASK(23, 0))
  15. #define SQFS_CHECK_FLAG(flag, bit) (((flag) >> (bit)) & 1)
  16. /* Useful for both fragment and data blocks */
  17. #define SQFS_COMPRESSED_BLOCK(A) (!((A) & BIT(24)))
  18. /* SQFS_COMPRESSED_DATA strictly used with super block's 'flags' member */
  19. #define SQFS_COMPRESSED_DATA(A) (!((A) & 0x0002))
  20. #define SQFS_IS_FRAGMENTED(A) ((A) != 0xFFFFFFFF)
  21. /*
  22. * These two macros work as getters for a metada block header, retrieving the
  23. * data size and if it is compressed/uncompressed
  24. */
  25. #define SQFS_COMPRESSED_METADATA(A) (!((A) & BIT(15)))
  26. #define SQFS_METADATA_SIZE(A) ((A) & GENMASK(14, 0))
  27. struct squashfs_super_block_flags {
  28. /* check: unused
  29. * uncompressed_ids: not supported
  30. */
  31. bool uncompressed_inodes;
  32. bool uncompressed_data;
  33. bool check;
  34. bool uncompressed_frags;
  35. bool no_frags;
  36. bool always_frags;
  37. bool duplicates;
  38. bool exportable;
  39. bool uncompressed_xattrs;
  40. bool no_xattrs;
  41. bool compressor_options;
  42. bool uncompressed_ids;
  43. };
  44. #endif /* SQFS_UTILS_H */