aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysv/sysv.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/sysv/sysv.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'fs/sysv/sysv.h')
-rw-r--r--fs/sysv/sysv.h244
1 files changed, 244 insertions, 0 deletions
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
new file mode 100644
index 000000000000..b7f9b4a42aab
--- /dev/null
+++ b/fs/sysv/sysv.h
@@ -0,0 +1,244 @@
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 * SystemV/V7/Coherent super-block data in memory
13 *
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".
19 */
20
21struct sysv_sb_info {
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 nlink_t s_link_max; /* max number of hard links to a file */
28 unsigned int s_inodes_per_block; /* number of inodes per block */
29 unsigned int s_inodes_per_block_1; /* inodes_per_block - 1 */
30 unsigned int s_inodes_per_block_bits; /* log2(inodes_per_block) */
31 unsigned int s_ind_per_block; /* number of indirections per block */
32 unsigned int s_ind_per_block_bits; /* log2(ind_per_block) */
33 unsigned int s_ind_per_block_2; /* ind_per_block ^ 2 */
34 unsigned int s_toobig_block; /* 10 + ipb + ipb^2 + ipb^3 */
35 unsigned int s_block_base; /* physical block number of block 0 */
36 unsigned short s_fic_size; /* free inode cache size, NICINOD */
37 unsigned short s_flc_size; /* free block list chunk size, NICFREE */
38 /* The superblock is kept in one or two disk buffers: */
39 struct buffer_head *s_bh1;
40 struct buffer_head *s_bh2;
41 /* These are pointers into the disk buffer, to compensate for
42 different superblock layout. */
43 char * s_sbd1; /* entire superblock data, for part 1 */
44 char * s_sbd2; /* entire superblock data, for part 2 */
45 __fs16 *s_sb_fic_count; /* pointer to s_sbd->s_ninode */
46 sysv_ino_t *s_sb_fic_inodes; /* pointer to s_sbd->s_inode */
47 __fs16 *s_sb_total_free_inodes; /* pointer to s_sbd->s_tinode */
48 __fs16 *s_bcache_count; /* pointer to s_sbd->s_nfree */
49 sysv_zone_t *s_bcache; /* pointer to s_sbd->s_free */
50 __fs32 *s_free_blocks; /* pointer to s_sbd->s_tfree */
51 __fs32 *s_sb_time; /* pointer to s_sbd->s_time */
52 __fs32 *s_sb_state; /* pointer to s_sbd->s_state, only FSTYPE_SYSV */
53 /* We keep those superblock entities that don't change here;
54 this saves us an indirection and perhaps a conversion. */
55 u32 s_firstinodezone; /* index of first inode zone */
56 u32 s_firstdatazone; /* same as s_sbd->s_isize */
57 u32 s_ninodes; /* total number of inodes */
58 u32 s_ndatazones; /* total number of data zones */
59 u32 s_nzones; /* same as s_sbd->s_fsize */
60 u16 s_namelen; /* max length of dir entry */
61 int s_forced_ro;
62};
63
64/*
65 * SystemV/V7/Coherent FS inode data in memory
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/* identify the FS in memory */
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/* Admissible values for i_nlink: 0.._LINK_MAX */
106enum {
107 XENIX_LINK_MAX = 126, /* ?? */
108 SYSV_LINK_MAX = 126, /* 127? 251? */
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 sb->s_dirt = 1;
122}
123
124
125/* ialloc.c */
126extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned,
127 struct buffer_head **);
128extern struct inode * sysv_new_inode(const struct inode *, mode_t);
129extern void sysv_free_inode(struct inode *);
130extern unsigned long sysv_count_free_inodes(struct super_block *);
131
132/* balloc.c */
133extern sysv_zone_t sysv_new_block(struct super_block *);
134extern void sysv_free_block(struct super_block *, sysv_zone_t);
135extern unsigned long sysv_count_free_blocks(struct super_block *);
136
137/* itree.c */
138extern void sysv_truncate(struct inode *);
139
140/* inode.c */
141extern int sysv_write_inode(struct inode *, int);
142extern int sysv_sync_inode(struct inode *);
143extern int sysv_sync_file(struct file *, struct dentry *, int);
144extern void sysv_set_inode(struct inode *, dev_t);
145extern int sysv_getattr(struct vfsmount *, struct dentry *, struct kstat *);
146
147/* dir.c */
148extern struct sysv_dir_entry *sysv_find_entry(struct dentry *, struct page **);
149extern int sysv_add_link(struct dentry *, struct inode *);
150extern int sysv_delete_entry(struct sysv_dir_entry *, struct page *);
151extern int sysv_make_empty(struct inode *, struct inode *);
152extern int sysv_empty_dir(struct inode *);
153extern void sysv_set_link(struct sysv_dir_entry *, struct page *,
154 struct inode *);
155extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
156extern ino_t sysv_inode_by_name(struct dentry *);
157
158
159extern struct inode_operations sysv_file_inode_operations;
160extern struct inode_operations sysv_dir_inode_operations;
161extern struct inode_operations sysv_fast_symlink_inode_operations;
162extern struct file_operations sysv_file_operations;
163extern struct file_operations sysv_dir_operations;
164extern struct address_space_operations sysv_aops;
165extern struct super_operations sysv_sops;
166extern struct dentry_operations sysv_dentry_operations;
167
168
169enum {
170 BYTESEX_LE,
171 BYTESEX_PDP,
172 BYTESEX_BE,
173};
174
175static inline u32 PDP_swab(u32 x)
176{
177#ifdef __LITTLE_ENDIAN
178 return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
179#else
180#ifdef __BIG_ENDIAN
181 return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
182#else
183#error BYTESEX
184#endif
185#endif
186}
187
188static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
189{
190 if (sbi->s_bytesex == BYTESEX_PDP)
191 return PDP_swab((__force __u32)n);
192 else if (sbi->s_bytesex == BYTESEX_LE)
193 return le32_to_cpu((__force __le32)n);
194 else
195 return be32_to_cpu((__force __be32)n);
196}
197
198static inline __fs32 cpu_to_fs32(struct sysv_sb_info *sbi, __u32 n)
199{
200 if (sbi->s_bytesex == BYTESEX_PDP)
201 return (__force __fs32)PDP_swab(n);
202 else if (sbi->s_bytesex == BYTESEX_LE)
203 return (__force __fs32)cpu_to_le32(n);
204 else
205 return (__force __fs32)cpu_to_be32(n);
206}
207
208static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
209{
210 if (sbi->s_bytesex == BYTESEX_PDP)
211 *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
212 else if (sbi->s_bytesex == BYTESEX_LE)
213 *(__le32*)n = cpu_to_le32(le32_to_cpu(*(__le32*)n)+d);
214 else
215 *(__be32*)n = cpu_to_be32(be32_to_cpu(*(__be32*)n)+d);
216 return *n;
217}
218
219static inline __u16 fs16_to_cpu(struct sysv_sb_info *sbi, __fs16 n)
220{
221 if (sbi->s_bytesex != BYTESEX_BE)
222 return le16_to_cpu((__force __le16)n);
223 else
224 return be16_to_cpu((__force __be16)n);
225}
226
227static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
228{
229 if (sbi->s_bytesex != BYTESEX_BE)
230 return (__force __fs16)cpu_to_le16(n);
231 else
232 return (__force __fs16)cpu_to_be16(n);
233}
234
235static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
236{
237 if (sbi->s_bytesex != BYTESEX_BE)
238 *(__le16*)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)+d);
239 else
240 *(__be16*)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)+d);
241 return *n;
242}
243
244#endif /* _SYSV_H */