4 #include <linux/buffer_head.h>
6 typedef __u16 __bitwise __fs16;
7 typedef __u32 __bitwise __fs32;
9 #include <linux/sysv_fs.h>
12 * SystemV/V7/Coherent super-block data in memory
14 * The SystemV/V7/Coherent superblock contains dynamic data (it gets modified
15 * while the system is running). This is in contrast to the Minix and Berkeley
16 * filesystems (where the superblock is never modified). This affects the
17 * sync() operation: we must keep the superblock in a disk buffer and use this
18 * one as our "working copy".
22 struct super_block *s_sb; /* VFS superblock */
23 int s_type; /* file system type: FSTYPE_{XENIX|SYSV|COH} */
24 char s_bytesex; /* bytesex (le/be/pdp) */
25 char s_truncate; /* if 1: names > SYSV_NAMELEN chars are truncated */
26 /* if 0: they are disallowed (ENAMETOOLONG) */
27 unsigned int s_inodes_per_block; /* number of inodes per block */
28 unsigned int s_inodes_per_block_1; /* inodes_per_block - 1 */
29 unsigned int s_inodes_per_block_bits; /* log2(inodes_per_block) */
30 unsigned int s_ind_per_block; /* number of indirections per block */
31 unsigned int s_ind_per_block_bits; /* log2(ind_per_block) */
32 unsigned int s_ind_per_block_2; /* ind_per_block ^ 2 */
33 unsigned int s_toobig_block; /* 10 + ipb + ipb^2 + ipb^3 */
34 unsigned int s_block_base; /* physical block number of block 0 */
35 unsigned short s_fic_size; /* free inode cache size, NICINOD */
36 unsigned short s_flc_size; /* free block list chunk size, NICFREE */
37 /* The superblock is kept in one or two disk buffers: */
38 struct buffer_head *s_bh1;
39 struct buffer_head *s_bh2;
40 /* These are pointers into the disk buffer, to compensate for
41 different superblock layout. */
42 char * s_sbd1; /* entire superblock data, for part 1 */
43 char * s_sbd2; /* entire superblock data, for part 2 */
44 __fs16 *s_sb_fic_count; /* pointer to s_sbd->s_ninode */
45 sysv_ino_t *s_sb_fic_inodes; /* pointer to s_sbd->s_inode */
46 __fs16 *s_sb_total_free_inodes; /* pointer to s_sbd->s_tinode */
47 __fs16 *s_bcache_count; /* pointer to s_sbd->s_nfree */
48 sysv_zone_t *s_bcache; /* pointer to s_sbd->s_free */
49 __fs32 *s_free_blocks; /* pointer to s_sbd->s_tfree */
50 __fs32 *s_sb_time; /* pointer to s_sbd->s_time */
51 __fs32 *s_sb_state; /* pointer to s_sbd->s_state, only FSTYPE_SYSV */
52 /* We keep those superblock entities that don't change here;
53 this saves us an indirection and perhaps a conversion. */
54 u32 s_firstinodezone; /* index of first inode zone */
55 u32 s_firstdatazone; /* same as s_sbd->s_isize */
56 u32 s_ninodes; /* total number of inodes */
57 u32 s_ndatazones; /* total number of data zones */
58 u32 s_nzones; /* same as s_sbd->s_fsize */
59 u16 s_namelen; /* max length of dir entry */
64 * SystemV/V7/Coherent FS inode data in memory
66 struct sysv_inode_info {
68 u32 i_dir_start_lookup;
69 struct inode vfs_inode;
73 static inline struct sysv_inode_info *SYSV_I(struct inode *inode)
75 return list_entry(inode, struct sysv_inode_info, vfs_inode);
78 static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
84 /* identify the FS in memory */
96 #define SYSV_MAGIC_BASE 0x012FF7B3
98 #define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX)
99 #define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
100 #define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
101 #define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH)
104 /* Admissible values for i_nlink: 0.._LINK_MAX */
106 XENIX_LINK_MAX = 126, /* ?? */
107 SYSV_LINK_MAX = 126, /* 127? 251? */
108 V7_LINK_MAX = 126, /* ?? */
109 COH_LINK_MAX = 10000,
113 static inline void dirty_sb(struct super_block *sb)
115 struct sysv_sb_info *sbi = SYSV_SB(sb);
117 mark_buffer_dirty(sbi->s_bh1);
118 if (sbi->s_bh1 != sbi->s_bh2)
119 mark_buffer_dirty(sbi->s_bh2);
124 extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
125 struct buffer_head **);
126 extern struct inode * sysv_new_inode(const struct inode *, umode_t);
127 extern void sysv_free_inode(struct inode *);
128 extern unsigned long sysv_count_free_inodes(struct super_block *);
131 extern sysv_zone_t sysv_new_block(struct super_block *);
132 extern void sysv_free_block(struct super_block *, sysv_zone_t);
133 extern unsigned long sysv_count_free_blocks(struct super_block *);
136 extern void sysv_truncate(struct inode *);
137 extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len);
140 extern struct inode *sysv_iget(struct super_block *, unsigned int);
141 extern int sysv_write_inode(struct inode *, struct writeback_control *wbc);
142 extern int sysv_sync_inode(struct inode *);
143 extern void sysv_set_inode(struct inode *, dev_t);
144 extern int sysv_getattr(struct vfsmount *, struct dentry *, struct kstat *);
145 extern int sysv_init_icache(void);
146 extern void sysv_destroy_icache(void);
150 extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
151 extern int sysv_add_link(struct dentry *, struct inode *);
152 extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
153 extern int sysv_make_empty(struct inode *, struct inode *);
154 extern int sysv_empty_dir(struct inode *);
155 extern void sysv_set_link(struct sysv_dir_entry *, struct page *,
157 extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
158 extern ino_t sysv_inode_by_name(struct dentry *);
161 extern const struct inode_operations sysv_file_inode_operations;
162 extern const struct inode_operations sysv_dir_inode_operations;
163 extern const struct inode_operations sysv_fast_symlink_inode_operations;
164 extern const struct file_operations sysv_file_operations;
165 extern const struct file_operations sysv_dir_operations;
166 extern const struct address_space_operations sysv_aops;
167 extern const struct super_operations sysv_sops;
168 extern const struct dentry_operations sysv_dentry_operations;
177 static inline u32 PDP_swab(u32 x)
179 #ifdef __LITTLE_ENDIAN
180 return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
183 return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
190 static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
192 if (sbi->s_bytesex == BYTESEX_PDP)
193 return PDP_swab((__force __u32)n);
194 else if (sbi->s_bytesex == BYTESEX_LE)
195 return le32_to_cpu((__force __le32)n);
197 return be32_to_cpu((__force __be32)n);
200 static inline __fs32 cpu_to_fs32(struct sysv_sb_info *sbi, __u32 n)
202 if (sbi->s_bytesex == BYTESEX_PDP)
203 return (__force __fs32)PDP_swab(n);
204 else if (sbi->s_bytesex == BYTESEX_LE)
205 return (__force __fs32)cpu_to_le32(n);
207 return (__force __fs32)cpu_to_be32(n);
210 static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
212 if (sbi->s_bytesex == BYTESEX_PDP)
213 *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
214 else if (sbi->s_bytesex == BYTESEX_LE)
215 le32_add_cpu((__le32 *)n, d);
217 be32_add_cpu((__be32 *)n, d);
221 static inline __u16 fs16_to_cpu(struct sysv_sb_info *sbi, __fs16 n)
223 if (sbi->s_bytesex != BYTESEX_BE)
224 return le16_to_cpu((__force __le16)n);
226 return be16_to_cpu((__force __be16)n);
229 static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
231 if (sbi->s_bytesex != BYTESEX_BE)
232 return (__force __fs16)cpu_to_le16(n);
234 return (__force __fs16)cpu_to_be16(n);
237 static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
239 if (sbi->s_bytesex != BYTESEX_BE)
240 le16_add_cpu((__le16 *)n, d);
242 be16_add_cpu((__be16 *)n, d);