INTRO 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. This is the implementation of the SystemV/Coherent filesystem for Linux.
  2. It grew out of separate filesystem implementations
  3. Xenix FS Doug Evans <dje@cygnus.com> June 1992
  4. SystemV FS Paul B. Monday <pmonday@eecs.wsu.edu> March-June 1993
  5. Coherent FS B. Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> June 1993
  6. and was merged together in July 1993.
  7. These filesystems are rather similar. Here is a comparison with Minix FS:
  8. * Linux fdisk reports on partitions
  9. - Minix FS 0x81 Linux/Minix
  10. - Xenix FS ??
  11. - SystemV FS ??
  12. - Coherent FS 0x08 AIX bootable
  13. * Size of a block or zone (data allocation unit on disk)
  14. - Minix FS 1024
  15. - Xenix FS 1024 (also 512 ??)
  16. - SystemV FS 1024 (also 512 and 2048)
  17. - Coherent FS 512
  18. * General layout: all have one boot block, one super block and
  19. separate areas for inodes and for directories/data.
  20. On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
  21. all the block numbers (including the super block) are offset by one track.
  22. * Byte ordering of "short" (16 bit entities) on disk:
  23. - Minix FS little endian 0 1
  24. - Xenix FS little endian 0 1
  25. - SystemV FS little endian 0 1
  26. - Coherent FS little endian 0 1
  27. Of course, this affects only the file system, not the data of files on it!
  28. * Byte ordering of "long" (32 bit entities) on disk:
  29. - Minix FS little endian 0 1 2 3
  30. - Xenix FS little endian 0 1 2 3
  31. - SystemV FS little endian 0 1 2 3
  32. - Coherent FS PDP-11 2 3 0 1
  33. Of course, this affects only the file system, not the data of files on it!
  34. * Inode on disk: "short", 0 means non-existent, the root dir ino is:
  35. - Minix FS 1
  36. - Xenix FS, SystemV FS, Coherent FS 2
  37. * Maximum number of hard links to a file:
  38. - Minix FS 250
  39. - Xenix FS ??
  40. - SystemV FS ??
  41. - Coherent FS >=10000
  42. * Free inode management:
  43. - Minix FS a bitmap
  44. - Xenix FS, SystemV FS, Coherent FS
  45. There is a cache of a certain number of free inodes in the super-block.
  46. When it is exhausted, new free inodes are found using a linear search.
  47. * Free block management:
  48. - Minix FS a bitmap
  49. - Xenix FS, SystemV FS, Coherent FS
  50. Free blocks are organized in a "free list". Maybe a misleading term,
  51. since it is not true that every free block contains a pointer to
  52. the next free block. Rather, the free blocks are organized in chunks
  53. of limited size, and every now and then a free block contains pointers
  54. to the free blocks pertaining to the next chunk; the first of these
  55. contains pointers and so on. The list terminates with a "block number"
  56. 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
  57. * Super-block location:
  58. - Minix FS block 1 = bytes 1024..2047
  59. - Xenix FS block 1 = bytes 1024..2047
  60. - SystemV FS bytes 512..1023
  61. - Coherent FS block 1 = bytes 512..1023
  62. * Super-block layout:
  63. - Minix FS
  64. unsigned short s_ninodes;
  65. unsigned short s_nzones;
  66. unsigned short s_imap_blocks;
  67. unsigned short s_zmap_blocks;
  68. unsigned short s_firstdatazone;
  69. unsigned short s_log_zone_size;
  70. unsigned long s_max_size;
  71. unsigned short s_magic;
  72. - Xenix FS, SystemV FS, Coherent FS
  73. unsigned short s_firstdatazone;
  74. unsigned long s_nzones;
  75. unsigned short s_fzone_count;
  76. unsigned long s_fzones[NICFREE];
  77. unsigned short s_finode_count;
  78. unsigned short s_finodes[NICINOD];
  79. char s_flock;
  80. char s_ilock;
  81. char s_modified;
  82. char s_rdonly;
  83. unsigned long s_time;
  84. short s_dinfo[4]; -- SystemV FS only
  85. unsigned long s_free_zones;
  86. unsigned short s_free_inodes;
  87. short s_dinfo[4]; -- Xenix FS only
  88. unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
  89. char s_fname[6];
  90. char s_fpack[6];
  91. then they differ considerably:
  92. Xenix FS
  93. char s_clean;
  94. char s_fill[371];
  95. long s_magic;
  96. long s_type;
  97. SystemV FS
  98. long s_fill[12 or 14];
  99. long s_state;
  100. long s_magic;
  101. long s_type;
  102. Coherent FS
  103. unsigned long s_unique;
  104. Note that Coherent FS has no magic.
  105. * Inode layout:
  106. - Minix FS
  107. unsigned short i_mode;
  108. unsigned short i_uid;
  109. unsigned long i_size;
  110. unsigned long i_time;
  111. unsigned char i_gid;
  112. unsigned char i_nlinks;
  113. unsigned short i_zone[7+1+1];
  114. - Xenix FS, SystemV FS, Coherent FS
  115. unsigned short i_mode;
  116. unsigned short i_nlink;
  117. unsigned short i_uid;
  118. unsigned short i_gid;
  119. unsigned long i_size;
  120. unsigned char i_zone[3*(10+1+1+1)];
  121. unsigned long i_atime;
  122. unsigned long i_mtime;
  123. unsigned long i_ctime;
  124. * Regular file data blocks are organized as
  125. - Minix FS
  126. 7 direct blocks
  127. 1 indirect block (pointers to blocks)
  128. 1 double-indirect block (pointer to pointers to blocks)
  129. - Xenix FS, SystemV FS, Coherent FS
  130. 10 direct blocks
  131. 1 indirect block (pointers to blocks)
  132. 1 double-indirect block (pointer to pointers to blocks)
  133. 1 triple-indirect block (pointer to pointers to pointers to blocks)
  134. * Inode size, inodes per block
  135. - Minix FS 32 32
  136. - Xenix FS 64 16
  137. - SystemV FS 64 16
  138. - Coherent FS 64 8
  139. * Directory entry on disk
  140. - Minix FS
  141. unsigned short inode;
  142. char name[14/30];
  143. - Xenix FS, SystemV FS, Coherent FS
  144. unsigned short inode;
  145. char name[14];
  146. * Dir entry size, dir entries per block
  147. - Minix FS 16/32 64/32
  148. - Xenix FS 16 64
  149. - SystemV FS 16 64
  150. - Coherent FS 16 32
  151. * How to implement symbolic links such that the host fsck doesn't scream:
  152. - Minix FS normal
  153. - Xenix FS kludge: as regular files with chmod 1000
  154. - SystemV FS ??
  155. - Coherent FS kludge: as regular files with chmod 1000
  156. Notation: We often speak of a "block" but mean a zone (the allocation unit)
  157. and not the disk driver's notion of "block".
  158. Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de>