cramfs_fs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef __CRAMFS_H
  2. #define __CRAMFS_H
  3. #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
  4. #define CRAMFS_SIGNATURE "Compressed ROMFS"
  5. /*
  6. * Width of various bitfields in struct cramfs_inode.
  7. * Primarily used to generate warnings in mkcramfs.
  8. */
  9. #define CRAMFS_MODE_WIDTH 16
  10. #define CRAMFS_UID_WIDTH 16
  11. #define CRAMFS_SIZE_WIDTH 24
  12. #define CRAMFS_GID_WIDTH 8
  13. #define CRAMFS_NAMELEN_WIDTH 6
  14. #define CRAMFS_OFFSET_WIDTH 26
  15. /*
  16. * Since inode.namelen is a unsigned 6-bit number, the maximum cramfs
  17. * path length is 63 << 2 = 252.
  18. */
  19. #define CRAMFS_MAXPATHLEN (((1 << CRAMFS_NAMELEN_WIDTH) - 1) << 2)
  20. /*
  21. * Reasonably terse representation of the inode data.
  22. */
  23. struct cramfs_inode {
  24. u32 mode:CRAMFS_MODE_WIDTH, uid:CRAMFS_UID_WIDTH;
  25. /* SIZE for device files is i_rdev */
  26. u32 size:CRAMFS_SIZE_WIDTH, gid:CRAMFS_GID_WIDTH;
  27. /* NAMELEN is the length of the file name, divided by 4 and
  28. rounded up. (cramfs doesn't support hard links.) */
  29. /* OFFSET: For symlinks and non-empty regular files, this
  30. contains the offset (divided by 4) of the file data in
  31. compressed form (starting with an array of block pointers;
  32. see README). For non-empty directories it is the offset
  33. (divided by 4) of the inode of the first file in that
  34. directory. For anything else, offset is zero. */
  35. u32 namelen:CRAMFS_NAMELEN_WIDTH, offset:CRAMFS_OFFSET_WIDTH;
  36. };
  37. struct cramfs_info {
  38. u32 crc;
  39. u32 edition;
  40. u32 blocks;
  41. u32 files;
  42. };
  43. /*
  44. * Superblock information at the beginning of the FS.
  45. */
  46. struct cramfs_super {
  47. u32 magic; /* 0x28cd3d45 - random number */
  48. u32 size; /* length in bytes */
  49. u32 flags; /* feature flags */
  50. u32 future; /* reserved for future use */
  51. u8 signature[16]; /* "Compressed ROMFS" */
  52. struct cramfs_info fsid; /* unique filesystem info */
  53. u8 name[16]; /* user-defined name */
  54. struct cramfs_inode root; /* root inode data */
  55. };
  56. /*
  57. * Feature flags
  58. *
  59. * 0x00000000 - 0x000000ff: features that work for all past kernels
  60. * 0x00000100 - 0xffffffff: features that don't work for past kernels
  61. */
  62. #define CRAMFS_FLAG_FSID_VERSION_2 0x00000001 /* fsid version #2 */
  63. #define CRAMFS_FLAG_SORTED_DIRS 0x00000002 /* sorted dirs */
  64. #define CRAMFS_FLAG_HOLES 0x00000100 /* support for holes */
  65. #define CRAMFS_FLAG_WRONG_SIGNATURE 0x00000200 /* reserved */
  66. #define CRAMFS_FLAG_SHIFTED_ROOT_OFFSET 0x00000400 /* shifted root fs */
  67. /*
  68. * Valid values in super.flags. Currently we refuse to mount
  69. * if (flags & ~CRAMFS_SUPPORTED_FLAGS). Maybe that should be
  70. * changed to test super.future instead.
  71. */
  72. #define CRAMFS_SUPPORTED_FLAGS ( 0x000000ff \
  73. | CRAMFS_FLAG_HOLES \
  74. | CRAMFS_FLAG_WRONG_SIGNATURE \
  75. | CRAMFS_FLAG_SHIFTED_ROOT_OFFSET )
  76. #define CRAMFS_16(x) (x)
  77. #define CRAMFS_24(x) (x)
  78. #define CRAMFS_32(x) (x)
  79. #define CRAMFS_GET_NAMELEN(x) ((x)->namelen)
  80. #define CRAMFS_GET_OFFSET(x) ((x)->offset)
  81. #define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y))
  82. #define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
  83. /* Uncompression interfaces to the underlying zlib */
  84. int cramfs_uncompress_block(void *dst, void *src, int srclen);
  85. int cramfs_uncompress_init(void);
  86. int cramfs_uncompress_exit(void);
  87. #endif /* __CRAMFS_H */