1#ifndef _SYSV_H
2#define _SYSV_H
3
4#include <linux/buffer_head.h>
5
6typedef __u16 __bitwise __fs16;
7typedef __u32 __bitwise __fs32;
8
9#include <linux/sysv_fs.h>
10
11
12
13
14
15
16
17
18
19
20
21struct sysv_sb_info {
22 struct super_block *s_sb;
23 int s_type;
24 char s_bytesex;
25 char s_truncate;
26
27 unsigned int s_inodes_per_block;
28 unsigned int s_inodes_per_block_1;
29 unsigned int s_inodes_per_block_bits;
30 unsigned int s_ind_per_block;
31 unsigned int s_ind_per_block_bits;
32 unsigned int s_ind_per_block_2;
33 unsigned int s_toobig_block;
34 unsigned int s_block_base;
35 unsigned short s_fic_size;
36 unsigned short s_flc_size;
37
38 struct buffer_head *s_bh1;
39 struct buffer_head *s_bh2;
40
41
42 char * s_sbd1;
43 char * s_sbd2;
44 __fs16 *s_sb_fic_count;
45 sysv_ino_t *s_sb_fic_inodes;
46 __fs16 *s_sb_total_free_inodes;
47 __fs16 *s_bcache_count;
48 sysv_zone_t *s_bcache;
49 __fs32 *s_free_blocks;
50 __fs32 *s_sb_time;
51 __fs32 *s_sb_state;
52
53
54 u32 s_firstinodezone;
55 u32 s_firstdatazone;
56 u32 s_ninodes;
57 u32 s_ndatazones;
58 u32 s_nzones;
59 u16 s_namelen;
60 int s_forced_ro;
61 struct mutex s_lock;
62};
63
64
65
66
67struct sysv_inode_info {
68 __fs32 i_data[13];
69 u32 i_dir_start_lookup;
70 struct inode vfs_inode;
71};
72
73
74static inline struct sysv_inode_info *SYSV_I(struct inode *inode)
75{
76 return list_entry(inode, struct sysv_inode_info, vfs_inode);
77}
78
79static inline struct sysv_sb_info *SYSV_SB(struct super_block *sb)
80{
81 return sb->s_fs_info;
82}
83
84
85
86enum {
87 FSTYPE_NONE = 0,
88 FSTYPE_XENIX,
89 FSTYPE_SYSV4,
90 FSTYPE_SYSV2,
91 FSTYPE_COH,
92 FSTYPE_V7,
93 FSTYPE_AFS,
94 FSTYPE_END,
95};
96
97#define SYSV_MAGIC_BASE 0x012FF7B3
98
99#define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX)
100#define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
101#define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
102#define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH)
103
104
105
106enum {
107 XENIX_LINK_MAX = 126,
108 SYSV_LINK_MAX = 126,
109 V7_LINK_MAX = 126,
110 COH_LINK_MAX = 10000,
111};
112
113
114static inline void dirty_sb(struct super_block *sb)
115{
116 struct sysv_sb_info *sbi = SYSV_SB(sb);
117
118 mark_buffer_dirty(sbi->s_bh1);
119 if (sbi->s_bh1 != sbi->s_bh2)
120 mark_buffer_dirty(sbi->s_bh2);
121}
122
123
124
125extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
126 struct buffer_head **);
127extern struct inode * sysv_new_inode(const struct inode *, umode_t);
128extern void sysv_free_inode(struct inode *);
129extern unsigned long sysv_count_free_inodes(struct super_block *);
130
131
132extern sysv_zone_t sysv_new_block(struct super_block *);
133extern void sysv_free_block(struct super_block *, sysv_zone_t);
134extern unsigned long sysv_count_free_blocks(struct super_block *);
135
136
137extern void sysv_truncate(struct inode *);
138extern int sysv_prepare_chunk(struct page *page, loff_t pos, unsigned len);
139
140
141extern struct inode *sysv_iget(struct super_block *, unsigned int);
142extern int sysv_write_inode(struct inode *, struct writeback_control *wbc);
143extern int sysv_sync_inode(struct inode *);
144extern void sysv_set_inode(struct inode *, dev_t);
145extern int sysv_getattr(struct vfsmount *, struct dentry *, struct kstat *);
146extern int sysv_init_icache(void);
147extern void sysv_destroy_icache(void);
148
149
150
151extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
152extern int sysv_add_link(struct dentry *, struct inode *);
153extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
154extern int sysv_make_empty(struct inode *, struct inode *);
155extern int sysv_empty_dir(struct inode *);
156extern void sysv_set_link(struct sysv_dir_entry *, struct page *,
157 struct inode *);
158extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
159extern ino_t sysv_inode_by_name(struct dentry *);
160
161
162extern const struct inode_operations sysv_file_inode_operations;
163extern const struct inode_operations sysv_dir_inode_operations;
164extern const struct inode_operations sysv_fast_symlink_inode_operations;
165extern const struct file_operations sysv_file_operations;
166extern const struct file_operations sysv_dir_operations;
167extern const struct address_space_operations sysv_aops;
168extern const struct super_operations sysv_sops;
169extern const struct dentry_operations sysv_dentry_operations;
170
171
172enum {
173 BYTESEX_LE,
174 BYTESEX_PDP,
175 BYTESEX_BE,
176};
177
178static inline u32 PDP_swab(u32 x)
179{
180#ifdef __LITTLE_ENDIAN
181 return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
182#else
183#ifdef __BIG_ENDIAN
184 return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
185#else
186#error BYTESEX
187#endif
188#endif
189}
190
191static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
192{
193 if (sbi->s_bytesex == BYTESEX_PDP)
194 return PDP_swab((__force __u32)n);
195 else if (sbi->s_bytesex == BYTESEX_LE)
196 return le32_to_cpu((__force __le32)n);
197 else
198 return be32_to_cpu((__force __be32)n);
199}
200
201static inline __fs32 cpu_to_fs32(struct sysv_sb_info *sbi, __u32 n)
202{
203 if (sbi->s_bytesex == BYTESEX_PDP)
204 return (__force __fs32)PDP_swab(n);
205 else if (sbi->s_bytesex == BYTESEX_LE)
206 return (__force __fs32)cpu_to_le32(n);
207 else
208 return (__force __fs32)cpu_to_be32(n);
209}
210
211static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
212{
213 if (sbi->s_bytesex == BYTESEX_PDP)
214 *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
215 else if (sbi->s_bytesex == BYTESEX_LE)
216 le32_add_cpu((__le32 *)n, d);
217 else
218 be32_add_cpu((__be32 *)n, d);
219 return *n;
220}
221
222static inline __u16 fs16_to_cpu(struct sysv_sb_info *sbi, __fs16 n)
223{
224 if (sbi->s_bytesex != BYTESEX_BE)
225 return le16_to_cpu((__force __le16)n);
226 else
227 return be16_to_cpu((__force __be16)n);
228}
229
230static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
231{
232 if (sbi->s_bytesex != BYTESEX_BE)
233 return (__force __fs16)cpu_to_le16(n);
234 else
235 return (__force __fs16)cpu_to_be16(n);
236}
237
238static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
239{
240 if (sbi->s_bytesex != BYTESEX_BE)
241 le16_add_cpu((__le16 *)n, d);
242 else
243 be16_add_cpu((__be16 *)n, d);
244 return *n;
245}
246
247#endif
248