sysv_fs.h 9.0 KB

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