1 #ifndef _LINUX_SYSV_FS_H
2 #define _LINUX_SYSV_FS_H
5 * The SystemV/Coherent filesystem constants/structures/macros
10 - sizeof(short) = 2, sizeof(int) = 4, sizeof(long) = 4,
11 - alignof(short) = 2, alignof(long) = 4.
15 #define __packed2__ __attribute__ ((packed, aligned(2)))
20 #include <linux/stat.h> /* declares S_IFLNK etc. */
21 #include <linux/sched.h> /* declares wake_up() */
22 #include <linux/sysv_fs_sb.h> /* defines the sv_... shortcuts */
28 static inline u32 PDP_swab(u32 x)
30 #ifdef __LITTLE_ENDIAN
31 return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
34 return ((x & 0xff00ff) << 8) | ((x & 0xff00ff00) >> 8);
41 /* inode numbers are 16 bit */
43 typedef u16 sysv_ino_t;
45 /* Block numbers are 24 bit, sometimes stored in 32 bit.
46 On Coherent FS, they are always stored in PDP-11 manner: the least
47 significant 16 bits come last.
50 typedef u32 sysv_zone_t;
52 /* Among the blocks ... */
53 /* Xenix FS, Coherent FS: block 0 is the boot block, block 1 the super-block.
54 SystemV FS: block 0 contains both the boot sector and the super-block. */
55 /* The first inode zone is sb->sv_firstinodezone (1 or 2). */
57 /* Among the inodes ... */
58 /* 0 is non-existent */
59 #define SYSV_BADBL_INO 1 /* inode of bad blocks file */
60 #define SYSV_ROOT_INO 2 /* inode of root directory */
63 /* Xenix super-block data on disk */
64 #define XENIX_NICINOD 100 /* number of inode cache entries */
65 #define XENIX_NICFREE 100 /* number of free block list chunk entries */
66 struct xenix_super_block {
67 u16 s_isize; /* index of first data zone */
68 u32 s_fsize __packed2__; /* total number of zones of this fs */
69 /* the start of the free block list: */
70 u16 s_nfree; /* number of free blocks in s_free, <= XENIX_NICFREE */
71 u32 s_free[XENIX_NICFREE]; /* first free block list chunk */
72 /* the cache of free inodes: */
73 u16 s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
74 sysv_ino_t s_inode[XENIX_NICINOD]; /* some free inodes */
75 /* locks, not used by Linux: */
76 char s_flock; /* lock during free block list manipulation */
77 char s_ilock; /* lock during inode cache manipulation */
78 char s_fmod; /* super-block modified flag */
79 char s_ronly; /* flag whether fs is mounted read-only */
80 u32 s_time __packed2__; /* time of last super block update */
81 u32 s_tfree __packed2__; /* total number of free zones */
82 u16 s_tinode; /* total number of free inodes */
83 s16 s_dinfo[4]; /* device information ?? */
84 char s_fname[6]; /* file system volume name */
85 char s_fpack[6]; /* file system pack name */
86 char s_clean; /* set to 0x46 when filesystem is properly unmounted */
88 s32 s_magic; /* version of file system */
89 s32 s_type; /* type of file system: 1 for 512 byte blocks
90 2 for 1024 byte blocks
91 3 for 2048 byte blocks */
95 /* SystemV FS comes in two variants:
96 * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
97 * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
99 #define SYSV_NICINOD 100 /* number of inode cache entries */
100 #define SYSV_NICFREE 50 /* number of free block list chunk entries */
102 /* SystemV4 super-block data on disk */
103 struct sysv4_super_block {
104 u16 s_isize; /* index of first data zone */
106 u32 s_fsize; /* total number of zones of this fs */
107 /* the start of the free block list: */
108 u16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
110 u32 s_free[SYSV_NICFREE]; /* first free block list chunk */
111 /* the cache of free inodes: */
112 u16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
114 sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
115 /* locks, not used by Linux: */
116 char s_flock; /* lock during free block list manipulation */
117 char s_ilock; /* lock during inode cache manipulation */
118 char s_fmod; /* super-block modified flag */
119 char s_ronly; /* flag whether fs is mounted read-only */
120 u32 s_time; /* time of last super block update */
121 s16 s_dinfo[4]; /* device information ?? */
122 u32 s_tfree; /* total number of free zones */
123 u16 s_tinode; /* total number of free inodes */
125 char s_fname[6]; /* file system volume name */
126 char s_fpack[6]; /* file system pack name */
128 s32 s_state; /* file system state: 0x7c269d38-s_time means clean */
129 s32 s_magic; /* version of file system */
130 s32 s_type; /* type of file system: 1 for 512 byte blocks
131 2 for 1024 byte blocks */
134 /* SystemV2 super-block data on disk */
135 struct sysv2_super_block {
136 u16 s_isize; /* index of first data zone */
137 u32 s_fsize __packed2__; /* total number of zones of this fs */
138 /* the start of the free block list: */
139 u16 s_nfree; /* number of free blocks in s_free, <= SYSV_NICFREE */
140 u32 s_free[SYSV_NICFREE]; /* first free block list chunk */
141 /* the cache of free inodes: */
142 u16 s_ninode; /* number of free inodes in s_inode, <= SYSV_NICINOD */
143 sysv_ino_t s_inode[SYSV_NICINOD]; /* some free inodes */
144 /* locks, not used by Linux: */
145 char s_flock; /* lock during free block list manipulation */
146 char s_ilock; /* lock during inode cache manipulation */
147 char s_fmod; /* super-block modified flag */
148 char s_ronly; /* flag whether fs is mounted read-only */
149 u32 s_time __packed2__; /* time of last super block update */
150 s16 s_dinfo[4]; /* device information ?? */
151 u32 s_tfree __packed2__; /* total number of free zones */
152 u16 s_tinode; /* total number of free inodes */
153 char s_fname[6]; /* file system volume name */
154 char s_fpack[6]; /* file system pack name */
156 s32 s_state; /* file system state: 0xcb096f43 means clean */
157 s32 s_magic; /* version of file system */
158 s32 s_type; /* type of file system: 1 for 512 byte blocks
159 2 for 1024 byte blocks */
162 /* V7 super-block data on disk */
163 #define V7_NICINOD 100 /* number of inode cache entries */
164 #define V7_NICFREE 50 /* number of free block list chunk entries */
165 struct v7_super_block {
166 u16 s_isize; /* index of first data zone */
167 u32 s_fsize __packed2__; /* total number of zones of this fs */
168 /* the start of the free block list: */
169 u16 s_nfree; /* number of free blocks in s_free, <= V7_NICFREE */
170 u32 s_free[V7_NICFREE]; /* first free block list chunk */
171 /* the cache of free inodes: */
172 u16 s_ninode; /* number of free inodes in s_inode, <= V7_NICINOD */
173 sysv_ino_t s_inode[V7_NICINOD]; /* some free inodes */
174 /* locks, not used by Linux or V7: */
175 char s_flock; /* lock during free block list manipulation */
176 char s_ilock; /* lock during inode cache manipulation */
177 char s_fmod; /* super-block modified flag */
178 char s_ronly; /* flag whether fs is mounted read-only */
179 u32 s_time __packed2__; /* time of last super block update */
180 /* the following fields are not maintained by V7: */
181 u32 s_tfree __packed2__; /* total number of free zones */
182 u16 s_tinode; /* total number of free inodes */
183 u16 s_m; /* interleave factor */
184 u16 s_n; /* interleave factor */
185 char s_fname[6]; /* file system name */
186 char s_fpack[6]; /* file system pack name */
189 /* Coherent super-block data on disk */
190 #define COH_NICINOD 100 /* number of inode cache entries */
191 #define COH_NICFREE 64 /* number of free block list chunk entries */
192 struct coh_super_block {
193 u16 s_isize; /* index of first data zone */
194 u32 s_fsize __packed2__; /* total number of zones of this fs */
195 /* the start of the free block list: */
196 u16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
197 u32 s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
198 /* the cache of free inodes: */
199 u16 s_ninode; /* number of free inodes in s_inode, <= COH_NICINOD */
200 sysv_ino_t s_inode[COH_NICINOD]; /* some free inodes */
201 /* locks, not used by Linux: */
202 char s_flock; /* lock during free block list manipulation */
203 char s_ilock; /* lock during inode cache manipulation */
204 char s_fmod; /* super-block modified flag */
205 char s_ronly; /* flag whether fs is mounted read-only */
206 u32 s_time __packed2__; /* time of last super block update */
207 u32 s_tfree __packed2__; /* total number of free zones */
208 u16 s_tinode; /* total number of free inodes */
209 u16 s_interleave_m; /* interleave factor */
211 char s_fname[6]; /* file system volume name */
212 char s_fpack[6]; /* file system pack name */
213 u32 s_unique; /* zero, not used */
216 /* SystemV/Coherent inode data on disk */
224 union { /* directories, regular files, ... */
225 unsigned char i_addb[3*(10+1+1+1)+1]; /* zone numbers: max. 10 data blocks,
226 * then 1 indirection block,
227 * then 1 double indirection block,
228 * then 1 triple indirection block.
229 * Then maybe a "file generation number" ??
231 /* named pipes on Coherent */
239 u32 i_atime; /* time of last access */
240 u32 i_mtime; /* time of last modification */
241 u32 i_ctime; /* time of creation */
244 /* Admissible values for i_nlink: 0.._LINK_MAX */
246 XENIX_LINK_MAX = 126, /* ?? */
247 SYSV_LINK_MAX = 126, /* 127? 251? */
248 V7_LINK_MAX = 126, /* ?? */
249 COH_LINK_MAX = 10000,
252 /* The number of inodes per block is
253 sb->sv_inodes_per_block = block_size / sizeof(struct sysv_inode) */
254 /* The number of indirect pointers per block is
255 sb->sv_ind_per_block = block_size / sizeof(u32) */
258 /* SystemV/Coherent directory entry on disk */
260 #define SYSV_NAMELEN 14 /* max size of name in struct sysv_dir_entry */
262 struct sysv_dir_entry {
264 char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
267 #define SYSV_DIRSIZE sizeof(struct sysv_dir_entry) /* size of every directory entry */
273 /* identify the FS in memory */
285 #define SYSV_MAGIC_BASE 0x012FF7B3
287 #define XENIX_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_XENIX)
288 #define SYSV4_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
289 #define SYSV2_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
290 #define COH_SUPER_MAGIC (SYSV_MAGIC_BASE+FSTYPE_COH)
301 * Function prototypes
304 extern struct inode * sysv_new_inode(const struct inode *, mode_t);
305 extern void sysv_free_inode(struct inode *);
306 extern unsigned long sysv_count_free_inodes(struct super_block *);
307 extern u32 sysv_new_block(struct super_block *);
308 extern void sysv_free_block(struct super_block *, u32);
309 extern unsigned long sysv_count_free_blocks(struct super_block *);
311 extern void sysv_truncate(struct inode *);
313 extern void sysv_write_inode(struct inode *, int);
314 extern int sysv_sync_inode(struct inode *);
315 extern int sysv_sync_file(struct file *, struct dentry *, int);
316 extern void sysv_set_inode(struct inode *, dev_t);
318 extern struct sysv_dir_entry *sysv_find_entry(struct dentry*, struct page**);
319 extern int sysv_add_link(struct dentry*, struct inode*);
320 extern int sysv_delete_entry(struct sysv_dir_entry*, struct page*);
321 extern int sysv_make_empty(struct inode*, struct inode*);
322 extern int sysv_empty_dir(struct inode*);
323 extern void sysv_set_link(struct sysv_dir_entry*, struct page*, struct inode*);
324 extern struct sysv_dir_entry *sysv_dotdot(struct inode*, struct page**);
325 extern ino_t sysv_inode_by_name(struct dentry*);
327 extern struct inode_operations sysv_file_inode_operations;
328 extern struct inode_operations sysv_dir_inode_operations;
329 extern struct inode_operations sysv_fast_symlink_inode_operations;
330 extern struct file_operations sysv_file_operations;
331 extern struct file_operations sysv_dir_operations;
332 extern struct address_space_operations sysv_aops;
333 extern struct super_operations sysv_sops;
334 extern struct dentry_operations sysv_dentry_operations;
336 extern struct sysv_inode *sysv_raw_inode(struct super_block *, unsigned, struct buffer_head **);
338 static inline void dirty_sb(struct super_block *sb)
340 mark_buffer_dirty(sb->sv_bh1);
341 if (sb->sv_bh1 != sb->sv_bh2)
342 mark_buffer_dirty(sb->sv_bh2);
346 static inline u32 fs32_to_cpu(struct super_block *sb, u32 n)
348 if (sb->sv_bytesex == BYTESEX_PDP)
350 else if (sb->sv_bytesex == BYTESEX_LE)
351 return le32_to_cpu(n);
353 return be32_to_cpu(n);
356 static inline u32 cpu_to_fs32(struct super_block *sb, u32 n)
358 if (sb->sv_bytesex == BYTESEX_PDP)
360 else if (sb->sv_bytesex == BYTESEX_LE)
361 return cpu_to_le32(n);
363 return cpu_to_be32(n);
366 static inline u32 fs32_add(struct super_block *sb, u32 *n, int d)
368 if (sb->sv_bytesex == BYTESEX_PDP)
369 return *n = PDP_swab(PDP_swab(*n)+d);
370 else if (sb->sv_bytesex == BYTESEX_LE)
371 return *n = cpu_to_le32(le32_to_cpu(*n)+d);
373 return *n = cpu_to_be32(be32_to_cpu(*n)+d);
376 static inline u16 fs16_to_cpu(struct super_block *sb, u16 n)
378 if (sb->sv_bytesex != BYTESEX_BE)
379 return le16_to_cpu(n);
381 return be16_to_cpu(n);
384 static inline u16 cpu_to_fs16(struct super_block *sb, u16 n)
386 if (sb->sv_bytesex != BYTESEX_BE)
387 return cpu_to_le16(n);
389 return cpu_to_be16(n);
392 static inline u16 fs16_add(struct super_block *sb, u16 *n, int d)
394 if (sb->sv_bytesex != BYTESEX_BE)
395 return *n = cpu_to_le16(le16_to_cpu(*n)+d);
397 return *n = cpu_to_be16(be16_to_cpu(*n)+d);
400 #endif /* __KERNEL__ */