minix.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * This is the original minix inode layout on disk.
  3. * Note the 8-bit gid and atime and ctime.
  4. */
  5. struct minix1_inode {
  6. uint16_t i_mode;
  7. uint16_t i_uid;
  8. uint32_t i_size;
  9. uint32_t i_time;
  10. uint8_t i_gid;
  11. uint8_t i_nlinks;
  12. uint16_t i_zone[9];
  13. };
  14. /*
  15. * The new minix inode has all the time entries, as well as
  16. * long block numbers and a third indirect block (7+1+1+1
  17. * instead of 7+1+1). Also, some previously 8-bit values are
  18. * now 16-bit. The inode is now 64 bytes instead of 32.
  19. */
  20. struct minix2_inode {
  21. uint16_t i_mode;
  22. uint16_t i_nlinks;
  23. uint16_t i_uid;
  24. uint16_t i_gid;
  25. uint32_t i_size;
  26. uint32_t i_atime;
  27. uint32_t i_mtime;
  28. uint32_t i_ctime;
  29. uint32_t i_zone[10];
  30. };
  31. /*
  32. * minix superblock data on disk
  33. */
  34. struct minix_superblock {
  35. uint16_t s_ninodes;
  36. uint16_t s_nzones;
  37. uint16_t s_imap_blocks;
  38. uint16_t s_zmap_blocks;
  39. uint16_t s_firstdatazone;
  40. uint16_t s_log_zone_size;
  41. uint32_t s_max_size;
  42. uint16_t s_magic;
  43. uint16_t s_state;
  44. uint32_t s_zones;
  45. };
  46. struct minix_dir_entry {
  47. uint16_t inode;
  48. char name[];
  49. };
  50. /* Believe it or not, but mount.h has this one #defined */
  51. #undef BLOCK_SIZE
  52. enum {
  53. BLOCK_SIZE = 1024,
  54. BITS_PER_BLOCK = BLOCK_SIZE << 3,
  55. MINIX_ROOT_INO = 1,
  56. MINIX_BAD_INO = 2,
  57. #undef MINIX1_SUPER_MAGIC
  58. MINIX1_SUPER_MAGIC = 0x137F, /* original minix fs */
  59. #undef MINIX1_SUPER_MAGIC2
  60. MINIX1_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */
  61. /* bionic has this define */
  62. #undef MINIX2_SUPER_MAGIC
  63. MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */
  64. #undef MINIX2_SUPER_MAGIC2
  65. MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */
  66. MINIX_VALID_FS = 0x0001, /* clean fs */
  67. MINIX_ERROR_FS = 0x0002, /* fs has errors */
  68. INODE_SIZE1 = sizeof(struct minix1_inode),
  69. INODE_SIZE2 = sizeof(struct minix2_inode),
  70. MINIX1_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix1_inode),
  71. MINIX2_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix2_inode),
  72. };
  73. /*
  74. Basic test script for regressions in mkfs/fsck.
  75. Copies current dir into image (typically bbox build tree).
  76. #!/bin/sh
  77. tmpdir=/tmp/minixtest-$$
  78. tmpimg=/tmp/minix-img-$$
  79. mkdir $tmpdir
  80. dd if=/dev/zero of=$tmpimg bs=1M count=20 || exit
  81. ./busybox mkfs.minix $tmpimg || exit
  82. mount -o loop $tmpimg $tmpdir || exit
  83. cp -a "$PWD" $tmpdir
  84. umount $tmpdir || exit
  85. ./busybox fsck.minix -vfm $tmpimg || exit
  86. echo "Continue?"
  87. read junk
  88. ./busybox fsck.minix -vfml $tmpimg || exit
  89. rmdir $tmpdir
  90. rm $tmpimg
  91. */