3
0

minix.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. MINIX1_SUPER_MAGIC = 0x137F, /* original minix fs */
  58. MINIX1_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */
  59. MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */
  60. MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */
  61. MINIX_VALID_FS = 0x0001, /* clean fs */
  62. MINIX_ERROR_FS = 0x0002, /* fs has errors */
  63. INODE_SIZE1 = sizeof(struct minix1_inode),
  64. INODE_SIZE2 = sizeof(struct minix2_inode),
  65. MINIX1_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix1_inode),
  66. MINIX2_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix2_inode),
  67. };
  68. /*
  69. Basic test script for regressions in mkfs/fsck.
  70. Copies current dir into image (typically bbox build tree).
  71. #!/bin/sh
  72. tmpdir=/tmp/minixtest-$$
  73. tmpimg=/tmp/minix-img-$$
  74. mkdir $tmpdir
  75. dd if=/dev/zero of=$tmpimg bs=1M count=20 || exit
  76. ./busybox mkfs.minix $tmpimg || exit
  77. mount -o loop $tmpimg $tmpdir || exit
  78. cp -a "$PWD" $tmpdir
  79. umount $tmpdir || exit
  80. ./busybox fsck.minix -vfm $tmpimg || exit
  81. echo "Continue?"
  82. read junk
  83. ./busybox fsck.minix -vfml $tmpimg || exit
  84. rmdir $tmpdir
  85. rm $tmpimg
  86. */