linux/include/linux/sysv_fs.h
<<
>>
Prefs
   1#ifndef _LINUX_SYSV_FS_H
   2#define _LINUX_SYSV_FS_H
   3
   4#define __packed2__     __attribute__((packed, aligned(2)))
   5
   6
   7#ifndef __KERNEL__
   8typedef u16 __fs16;
   9typedef u32 __fs16;
  10#endif
  11
  12/* inode numbers are 16 bit */
  13typedef __fs16 sysv_ino_t;
  14
  15/* Block numbers are 24 bit, sometimes stored in 32 bit.
  16   On Coherent FS, they are always stored in PDP-11 manner: the least
  17   significant 16 bits come last. */
  18typedef __fs32 sysv_zone_t;
  19
  20/* 0 is non-existent */
  21#define SYSV_BADBL_INO  1       /* inode of bad blocks file */
  22#define SYSV_ROOT_INO   2       /* inode of root directory */
  23
  24
  25/* Xenix super-block data on disk */
  26#define XENIX_NICINOD   100     /* number of inode cache entries */
  27#define XENIX_NICFREE   100     /* number of free block list chunk entries */
  28struct xenix_super_block {
  29        __fs16          s_isize; /* index of first data zone */
  30        __fs32          s_fsize __packed2__; /* total number of zones of this fs */
  31        /* the start of the free block list: */
  32        __fs16          s_nfree;        /* number of free blocks in s_free, <= XENIX_NICFREE */
  33        sysv_zone_t     s_free[XENIX_NICFREE]; /* first free block list chunk */
  34        /* the cache of free inodes: */
  35        __fs16          s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
  36        sysv_ino_t      s_inode[XENIX_NICINOD]; /* some free inodes */
  37        /* locks, not used by Linux: */
  38        char            s_flock;        /* lock during free block list manipulation */
  39        char            s_ilock;        /* lock during inode cache manipulation */
  40        char            s_fmod;         /* super-block modified flag */
  41        char            s_ronly;        /* flag whether fs is mounted read-only */
  42        __fs32          s_time __packed2__; /* time of last super block update */
  43        __fs32          s_tfree __packed2__; /* total number of free zones */
  44        __fs16          s_tinode;       /* total number of free inodes */
  45        __fs16          s_dinfo[4];     /* device information ?? */
  46        char            s_fname[6];     /* file system volume name */
  47        char            s_fpack[6];     /* file system pack name */
  48        char            s_clean;        /* set to 0x46 when filesystem is properly unmounted */
  49        char            s_fill[371];
  50        s32             s_magic;        /* version of file system */
  51        __fs32          s_type;         /* type of file system: 1 for 512 byte blocks
  52                                                                2 for 1024 byte blocks
  53                                                                3 for 2048 byte blocks */
  54                                                                
  55};
  56
  57/*
  58 * SystemV FS comes in two variants:
  59 * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
  60 * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
  61 */
  62#define SYSV_NICINOD    100     /* number of inode cache entries */
  63#define SYSV_NICFREE    50      /* number of free block list chunk entries */
  64
  65/* SystemV4 super-block data on disk */
  66struct sysv4_super_block {
  67        __fs16  s_isize;        /* index of first data zone */
  68        u16     s_pad0;
  69        __fs32  s_fsize;        /* total number of zones of this fs */
  70        /* the start of the free block list: */
  71        __fs16  s_nfree;        /* number of free blocks in s_free, <= SYSV_NICFREE */
  72        u16     s_pad1;
  73        sysv_zone_t     s_free[SYSV_NICFREE]; /* first free block list chunk */
  74        /* the cache of free inodes: */
  75        __fs16  s_ninode;       /* number of free inodes in s_inode, <= SYSV_NICINOD */
  76        u16     s_pad2;
  77        sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
  78        /* locks, not used by Linux: */
  79        char    s_flock;        /* lock during free block list manipulation */
  80        char    s_ilock;        /* lock during inode cache manipulation */
  81        char    s_fmod;         /* super-block modified flag */
  82        char    s_ronly;        /* flag whether fs is mounted read-only */
  83        __fs32  s_time;         /* time of last super block update */
  84        __fs16  s_dinfo[4];     /* device information ?? */
  85        __fs32  s_tfree;        /* total number of free zones */
  86        __fs16  s_tinode;       /* total number of free inodes */
  87        u16     s_pad3;
  88        char    s_fname[6];     /* file system volume name */
  89        char    s_fpack[6];     /* file system pack name */
  90        s32     s_fill[12];
  91        __fs32  s_state;        /* file system state: 0x7c269d38-s_time means clean */
  92        s32     s_magic;        /* version of file system */
  93        __fs32  s_type;         /* type of file system: 1 for 512 byte blocks
  94                                                                2 for 1024 byte blocks */
  95};
  96
  97/* SystemV2 super-block data on disk */
  98struct sysv2_super_block {
  99        __fs16  s_isize;                /* index of first data zone */
 100        __fs32  s_fsize __packed2__;    /* total number of zones of this fs */
 101        /* the start of the free block list: */
 102        __fs16  s_nfree;                /* number of free blocks in s_free, <= SYSV_NICFREE */
 103        sysv_zone_t s_free[SYSV_NICFREE];       /* first free block list chunk */
 104        /* the cache of free inodes: */
 105        __fs16  s_ninode;               /* number of free inodes in s_inode, <= SYSV_NICINOD */
 106        sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
 107        /* locks, not used by Linux: */
 108        char    s_flock;                /* lock during free block list manipulation */
 109        char    s_ilock;                /* lock during inode cache manipulation */
 110        char    s_fmod;                 /* super-block modified flag */
 111        char    s_ronly;                /* flag whether fs is mounted read-only */
 112        __fs32  s_time __packed2__;     /* time of last super block update */
 113        __fs16  s_dinfo[4];             /* device information ?? */
 114        __fs32  s_tfree __packed2__;    /* total number of free zones */
 115        __fs16  s_tinode;               /* total number of free inodes */
 116        char    s_fname[6];             /* file system volume name */
 117        char    s_fpack[6];             /* file system pack name */
 118        s32     s_fill[14];
 119        __fs32  s_state;                /* file system state: 0xcb096f43 means clean */
 120        s32     s_magic;                /* version of file system */
 121        __fs32  s_type;                 /* type of file system: 1 for 512 byte blocks
 122                                                                2 for 1024 byte blocks */
 123};
 124
 125/* V7 super-block data on disk */
 126#define V7_NICINOD     100     /* number of inode cache entries */
 127#define V7_NICFREE     50      /* number of free block list chunk entries */
 128struct v7_super_block {
 129        __fs16 s_isize;        /* index of first data zone */
 130        __fs32 s_fsize __packed2__; /* total number of zones of this fs */
 131        /* the start of the free block list: */
 132        __fs16 s_nfree;        /* number of free blocks in s_free, <= V7_NICFREE */
 133        sysv_zone_t s_free[V7_NICFREE]; /* first free block list chunk */
 134        /* the cache of free inodes: */
 135        __fs16 s_ninode;       /* number of free inodes in s_inode, <= V7_NICINOD */
 136        sysv_ino_t      s_inode[V7_NICINOD]; /* some free inodes */
 137        /* locks, not used by Linux or V7: */
 138        char    s_flock;        /* lock during free block list manipulation */
 139        char    s_ilock;        /* lock during inode cache manipulation */
 140        char    s_fmod;         /* super-block modified flag */
 141        char    s_ronly;        /* flag whether fs is mounted read-only */
 142        __fs32  s_time __packed2__; /* time of last super block update */
 143        /* the following fields are not maintained by V7: */
 144        __fs32  s_tfree __packed2__; /* total number of free zones */
 145        __fs16  s_tinode;       /* total number of free inodes */
 146        __fs16  s_m;            /* interleave factor */
 147        __fs16  s_n;            /* interleave factor */
 148        char    s_fname[6];     /* file system name */
 149        char    s_fpack[6];     /* file system pack name */
 150};
 151/* Constants to aid sanity checking */
 152/* This is not a hard limit, nor enforced by v7 kernel. It's actually just
 153 * the limit used by Seventh Edition's ls, though is high enough to assume
 154 * that no reasonable file system would have that much entries in root
 155 * directory. Thus, if we see anything higher, we just probably got the
 156 * endiannes wrong. */
 157#define V7_NFILES       1024
 158/* The disk addresses are three-byte (despite direct block addresses being
 159 * aligned word-wise in inode). If the most significant byte is non-zero,
 160 * something is most likely wrong (not a filesystem, bad bytesex). */
 161#define V7_MAXSIZE      0x00ffffff
 162
 163/* Coherent super-block data on disk */
 164#define COH_NICINOD     100     /* number of inode cache entries */
 165#define COH_NICFREE     64      /* number of free block list chunk entries */
 166struct coh_super_block {
 167        __fs16          s_isize;        /* index of first data zone */
 168        __fs32          s_fsize __packed2__; /* total number of zones of this fs */
 169        /* the start of the free block list: */
 170        __fs16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
 171        sysv_zone_t     s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
 172        /* the cache of free inodes: */
 173        __fs16          s_ninode;       /* number of free inodes in s_inode, <= COH_NICINOD */
 174        sysv_ino_t      s_inode[COH_NICINOD]; /* some free inodes */
 175        /* locks, not used by Linux: */
 176        char            s_flock;        /* lock during free block list manipulation */
 177        char            s_ilock;        /* lock during inode cache manipulation */
 178        char            s_fmod;         /* super-block modified flag */
 179        char            s_ronly;        /* flag whether fs is mounted read-only */
 180        __fs32          s_time __packed2__; /* time of last super block update */
 181        __fs32          s_tfree __packed2__; /* total number of free zones */
 182        __fs16          s_tinode;       /* total number of free inodes */
 183        __fs16          s_interleave_m; /* interleave factor */
 184        __fs16          s_interleave_n;
 185        char            s_fname[6];     /* file system volume name */
 186        char            s_fpack[6];     /* file system pack name */
 187        __fs32          s_unique;       /* zero, not used */
 188};
 189
 190/* SystemV/Coherent inode data on disk */
 191struct sysv_inode {
 192        __fs16 i_mode;
 193        __fs16 i_nlink;
 194        __fs16 i_uid;
 195        __fs16 i_gid;
 196        __fs32 i_size;
 197        u8  i_data[3*(10+1+1+1)];
 198        u8  i_gen;
 199        __fs32 i_atime; /* time of last access */
 200        __fs32 i_mtime; /* time of last modification */
 201        __fs32 i_ctime; /* time of creation */
 202};
 203
 204/* SystemV/Coherent directory entry on disk */
 205#define SYSV_NAMELEN    14      /* max size of name in struct sysv_dir_entry */
 206struct sysv_dir_entry {
 207        sysv_ino_t inode;
 208        char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
 209};
 210
 211#define SYSV_DIRSIZE    sizeof(struct sysv_dir_entry)   /* size of every directory entry */
 212
 213#endif /* _LINUX_SYSV_FS_H */
 214