cramfs_fs.h 2.7 KB

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