sysv-fs.rst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ==================
  3. SystemV Filesystem
  4. ==================
  5. It implements all of
  6. - Xenix FS,
  7. - SystemV/386 FS,
  8. - Coherent FS.
  9. To install:
  10. * Answer the 'System V and Coherent filesystem support' question with 'y'
  11. when configuring the kernel.
  12. * To mount a disk or a partition, use::
  13. mount [-r] -t sysv device mountpoint
  14. The file system type names::
  15. -t sysv
  16. -t xenix
  17. -t coherent
  18. may be used interchangeably, but the last two will eventually disappear.
  19. Bugs in the present implementation:
  20. - Coherent FS:
  21. - The "free list interleave" n:m is currently ignored.
  22. - Only file systems with no filesystem name and no pack name are recognized.
  23. (See Coherent "man mkfs" for a description of these features.)
  24. - SystemV Release 2 FS:
  25. The superblock is only searched in the blocks 9, 15, 18, which
  26. corresponds to the beginning of track 1 on floppy disks. No support
  27. for this FS on hard disk yet.
  28. These filesystems are rather similar. Here is a comparison with Minix FS:
  29. * Linux fdisk reports on partitions
  30. - Minix FS 0x81 Linux/Minix
  31. - Xenix FS ??
  32. - SystemV FS ??
  33. - Coherent FS 0x08 AIX bootable
  34. * Size of a block or zone (data allocation unit on disk)
  35. - Minix FS 1024
  36. - Xenix FS 1024 (also 512 ??)
  37. - SystemV FS 1024 (also 512 and 2048)
  38. - Coherent FS 512
  39. * General layout: all have one boot block, one super block and
  40. separate areas for inodes and for directories/data.
  41. On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
  42. all the block numbers (including the super block) are offset by one track.
  43. * Byte ordering of "short" (16 bit entities) on disk:
  44. - Minix FS little endian 0 1
  45. - Xenix FS little endian 0 1
  46. - SystemV FS little endian 0 1
  47. - Coherent FS little endian 0 1
  48. Of course, this affects only the file system, not the data of files on it!
  49. * Byte ordering of "long" (32 bit entities) on disk:
  50. - Minix FS little endian 0 1 2 3
  51. - Xenix FS little endian 0 1 2 3
  52. - SystemV FS little endian 0 1 2 3
  53. - Coherent FS PDP-11 2 3 0 1
  54. Of course, this affects only the file system, not the data of files on it!
  55. * Inode on disk: "short", 0 means non-existent, the root dir ino is:
  56. ================================= ==
  57. Minix FS 1
  58. Xenix FS, SystemV FS, Coherent FS 2
  59. ================================= ==
  60. * Maximum number of hard links to a file:
  61. =========== =========
  62. Minix FS 250
  63. Xenix FS ??
  64. SystemV FS ??
  65. Coherent FS >=10000
  66. =========== =========
  67. * Free inode management:
  68. - Minix FS
  69. a bitmap
  70. - Xenix FS, SystemV FS, Coherent FS
  71. There is a cache of a certain number of free inodes in the super-block.
  72. When it is exhausted, new free inodes are found using a linear search.
  73. * Free block management:
  74. - Minix FS
  75. a bitmap
  76. - Xenix FS, SystemV FS, Coherent FS
  77. Free blocks are organized in a "free list". Maybe a misleading term,
  78. since it is not true that every free block contains a pointer to
  79. the next free block. Rather, the free blocks are organized in chunks
  80. of limited size, and every now and then a free block contains pointers
  81. to the free blocks pertaining to the next chunk; the first of these
  82. contains pointers and so on. The list terminates with a "block number"
  83. 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
  84. * Super-block location:
  85. =========== ==========================
  86. Minix FS block 1 = bytes 1024..2047
  87. Xenix FS block 1 = bytes 1024..2047
  88. SystemV FS bytes 512..1023
  89. Coherent FS block 1 = bytes 512..1023
  90. =========== ==========================
  91. * Super-block layout:
  92. - Minix FS::
  93. unsigned short s_ninodes;
  94. unsigned short s_nzones;
  95. unsigned short s_imap_blocks;
  96. unsigned short s_zmap_blocks;
  97. unsigned short s_firstdatazone;
  98. unsigned short s_log_zone_size;
  99. unsigned long s_max_size;
  100. unsigned short s_magic;
  101. - Xenix FS, SystemV FS, Coherent FS::
  102. unsigned short s_firstdatazone;
  103. unsigned long s_nzones;
  104. unsigned short s_fzone_count;
  105. unsigned long s_fzones[NICFREE];
  106. unsigned short s_finode_count;
  107. unsigned short s_finodes[NICINOD];
  108. char s_flock;
  109. char s_ilock;
  110. char s_modified;
  111. char s_rdonly;
  112. unsigned long s_time;
  113. short s_dinfo[4]; -- SystemV FS only
  114. unsigned long s_free_zones;
  115. unsigned short s_free_inodes;
  116. short s_dinfo[4]; -- Xenix FS only
  117. unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
  118. char s_fname[6];
  119. char s_fpack[6];
  120. then they differ considerably:
  121. Xenix FS::
  122. char s_clean;
  123. char s_fill[371];
  124. long s_magic;
  125. long s_type;
  126. SystemV FS::
  127. long s_fill[12 or 14];
  128. long s_state;
  129. long s_magic;
  130. long s_type;
  131. Coherent FS::
  132. unsigned long s_unique;
  133. Note that Coherent FS has no magic.
  134. * Inode layout:
  135. - Minix FS::
  136. unsigned short i_mode;
  137. unsigned short i_uid;
  138. unsigned long i_size;
  139. unsigned long i_time;
  140. unsigned char i_gid;
  141. unsigned char i_nlinks;
  142. unsigned short i_zone[7+1+1];
  143. - Xenix FS, SystemV FS, Coherent FS::
  144. unsigned short i_mode;
  145. unsigned short i_nlink;
  146. unsigned short i_uid;
  147. unsigned short i_gid;
  148. unsigned long i_size;
  149. unsigned char i_zone[3*(10+1+1+1)];
  150. unsigned long i_atime;
  151. unsigned long i_mtime;
  152. unsigned long i_ctime;
  153. * Regular file data blocks are organized as
  154. - Minix FS:
  155. - 7 direct blocks
  156. - 1 indirect block (pointers to blocks)
  157. - 1 double-indirect block (pointer to pointers to blocks)
  158. - Xenix FS, SystemV FS, Coherent FS:
  159. - 10 direct blocks
  160. - 1 indirect block (pointers to blocks)
  161. - 1 double-indirect block (pointer to pointers to blocks)
  162. - 1 triple-indirect block (pointer to pointers to pointers to blocks)
  163. =========== ========== ================
  164. Inode size inodes per block
  165. =========== ========== ================
  166. Minix FS 32 32
  167. Xenix FS 64 16
  168. SystemV FS 64 16
  169. Coherent FS 64 8
  170. =========== ========== ================
  171. * Directory entry on disk
  172. - Minix FS::
  173. unsigned short inode;
  174. char name[14/30];
  175. - Xenix FS, SystemV FS, Coherent FS::
  176. unsigned short inode;
  177. char name[14];
  178. =========== ============== =====================
  179. Dir entry size dir entries per block
  180. =========== ============== =====================
  181. Minix FS 16/32 64/32
  182. Xenix FS 16 64
  183. SystemV FS 16 64
  184. Coherent FS 16 32
  185. =========== ============== =====================
  186. * How to implement symbolic links such that the host fsck doesn't scream:
  187. - Minix FS normal
  188. - Xenix FS kludge: as regular files with chmod 1000
  189. - SystemV FS ??
  190. - Coherent FS kludge: as regular files with chmod 1000
  191. Notation: We often speak of a "block" but mean a zone (the allocation unit)
  192. and not the disk driver's notion of "block".