~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/linux/sysv_fs.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _LINUX_SYSV_FS_H
  2 #define _LINUX_SYSV_FS_H
  3 
  4 /*
  5  * The SystemV/Coherent filesystem constants/structures/macros
  6  */
  7 
  8 
  9 /* This code assumes
 10    - a little endian processor like 386,
 11    - sizeof(short) = 2, sizeof(int) = 4, sizeof(long) = 4,
 12    - alignof(short) = 2, alignof(long) = 4.
 13 */
 14 
 15 #ifdef __GNUC__
 16 #define __packed2__  __attribute__ ((packed, aligned(2)))
 17 #else
 18 #error I want gcc!
 19 #endif
 20 
 21 #include <linux/stat.h>         /* declares S_IFLNK etc. */
 22 #include <linux/sched.h>        /* declares wake_up() */
 23 #include <linux/sysv_fs_sb.h>   /* defines the sv_... shortcuts */
 24 
 25 
 26 /* Layout on disk */
 27 /* ============== */
 28 
 29 
 30 /* The block size is sb->sv_block_size which may be smaller than BLOCK_SIZE. */
 31 
 32 /* zones (= data allocation units) are blocks */
 33 
 34 /* On Coherent FS, 32 bit quantities are stored using (I quote the Coherent
 35    manual) a "canonical byte ordering". This is the PDP-11 byte ordering:
 36    x = 2^24 * byte3 + 2^16 * byte2 + 2^8 * byte1 + byte0 is stored
 37    as { byte2, byte3, byte0, byte1 }. We need conversions.
 38 */
 39 
 40 typedef u32 coh_ulong;
 41 
 42 static inline coh_ulong to_coh_ulong (u32 x)
 43 {
 44         return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
 45 }
 46 
 47 static inline u32 from_coh_ulong (coh_ulong x)
 48 {
 49         return ((x & 0xffff) << 16) | ((x & 0xffff0000) >> 16);
 50 }
 51 
 52 /* inode numbers are 16 bit */
 53 
 54 typedef u16 sysv_ino_t;
 55 
 56 /* Block numbers are 24 bit, sometimes stored in 32 bit.
 57    On Coherent FS, they are always stored in PDP-11 manner: the least
 58    significant 16 bits come last.
 59 */
 60 
 61 typedef u32 sysv_zone_t;
 62 
 63 /* Among the blocks ... */
 64 /* Xenix FS, Coherent FS: block 0 is the boot block, block 1 the super-block.
 65    SystemV FS: block 0 contains both the boot sector and the super-block. */
 66 /* The first inode zone is sb->sv_firstinodezone (1 or 2). */
 67 
 68 /* Among the inodes ... */
 69 /* 0 is non-existent */
 70 #define SYSV_BADBL_INO  1       /* inode of bad blocks file */
 71 #define SYSV_ROOT_INO   2       /* inode of root directory */
 72 
 73 
 74 /* Xenix super-block data on disk */
 75 #define XENIX_NICINOD   100     /* number of inode cache entries */
 76 #define XENIX_NICFREE   100     /* number of free block list chunk entries */
 77 struct xenix_super_block {
 78         u16             s_isize; /* index of first data zone */
 79         u32             s_fsize __packed2__; /* total number of zones of this fs */
 80         /* the start of the free block list: */
 81         u16             s_nfree;        /* number of free blocks in s_free, <= XENIX_NICFREE */
 82         u32             s_free[XENIX_NICFREE]; /* first free block list chunk */
 83         /* the cache of free inodes: */
 84         u16             s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
 85         sysv_ino_t      s_inode[XENIX_NICINOD]; /* some free inodes */
 86         /* locks, not used by Linux: */
 87         char            s_flock;        /* lock during free block list manipulation */
 88         char            s_ilock;        /* lock during inode cache manipulation */
 89         char            s_fmod;         /* super-block modified flag */
 90         char            s_ronly;        /* flag whether fs is mounted read-only */
 91         u32             s_time __packed2__; /* time of last super block update */
 92         u32             s_tfree __packed2__; /* total number of free zones */
 93         u16             s_tinode;       /* total number of free inodes */
 94         s16             s_dinfo[4];     /* device information ?? */
 95         char            s_fname[6];     /* file system volume name */
 96         char            s_fpack[6];     /* file system pack name */
 97         char            s_clean;        /* set to 0x46 when filesystem is properly unmounted */
 98         char            s_fill[371];
 99         s32             s_magic;        /* version of file system */
100         s32             s_type;         /* type of file system: 1 for 512 byte blocks
101                                                                 2 for 1024 byte blocks
102                                                                 3 for 2048 byte blocks */
103                                                                 
104 };
105 
106 /* Xenix free list block on disk */
107 struct xenix_freelist_chunk {
108         u16     fl_nfree;       /* number of free blocks in fl_free, <= XENIX_NICFREE] */
109         u32     fl_free[XENIX_NICFREE] __packed2__;
110 };
111 
112 /* SystemV FS comes in two variants:
113  * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
114  * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
115  */
116 #define SYSV_NICINOD    100     /* number of inode cache entries */
117 #define SYSV_NICFREE    50      /* number of free block list chunk entries */
118 
119 /* SystemV4 super-block data on disk */
120 struct sysv4_super_block {
121         u16     s_isize;        /* index of first data zone */
122         u16     s_pad0;
123         u32     s_fsize;        /* total number of zones of this fs */
124         /* the start of the free block list: */
125         u16     s_nfree;        /* number of free blocks in s_free, <= SYSV_NICFREE */
126         u16     s_pad1;
127         u32     s_free[SYSV_NICFREE]; /* first free block list chunk */
128         /* the cache of free inodes: */
129         u16     s_ninode;       /* number of free inodes in s_inode, <= SYSV_NICINOD */
130         u16     s_pad2;
131         sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
132         /* locks, not used by Linux: */
133         char    s_flock;        /* lock during free block list manipulation */
134         char    s_ilock;        /* lock during inode cache manipulation */
135         char    s_fmod;         /* super-block modified flag */
136         char    s_ronly;        /* flag whether fs is mounted read-only */
137         u32     s_time;         /* time of last super block update */
138         s16     s_dinfo[4];     /* device information ?? */
139         u32     s_tfree;        /* total number of free zones */
140         u16     s_tinode;       /* total number of free inodes */
141         u16     s_pad3;
142         char    s_fname[6];     /* file system volume name */
143         char    s_fpack[6];     /* file system pack name */
144         s32     s_fill[12];
145         s32     s_state;        /* file system state: 0x7c269d38-s_time means clean */
146         s32     s_magic;        /* version of file system */
147         s32     s_type;         /* type of file system: 1 for 512 byte blocks
148                                                                 2 for 1024 byte blocks */
149 };
150 
151 /* SystemV4 free list block on disk */
152 struct sysv4_freelist_chunk {
153         u16 fl_nfree;   /* number of free blocks in fl_free, <= SYSV_NICFREE] */
154         u32  fl_free[SYSV_NICFREE];
155 };
156 
157 /* SystemV2 super-block data on disk */
158 struct sysv2_super_block {
159         u16     s_isize;                /* index of first data zone */
160         u32     s_fsize __packed2__;    /* total number of zones of this fs */
161         /* the start of the free block list: */
162         u16     s_nfree;                /* number of free blocks in s_free, <= SYSV_NICFREE */
163         u32     s_free[SYSV_NICFREE];   /* first free block list chunk */
164         /* the cache of free inodes: */
165         u16     s_ninode;               /* number of free inodes in s_inode, <= SYSV_NICINOD */
166         sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
167         /* locks, not used by Linux: */
168         char    s_flock;                /* lock during free block list manipulation */
169         char    s_ilock;                /* lock during inode cache manipulation */
170         char    s_fmod;                 /* super-block modified flag */
171         char    s_ronly;                /* flag whether fs is mounted read-only */
172         u32     s_time __packed2__;     /* time of last super block update */
173         s16     s_dinfo[4];             /* device information ?? */
174         u32     s_tfree __packed2__;    /* total number of free zones */
175         u16     s_tinode;               /* total number of free inodes */
176         char    s_fname[6];             /* file system volume name */
177         char    s_fpack[6];             /* file system pack name */
178         s32     s_fill[14];
179         s32     s_state;                /* file system state: 0xcb096f43 means clean */
180         s32     s_magic;                /* version of file system */
181         s32     s_type;                 /* type of file system: 1 for 512 byte blocks
182                                                                 2 for 1024 byte blocks */
183 };
184 
185 /* SystemV2 free list block on disk */
186 struct sysv2_freelist_chunk {
187         u16     fl_nfree;       /* number of free blocks in fl_free, <= SYSV_NICFREE] */
188         u32     fl_free[SYSV_NICFREE] __packed2__;
189 };
190 
191 /* Coherent super-block data on disk */
192 #define COH_NICINOD     100     /* number of inode cache entries */
193 #define COH_NICFREE     64      /* number of free block list chunk entries */
194 struct coh_super_block {
195         u16             s_isize;        /* index of first data zone */
196         coh_ulong       s_fsize __packed2__; /* total number of zones of this fs */
197         /* the start of the free block list: */
198         u16 s_nfree;    /* number of free blocks in s_free, <= COH_NICFREE */
199         coh_ulong       s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
200         /* the cache of free inodes: */
201         u16             s_ninode;       /* number of free inodes in s_inode, <= COH_NICINOD */
202         sysv_ino_t      s_inode[COH_NICINOD]; /* some free inodes */
203         /* locks, not used by Linux: */
204         char            s_flock;        /* lock during free block list manipulation */
205         char            s_ilock;        /* lock during inode cache manipulation */
206         char            s_fmod;         /* super-block modified flag */
207         char            s_ronly;        /* flag whether fs is mounted read-only */
208         coh_ulong       s_time __packed2__; /* time of last super block update */
209         coh_ulong       s_tfree __packed2__; /* total number of free zones */
210         u16             s_tinode;       /* total number of free inodes */
211         u16             s_interleave_m; /* interleave factor */
212         u16             s_interleave_n;
213         char            s_fname[6];     /* file system volume name */
214         char            s_fpack[6];     /* file system pack name */
215         u32             s_unique;       /* zero, not used */
216 };
217 
218 /* Coherent free list block on disk */
219 struct coh_freelist_chunk {
220         u16 fl_nfree;   /* number of free blocks in fl_free, <= COH_NICFREE] */
221         u32  fl_free[COH_NICFREE] __packed2__;
222 };
223 
224 
225 /* SystemV/Coherent inode data on disk */
226 
227 struct sysv_inode {
228         u16 i_mode;
229         u16 i_nlink;
230         u16 i_uid;
231         u16 i_gid;
232         u32 i_size;
233         union { /* directories, regular files, ... */
234                 unsigned char i_addb[3*(10+1+1+1)+1]; /* zone numbers: max. 10 data blocks,
235                                               * then 1 indirection block,
236                                               * then 1 double indirection block,
237                                               * then 1 triple indirection block.
238                                               * Then maybe a "file generation number" ??
239                                               */
240                 /* devices */
241                 dev_t i_rdev;
242                 /* named pipes on Coherent */
243                 struct {
244                         char p_addp[30];
245                         s16 p_pnc;
246                         s16 p_prx;
247                         s16 p_pwx;
248                 } i_p;
249         } i_a;
250         u32 i_atime;    /* time of last access */
251         u32 i_mtime;    /* time of last modification */
252         u32 i_ctime;    /* time of creation */
253 };
254 
255 /* The admissible values for i_mode are listed in <linux/stat.h> :
256  * #define S_IFMT  00170000  mask for type
257  * #define S_IFREG  0100000  type = regular file
258  * #define S_IFBLK  0060000  type = block device
259  * #define S_IFDIR  0040000  type = directory
260  * #define S_IFCHR  0020000  type = character device
261  * #define S_IFIFO  0010000  type = named pipe
262  * #define S_ISUID  0004000  set user id
263  * #define S_ISGID  0002000  set group id
264  * #define S_ISVTX  0001000  save swapped text even after use
265  * Additionally for SystemV:
266  * #define S_IFLNK  0120000  type = symbolic link
267  * #define S_IFNAM  0050000  type = XENIX special named file ??
268  * Additionally for Coherent:
269  * #define S_IFMPB  0070000  type = multiplexed block device ??
270  * #define S_IFMPC  0030000  type = multiplexed character device ??
271  *
272  * Since Coherent doesn't know about symbolic links, we use a kludgey
273  * implementation of symbolic links: i_mode = COH_KLUDGE_SYMLINK_MODE
274  * denotes a symbolic link. When a regular file should get this mode by
275  * accident, it is automatically converted to COH_KLUDGE_NOT_SYMLINK.
276  * We use S_IFREG because only regular files (and Coherent pipes...) can have
277  * data blocks with arbitrary contents associated with them, and S_ISVTX
278  * ("save swapped text after use") because it is unused on both Linux and
279  * Coherent: Linux does much more intelligent paging, and Coherent hasn't
280  * virtual memory at all.
281  * Same trick for Xenix.
282  */
283 #define COH_KLUDGE_SYMLINK_MODE (S_IFREG | S_ISVTX)
284 #define COH_KLUDGE_NOT_SYMLINK  (S_IFREG | S_ISVTX | S_IRUSR) /* force read access */
285 extern inline mode_t from_coh_imode(unsigned short mode)
286 {
287         if (mode == COH_KLUDGE_SYMLINK_MODE)
288                 return (S_IFLNK | 0777);
289         else
290                 return mode;
291 }
292 extern inline unsigned short to_coh_imode(mode_t mode)
293 {
294         if (S_ISLNK(mode))
295                 return COH_KLUDGE_SYMLINK_MODE;
296         else if (mode == COH_KLUDGE_SYMLINK_MODE)
297                 return COH_KLUDGE_NOT_SYMLINK;
298         else
299                 return mode;
300 }
301 
302 /* Admissible values for i_nlink: 0.._LINK_MAX */
303 #define XENIX_LINK_MAX  126     /* ?? */
304 #define SYSV_LINK_MAX   126     /* 127? 251? */
305 #define COH_LINK_MAX    10000   /* max number of hard links to an inode */
306 
307 /* The number of inodes per block is
308    sb->sv_inodes_per_block = block_size / sizeof(struct sysv_inode) */
309 /* The number of indirect pointers per block is
310    sb->sv_ind_per_block = block_size / sizeof(u32) */
311 
312 
313 /* SystemV/Coherent directory entry on disk */
314 
315 #define SYSV_NAMELEN    14      /* max size of name in struct sysv_dir_entry */
316 
317 struct sysv_dir_entry {
318         sysv_ino_t inode;
319         char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
320 };
321 
322 #define SYSV_DIRSIZE    sizeof(struct sysv_dir_entry)   /* size of every directory entry */
323 
324 
325 /* Operations */
326 /* ========== */
327 
328 
329 /* identify the FS in memory */
330 #define FSTYPE_XENIX    1
331 #define FSTYPE_SYSV4    2
332 #define FSTYPE_SYSV2    3
333 #define FSTYPE_COH      4
334 
335 #define SYSV_MAGIC_BASE         0x012FF7B3
336 
337 #define XENIX_SUPER_MAGIC       (SYSV_MAGIC_BASE+FSTYPE_XENIX)
338 #define SYSV4_SUPER_MAGIC       (SYSV_MAGIC_BASE+FSTYPE_SYSV4)
339 #define SYSV2_SUPER_MAGIC       (SYSV_MAGIC_BASE+FSTYPE_SYSV2)
340 #define COH_SUPER_MAGIC         (SYSV_MAGIC_BASE+FSTYPE_COH)
341 
342 #ifdef __KERNEL__
343 
344 /* sv_get_hash_table(sb,dev,block) is equivalent to  get_hash_table(dev,block,block_size)  */
345 static inline struct buffer_head *
346 sv_get_hash_table (struct super_block *sb, kdev_t dev, unsigned int block)
347 {
348         return get_hash_table (dev, block + sb->sv_block_base, sb->sv_block_size);
349 }
350 
351 /* sv_getblk(sb,dev,block) is equivalent to  getblk(dev,block,block_size)  */
352 static inline struct buffer_head *
353 sv_getblk (struct super_block *sb, kdev_t dev, unsigned int block)
354 {
355         return getblk (dev, block + sb->sv_block_base, sb->sv_block_size);
356 }
357 
358 /* sv_bread(sb,dev,block) is equivalent to  bread(dev,block,block_size)  */
359 static inline struct buffer_head *
360 sv_bread (struct super_block *sb, kdev_t dev, unsigned int block)
361 {
362         return bread (dev, block + sb->sv_block_base, sb->sv_block_size);
363 }
364 
365 
366 /*
367  * Function prototypes
368  */
369 
370 extern struct inode * sysv_new_inode(const struct inode * dir);
371 extern void sysv_free_inode(struct inode * inode);
372 extern unsigned long sysv_count_free_inodes(struct super_block *sb);
373 extern int sysv_new_block(struct super_block * sb);
374 extern void sysv_free_block(struct super_block * sb, unsigned int block);
375 extern unsigned long sysv_count_free_blocks(struct super_block *sb);
376 
377 extern struct buffer_head * sysv_file_bread(struct inode *, int, int);
378 
379 extern void sysv_truncate(struct inode *);
380 extern void sysv_write_inode(struct inode *, int);
381 extern int sysv_sync_inode(struct inode *);
382 extern int sysv_sync_file(struct file *, struct dentry *, int);
383 extern int sysv_notify_change(struct dentry *, struct iattr *);
384 
385 extern struct inode_operations sysv_file_inode_operations;
386 extern struct inode_operations sysv_symlink_inode_operations;
387 extern struct inode_operations sysv_dir_inode_operations;
388 extern struct file_operations sysv_file_operations;
389 extern struct file_operations sysv_dir_operations;
390 extern struct address_space_operations sysv_aops;
391 
392 #endif /* __KERNEL__ */
393 
394 #endif
395 
396 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.