original development tree for Linux kernel GTP module; now long in mainline.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
7.8 KiB

  1. #ifndef _SYSV_H
  2. #define _SYSV_H
  3. #include <linux/buffer_head.h>
  4. typedef __u16 __bitwise __fs16;
  5. typedef __u32 __bitwise __fs32;
  6. #include <linux/sysv_fs.h>
  7. /*
  8. * SystemV/V7/Coherent super-block data in memory
  9. *
  10. * The SystemV/V7/Coherent superblock contains dynamic data (it gets modified
  11. * while the system is running). This is in contrast to the Minix and Berkeley
  12. * filesystems (where the superblock is never modified). This affects the
  13. * sync() operation: we must keep the superblock in a disk buffer and use this
  14. * one as our "working copy".
  15. */
  16. struct sysv_sb_info {
  17. struct super_block *s_sb; /* VFS superblock */
  18. int s_type; /* file system type: FSTYPE_{XENIX|SYSV|COH} */
  19. char s_bytesex; /* bytesex (le/be/pdp) */
  20. char s_truncate; /* if 1: names > SYSV_NAMELEN chars are truncated */
  21. /* if 0: they are disallowed (ENAMETOOLONG) */
  22. unsigned int s_inodes_per_block; /* number of inodes per block */
  23. unsigned int s_inodes_per_block_1; /* inodes_per_block - 1 */
  24. unsigned int s_inodes_per_block_bits; /* log2(inodes_per_block) */
  25. unsigned int s_ind_per_block; /* number of indirections per block */
  26. unsigned int s_ind_per_block_bits; /* log2(ind_per_block) */
  27. unsigned int s_ind_per_block_2; /* ind_per_block ^ 2 */
  28. unsigned int s_toobig_block; /* 10 + ipb + ipb^2 + ipb^3 */
  29. unsigned int s_block_base; /* physical block number of block 0 */
  30. unsigned short s_fic_size; /* free inode cache size, NICINOD */
  31. unsigned short s_flc_size; /* free block list chunk size, NICFREE */
  32. /* The superblock is kept in one or two disk buffers: */
  33. struct buffer_head *s_bh1;
  34. struct buffer_head *s_bh2;
  35. /* These are pointers into the disk buffer, to compensate for
  36. different superblock layout. */
  37. char * s_sbd1; /* entire superblock data, for part 1 */
  38. char * s_sbd2; /* entire superblock data, for part 2 */
  39. __fs16 *s_sb_fic_count; /* pointer to s_sbd->s_ninode */
  40. sysv_ino_t *s_sb_fic_inodes; /* pointer to s_sbd->s_inode */
  41. __fs16 *s_sb_total_free_inodes; /* pointer to s_sbd->s_tinode */
  42. __fs16 *s_bcache_count; /* pointer to s_sbd->s_nfree */
  43. sysv_zone_t *s_bcache; /* pointer to s_sbd->s_free */
  44. __fs32 *s_free_blocks; /* pointer to s_sbd->s_tfree */
  45. __fs32 *s_sb_time; /* pointer to s_sbd->s_time */
  46. __fs32 *s_sb_state; /* pointer to s_sbd->s_state, only FSTYPE_SYSV */
  47. /* We keep those superblock entities that don't change here;
  48. this saves us an indirection and perhaps a conversion. */
  49. u32 s_firstinodezone; /* index of first inode zone */
  50. u32 s_firstdatazone; /* same as s_sbd->s_isize */
  51. u32 s_ninodes; /* total number of inodes */
  52. u32 s_ndatazones; /* total number of data zones */
  53. u32 s_nzones; /* same as s_sbd->s_fsize */
  54. u16 s_namelen; /* max length of dir entry */
  55. int s_forced_ro;
  56. struct mutex s_lock;
  57. };
  58. /*
  59. * SystemV/V7/Coherent FS inode data in memory
  60. */
  61. struct sysv_inode_info {
  62. __fs32 i_data[13];
  63. u32 i_dir_start_lookup;
  64. struct inode vfs_inode;
  65. };
  66. static inline struct sysv_inode_info *SYSV_I(struct inode *inode)
  67. {
  68. return list_entry(inode, struct sysv_inode_info, vfs_inode);
  69. }
  70. static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
  71. {
  72. return sb->s_fs_info;
  73. }
  74. /* identify the FS in memory */
  75. enum {
  76. FSTYPE_NONE = 0,
  77. FSTYPE_XENIX,
  78. FSTYPE_SYSV4,
  79. FSTYPE_SYSV2,
  80. FSTYPE_COH,
  81. FSTYPE_V7,
  82. FSTYPE_AFS,
  83. FSTYPE_END,
  84. };
  85. #define SYSV_MAGIC_BASE 0x012FF7B3
  86. #define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX)
  87. #define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
  88. #define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
  89. #define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH)
  90. /* Admissible values for i_nlink: 0.._LINK_MAX */
  91. enum {
  92. XENIX_LINK_MAX = 126, /* ?? */
  93. SYSV_LINK_MAX = 126, /* 127? 251? */
  94. V7_LINK_MAX = 126, /* ?? */
  95. COH_LINK_MAX = 10000,
  96. };
  97. static inline void dirty_sb(struct super_block *sb)
  98. {
  99. struct sysv_sb_info *sbi = SYSV_SB(sb);
  100. mark_buffer_dirty(sbi->s_bh1);
  101. if (sbi->s_bh1 != sbi->s_bh2)
  102. mark_buffer_dirty(sbi->s_bh2);
  103. }
  104. /* ialloc.c */
  105. extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
  106. struct buffer_head **);
  107. extern struct inode * sysv_new_inode(const struct inode *, umode_t);
  108. extern void sysv_free_inode(struct inode *);
  109. extern unsigned long sysv_count_free_inodes(struct super_block *);
  110. /* balloc.c */
  111. extern sysv_zone_t sysv_new_block(struct super_block *);
  112. extern void sysv_free_block(struct super_block *, sysv_zone_t);
  113. extern unsigned long sysv_count_free_blocks(struct super_block *);
  114. /* itree.c */
  115. extern void sysv_truncate(struct inode *);
  116. extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len);
  117. /* inode.c */
  118. extern struct inode *sysv_iget(struct super_block *, unsigned int);
  119. extern int sysv_write_inode(struct inode *, struct writeback_control *wbc);
  120. extern int sysv_sync_inode(struct inode *);
  121. extern void sysv_set_inode(struct inode *, dev_t);
  122. extern int sysv_getattr(struct vfsmount *, struct dentry *, struct kstat *);
  123. extern int sysv_init_icache(void);
  124. extern void sysv_destroy_icache(void);
  125. /* dir.c */
  126. extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
  127. extern int sysv_add_link(struct dentry *, struct inode *);
  128. extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
  129. extern int sysv_make_empty(struct inode *, struct inode *);
  130. extern int sysv_empty_dir(struct inode *);
  131. extern void sysv_set_link(struct sysv_dir_entry *, struct page *,
  132. struct inode *);
  133. extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
  134. extern ino_t sysv_inode_by_name(struct dentry *);
  135. extern const struct inode_operations sysv_file_inode_operations;
  136. extern const struct inode_operations sysv_dir_inode_operations;
  137. extern const struct inode_operations sysv_fast_symlink_inode_operations;
  138. extern const struct file_operations sysv_file_operations;
  139. extern const struct file_operations sysv_dir_operations;
  140. extern const struct address_space_operations sysv_aops;
  141. extern const struct super_operations sysv_sops;
  142. extern const struct dentry_operations sysv_dentry_operations;
  143. enum {
  144. BYTESEX_LE,
  145. BYTESEX_PDP,
  146. BYTESEX_BE,
  147. };
  148. static inline u32 PDP_swab(u32 x)
  149. {
  150. #ifdef __LITTLE_ENDIAN
  151. return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
  152. #else
  153. #ifdef __BIG_ENDIAN
  154. return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
  155. #else
  156. #error BYTESEX
  157. #endif
  158. #endif
  159. }
  160. static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
  161. {
  162. if (sbi->s_bytesex == BYTESEX_PDP)
  163. return PDP_swab((__force __u32)n);
  164. else if (sbi->s_bytesex == BYTESEX_LE)
  165. return le32_to_cpu((__force __le32)n);
  166. else
  167. return be32_to_cpu((__force __be32)n);
  168. }
  169. static inline __fs32 cpu_to_fs32(struct sysv_sb_info *sbi, __u32 n)
  170. {
  171. if (sbi->s_bytesex == BYTESEX_PDP)
  172. return (__force __fs32)PDP_swab(n);
  173. else if (sbi->s_bytesex == BYTESEX_LE)
  174. return (__force __fs32)cpu_to_le32(n);
  175. else
  176. return (__force __fs32)cpu_to_be32(n);
  177. }
  178. static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
  179. {
  180. if (sbi->s_bytesex == BYTESEX_PDP)
  181. *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
  182. else if (sbi->s_bytesex == BYTESEX_LE)
  183. le32_add_cpu((__le32 *)n, d);
  184. else
  185. be32_add_cpu((__be32 *)n, d);
  186. return *n;
  187. }
  188. static inline __u16 fs16_to_cpu(struct sysv_sb_info *sbi, __fs16 n)
  189. {
  190. if (sbi->s_bytesex != BYTESEX_BE)
  191. return le16_to_cpu((__force __le16)n);
  192. else
  193. return be16_to_cpu((__force __be16)n);
  194. }
  195. static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
  196. {
  197. if (sbi->s_bytesex != BYTESEX_BE)
  198. return (__force __fs16)cpu_to_le16(n);
  199. else
  200. return (__force __fs16)cpu_to_be16(n);
  201. }
  202. static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
  203. {
  204. if (sbi->s_bytesex != BYTESEX_BE)
  205. le16_add_cpu((__le16 *)n, d);
  206. else
  207. be16_add_cpu((__be16 *)n, d);
  208. return *n;
  209. }
  210. #endif /* _SYSV_H */