sysv_fs.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SYSV_FS_H
  3. #define _LINUX_SYSV_FS_H
  4. #define __packed2__ __attribute__((packed, aligned(2)))
  5. #ifndef __KERNEL__
  6. typedef u16 __fs16;
  7. typedef u32 __fs16;
  8. #endif
  9. /* inode numbers are 16 bit */
  10. typedef __fs16 sysv_ino_t;
  11. /* Block numbers are 24 bit, sometimes stored in 32 bit.
  12. On Coherent FS, they are always stored in PDP-11 manner: the least
  13. significant 16 bits come last. */
  14. typedef __fs32 sysv_zone_t;
  15. /* 0 is non-existent */
  16. #define SYSV_BADBL_INO 1 /* inode of bad blocks file */
  17. #define SYSV_ROOT_INO 2 /* inode of root directory */
  18. /* Xenix super-block data on disk */
  19. #define XENIX_NICINOD 100 /* number of inode cache entries */
  20. #define XENIX_NICFREE 100 /* number of free block list chunk entries */
  21. struct xenix_super_block {
  22. __fs16 s_isize; /* index of first data zone */
  23. __fs32 s_fsize __packed2__; /* total number of zones of this fs */
  24. /* the start of the free block list: */
  25. __fs16 s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */
  26. sysv_zone_t s_free[XENIX_NICFREE]; /* first free block list chunk */
  27. /* the cache of free inodes: */
  28. __fs16 s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
  29. sysv_ino_t s_inode[XENIX_NICINOD]; /* some free inodes */
  30. /* locks, not used by Linux: */
  31. char s_flock; /* lock during free block list manipulation */
  32. char s_ilock; /* lock during inode cache manipulation */
  33. char s_fmod; /* super-block modified flag */
  34. char s_ronly; /* flag whether fs is mounted read-only */
  35. __fs32 s_time __packed2__; /* time of last super block update */
  36. __fs32 s_tfree __packed2__; /* total number of free zones */
  37. __fs16 s_tinode; /* total number of free inodes */
  38. __fs16 s_dinfo[4]; /* device information ?? */
  39. char s_fname[6]; /* file system volume name */
  40. char s_fpack[6]; /* file system pack name */
  41. char s_clean; /* set to 0x46 when filesystem is properly unmounted */
  42. char s_fill[371];
  43. s32 s_magic; /* version of file system */
  44. __fs32 s_type; /* type of file system: 1 for 512 byte blocks
  45. 2 for 1024 byte blocks
  46. 3 for 2048 byte blocks */
  47. };
  48. /*
  49. * SystemV FS comes in two variants:
  50. * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
  51. * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
  52. */
  53. #define SYSV_NICINOD 100 /* number of inode cache entries */
  54. #define SYSV_NICFREE 50 /* number of free block list chunk entries */
  55. /* SystemV4 super-block data on disk */
  56. struct sysv4_super_block {
  57. __fs16 s_isize; /* index of first data zone */
  58. u16 s_pad0;
  59. __fs32 s_fsize; /* total number of zones of this fs */
  60. /* the start of the free block list: */
  61. __fs16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
  62. u16 s_pad1;
  63. sysv_zone_t s_free[SYSV_NICFREE]; /* first free block list chunk */
  64. /* the cache of free inodes: */
  65. __fs16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
  66. u16 s_pad2;
  67. sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
  68. /* locks, not used by Linux: */
  69. char s_flock; /* lock during free block list manipulation */
  70. char s_ilock; /* lock during inode cache manipulation */
  71. char s_fmod; /* super-block modified flag */
  72. char s_ronly; /* flag whether fs is mounted read-only */
  73. __fs32 s_time; /* time of last super block update */
  74. __fs16 s_dinfo[4]; /* device information ?? */
  75. __fs32 s_tfree; /* total number of free zones */
  76. __fs16 s_tinode; /* total number of free inodes */
  77. u16 s_pad3;
  78. char s_fname[6]; /* file system volume name */
  79. char s_fpack[6]; /* file system pack name */
  80. s32 s_fill[12];
  81. __fs32 s_state; /* file system state: 0x7c269d38-s_time means clean */
  82. s32 s_magic; /* version of file system */
  83. __fs32 s_type; /* type of file system: 1 for 512 byte blocks
  84. 2 for 1024 byte blocks */
  85. };
  86. /* SystemV2 super-block data on disk */
  87. struct sysv2_super_block {
  88. __fs16 s_isize; /* index of first data zone */
  89. __fs32 s_fsize __packed2__; /* total number of zones of this fs */
  90. /* the start of the free block list: */
  91. __fs16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
  92. sysv_zone_t s_free[SYSV_NICFREE]; /* first free block list chunk */
  93. /* the cache of free inodes: */
  94. __fs16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
  95. sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
  96. /* locks, not used by Linux: */
  97. char s_flock; /* lock during free block list manipulation */
  98. char s_ilock; /* lock during inode cache manipulation */
  99. char s_fmod; /* super-block modified flag */
  100. char s_ronly; /* flag whether fs is mounted read-only */
  101. __fs32 s_time __packed2__; /* time of last super block update */
  102. __fs16 s_dinfo[4]; /* device information ?? */
  103. __fs32 s_tfree __packed2__; /* total number of free zones */
  104. __fs16 s_tinode; /* total number of free inodes */
  105. char s_fname[6]; /* file system volume name */
  106. char s_fpack[6]; /* file system pack name */
  107. s32 s_fill[14];
  108. __fs32 s_state; /* file system state: 0xcb096f43 means clean */
  109. s32 s_magic; /* version of file system */
  110. __fs32 s_type; /* type of file system: 1 for 512 byte blocks
  111. 2 for 1024 byte blocks */
  112. };
  113. /* V7 super-block data on disk */
  114. #define V7_NICINOD 100 /* number of inode cache entries */
  115. #define V7_NICFREE 50 /* number of free block list chunk entries */
  116. struct v7_super_block {
  117. __fs16 s_isize; /* index of first data zone */
  118. __fs32 s_fsize __packed2__; /* total number of zones of this fs */
  119. /* the start of the free block list: */
  120. __fs16 s_nfree; /* number of free blocks in s_free, <= V7_NICFREE */
  121. sysv_zone_t s_free[V7_NICFREE]; /* first free block list chunk */
  122. /* the cache of free inodes: */
  123. __fs16 s_ninode; /* number of free inodes in s_inode, <= V7_NICINOD */
  124. sysv_ino_t s_inode[V7_NICINOD]; /* some free inodes */
  125. /* locks, not used by Linux or V7: */
  126. char s_flock; /* lock during free block list manipulation */
  127. char s_ilock; /* lock during inode cache manipulation */
  128. char s_fmod; /* super-block modified flag */
  129. char s_ronly; /* flag whether fs is mounted read-only */
  130. __fs32 s_time __packed2__; /* time of last super block update */
  131. /* the following fields are not maintained by V7: */
  132. __fs32 s_tfree __packed2__; /* total number of free zones */
  133. __fs16 s_tinode; /* total number of free inodes */
  134. __fs16 s_m; /* interleave factor */
  135. __fs16 s_n; /* interleave factor */
  136. char s_fname[6]; /* file system name */
  137. char s_fpack[6]; /* file system pack name */
  138. };
  139. /* Constants to aid sanity checking */
  140. /* This is not a hard limit, nor enforced by v7 kernel. It's actually just
  141. * the limit used by Seventh Edition's ls, though is high enough to assume
  142. * that no reasonable file system would have that much entries in root
  143. * directory. Thus, if we see anything higher, we just probably got the
  144. * endiannes wrong. */
  145. #define V7_NFILES 1024
  146. /* The disk addresses are three-byte (despite direct block addresses being
  147. * aligned word-wise in inode). If the most significant byte is non-zero,
  148. * something is most likely wrong (not a filesystem, bad bytesex). */
  149. #define V7_MAXSIZE 0x00ffffff
  150. /* Coherent super-block data on disk */
  151. #define COH_NICINOD 100 /* number of inode cache entries */
  152. #define COH_NICFREE 64 /* number of free block list chunk entries */
  153. struct coh_super_block {
  154. __fs16 s_isize; /* index of first data zone */
  155. __fs32 s_fsize __packed2__; /* total number of zones of this fs */
  156. /* the start of the free block list: */
  157. __fs16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
  158. sysv_zone_t s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
  159. /* the cache of free inodes: */
  160. __fs16 s_ninode; /* number of free inodes in s_inode, <= COH_NICINOD */
  161. sysv_ino_t s_inode[COH_NICINOD]; /* some free inodes */
  162. /* locks, not used by Linux: */
  163. char s_flock; /* lock during free block list manipulation */
  164. char s_ilock; /* lock during inode cache manipulation */
  165. char s_fmod; /* super-block modified flag */
  166. char s_ronly; /* flag whether fs is mounted read-only */
  167. __fs32 s_time __packed2__; /* time of last super block update */
  168. __fs32 s_tfree __packed2__; /* total number of free zones */
  169. __fs16 s_tinode; /* total number of free inodes */
  170. __fs16 s_interleave_m; /* interleave factor */
  171. __fs16 s_interleave_n;
  172. char s_fname[6]; /* file system volume name */
  173. char s_fpack[6]; /* file system pack name */
  174. __fs32 s_unique; /* zero, not used */
  175. };
  176. /* SystemV/Coherent inode data on disk */
  177. struct sysv_inode {
  178. __fs16 i_mode;
  179. __fs16 i_nlink;
  180. __fs16 i_uid;
  181. __fs16 i_gid;
  182. __fs32 i_size;
  183. u8 i_data[3*(10+1+1+1)];
  184. u8 i_gen;
  185. __fs32 i_atime; /* time of last access */
  186. __fs32 i_mtime; /* time of last modification */
  187. __fs32 i_ctime; /* time of creation */
  188. };
  189. /* SystemV/Coherent directory entry on disk */
  190. #define SYSV_NAMELEN 14 /* max size of name in struct sysv_dir_entry */
  191. struct sysv_dir_entry {
  192. sysv_ino_t inode;
  193. char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
  194. };
  195. #define SYSV_DIRSIZE sizeof(struct sysv_dir_entry) /* size of every directory entry */
  196. #endif /* _LINUX_SYSV_FS_H */