Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_SYSV_FS_H
0003 #define _LINUX_SYSV_FS_H
0004 
0005 #define __packed2__ __attribute__((packed, aligned(2)))
0006 
0007 
0008 #ifndef __KERNEL__
0009 typedef u16 __fs16;
0010 typedef u32 __fs16;
0011 #endif
0012 
0013 /* inode numbers are 16 bit */
0014 typedef __fs16 sysv_ino_t;
0015 
0016 /* Block numbers are 24 bit, sometimes stored in 32 bit.
0017    On Coherent FS, they are always stored in PDP-11 manner: the least
0018    significant 16 bits come last. */
0019 typedef __fs32 sysv_zone_t;
0020 
0021 /* 0 is non-existent */
0022 #define SYSV_BADBL_INO  1   /* inode of bad blocks file */
0023 #define SYSV_ROOT_INO   2   /* inode of root directory */
0024 
0025 
0026 /* Xenix super-block data on disk */
0027 #define XENIX_NICINOD   100 /* number of inode cache entries */
0028 #define XENIX_NICFREE   100 /* number of free block list chunk entries */
0029 struct xenix_super_block {
0030     __fs16      s_isize; /* index of first data zone */
0031     __fs32      s_fsize __packed2__; /* total number of zones of this fs */
0032     /* the start of the free block list: */
0033     __fs16      s_nfree;    /* number of free blocks in s_free, <= XENIX_NICFREE */
0034     sysv_zone_t s_free[XENIX_NICFREE]; /* first free block list chunk */
0035     /* the cache of free inodes: */
0036     __fs16      s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
0037     sysv_ino_t  s_inode[XENIX_NICINOD]; /* some free inodes */
0038     /* locks, not used by Linux: */
0039     char        s_flock;    /* lock during free block list manipulation */
0040     char        s_ilock;    /* lock during inode cache manipulation */
0041     char        s_fmod;     /* super-block modified flag */
0042     char        s_ronly;    /* flag whether fs is mounted read-only */
0043     __fs32      s_time __packed2__; /* time of last super block update */
0044     __fs32      s_tfree __packed2__; /* total number of free zones */
0045     __fs16      s_tinode;   /* total number of free inodes */
0046     __fs16      s_dinfo[4]; /* device information ?? */
0047     char        s_fname[6]; /* file system volume name */
0048     char        s_fpack[6]; /* file system pack name */
0049     char        s_clean;    /* set to 0x46 when filesystem is properly unmounted */
0050     char        s_fill[371];
0051     s32     s_magic;    /* version of file system */
0052     __fs32      s_type;     /* type of file system: 1 for 512 byte blocks
0053                                 2 for 1024 byte blocks
0054                                 3 for 2048 byte blocks */
0055                                 
0056 };
0057 
0058 /*
0059  * SystemV FS comes in two variants:
0060  * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
0061  * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
0062  */
0063 #define SYSV_NICINOD    100 /* number of inode cache entries */
0064 #define SYSV_NICFREE    50  /* number of free block list chunk entries */
0065 
0066 /* SystemV4 super-block data on disk */
0067 struct sysv4_super_block {
0068     __fs16  s_isize;    /* index of first data zone */
0069     u16 s_pad0;
0070     __fs32  s_fsize;    /* total number of zones of this fs */
0071     /* the start of the free block list: */
0072     __fs16  s_nfree;    /* number of free blocks in s_free, <= SYSV_NICFREE */
0073     u16 s_pad1;
0074     sysv_zone_t s_free[SYSV_NICFREE]; /* first free block list chunk */
0075     /* the cache of free inodes: */
0076     __fs16  s_ninode;   /* number of free inodes in s_inode, <= SYSV_NICINOD */
0077     u16 s_pad2;
0078     sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
0079     /* locks, not used by Linux: */
0080     char    s_flock;    /* lock during free block list manipulation */
0081     char    s_ilock;    /* lock during inode cache manipulation */
0082     char    s_fmod;     /* super-block modified flag */
0083     char    s_ronly;    /* flag whether fs is mounted read-only */
0084     __fs32  s_time;     /* time of last super block update */
0085     __fs16  s_dinfo[4]; /* device information ?? */
0086     __fs32  s_tfree;    /* total number of free zones */
0087     __fs16  s_tinode;   /* total number of free inodes */
0088     u16 s_pad3;
0089     char    s_fname[6]; /* file system volume name */
0090     char    s_fpack[6]; /* file system pack name */
0091     s32 s_fill[12];
0092     __fs32  s_state;    /* file system state: 0x7c269d38-s_time means clean */
0093     s32 s_magic;    /* version of file system */
0094     __fs32  s_type;     /* type of file system: 1 for 512 byte blocks
0095                                 2 for 1024 byte blocks */
0096 };
0097 
0098 /* SystemV2 super-block data on disk */
0099 struct sysv2_super_block {
0100     __fs16  s_isize;        /* index of first data zone */
0101     __fs32  s_fsize __packed2__;    /* total number of zones of this fs */
0102     /* the start of the free block list: */
0103     __fs16  s_nfree;        /* number of free blocks in s_free, <= SYSV_NICFREE */
0104     sysv_zone_t s_free[SYSV_NICFREE];   /* first free block list chunk */
0105     /* the cache of free inodes: */
0106     __fs16  s_ninode;       /* number of free inodes in s_inode, <= SYSV_NICINOD */
0107     sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
0108     /* locks, not used by Linux: */
0109     char    s_flock;        /* lock during free block list manipulation */
0110     char    s_ilock;        /* lock during inode cache manipulation */
0111     char    s_fmod;         /* super-block modified flag */
0112     char    s_ronly;        /* flag whether fs is mounted read-only */
0113     __fs32  s_time __packed2__; /* time of last super block update */
0114     __fs16  s_dinfo[4];     /* device information ?? */
0115     __fs32  s_tfree __packed2__;    /* total number of free zones */
0116     __fs16  s_tinode;       /* total number of free inodes */
0117     char    s_fname[6];     /* file system volume name */
0118     char    s_fpack[6];     /* file system pack name */
0119     s32 s_fill[14];
0120     __fs32  s_state;        /* file system state: 0xcb096f43 means clean */
0121     s32 s_magic;        /* version of file system */
0122     __fs32  s_type;         /* type of file system: 1 for 512 byte blocks
0123                                 2 for 1024 byte blocks */
0124 };
0125 
0126 /* V7 super-block data on disk */
0127 #define V7_NICINOD     100     /* number of inode cache entries */
0128 #define V7_NICFREE     50      /* number of free block list chunk entries */
0129 struct v7_super_block {
0130     __fs16 s_isize;        /* index of first data zone */
0131     __fs32 s_fsize __packed2__; /* total number of zones of this fs */
0132     /* the start of the free block list: */
0133     __fs16 s_nfree;        /* number of free blocks in s_free, <= V7_NICFREE */
0134     sysv_zone_t s_free[V7_NICFREE]; /* first free block list chunk */
0135     /* the cache of free inodes: */
0136     __fs16 s_ninode;       /* number of free inodes in s_inode, <= V7_NICINOD */
0137     sysv_ino_t      s_inode[V7_NICINOD]; /* some free inodes */
0138     /* locks, not used by Linux or V7: */
0139     char    s_flock;        /* lock during free block list manipulation */
0140     char    s_ilock;        /* lock during inode cache manipulation */
0141     char    s_fmod;         /* super-block modified flag */
0142     char    s_ronly;        /* flag whether fs is mounted read-only */
0143     __fs32  s_time __packed2__; /* time of last super block update */
0144     /* the following fields are not maintained by V7: */
0145     __fs32  s_tfree __packed2__; /* total number of free zones */
0146     __fs16  s_tinode;       /* total number of free inodes */
0147     __fs16  s_m;            /* interleave factor */
0148     __fs16  s_n;            /* interleave factor */
0149     char    s_fname[6];     /* file system name */
0150     char    s_fpack[6];     /* file system pack name */
0151 };
0152 /* Constants to aid sanity checking */
0153 /* This is not a hard limit, nor enforced by v7 kernel. It's actually just
0154  * the limit used by Seventh Edition's ls, though is high enough to assume
0155  * that no reasonable file system would have that much entries in root
0156  * directory. Thus, if we see anything higher, we just probably got the
0157  * endiannes wrong. */
0158 #define V7_NFILES   1024
0159 /* The disk addresses are three-byte (despite direct block addresses being
0160  * aligned word-wise in inode). If the most significant byte is non-zero,
0161  * something is most likely wrong (not a filesystem, bad bytesex). */
0162 #define V7_MAXSIZE  0x00ffffff
0163 
0164 /* Coherent super-block data on disk */
0165 #define COH_NICINOD 100 /* number of inode cache entries */
0166 #define COH_NICFREE 64  /* number of free block list chunk entries */
0167 struct coh_super_block {
0168     __fs16      s_isize;    /* index of first data zone */
0169     __fs32      s_fsize __packed2__; /* total number of zones of this fs */
0170     /* the start of the free block list: */
0171     __fs16 s_nfree; /* number of free blocks in s_free, <= COH_NICFREE */
0172     sysv_zone_t s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
0173     /* the cache of free inodes: */
0174     __fs16      s_ninode;   /* number of free inodes in s_inode, <= COH_NICINOD */
0175     sysv_ino_t  s_inode[COH_NICINOD]; /* some free inodes */
0176     /* locks, not used by Linux: */
0177     char        s_flock;    /* lock during free block list manipulation */
0178     char        s_ilock;    /* lock during inode cache manipulation */
0179     char        s_fmod;     /* super-block modified flag */
0180     char        s_ronly;    /* flag whether fs is mounted read-only */
0181     __fs32      s_time __packed2__; /* time of last super block update */
0182     __fs32      s_tfree __packed2__; /* total number of free zones */
0183     __fs16      s_tinode;   /* total number of free inodes */
0184     __fs16      s_interleave_m; /* interleave factor */
0185     __fs16      s_interleave_n;
0186     char        s_fname[6]; /* file system volume name */
0187     char        s_fpack[6]; /* file system pack name */
0188     __fs32      s_unique;   /* zero, not used */
0189 };
0190 
0191 /* SystemV/Coherent inode data on disk */
0192 struct sysv_inode {
0193     __fs16 i_mode;
0194     __fs16 i_nlink;
0195     __fs16 i_uid;
0196     __fs16 i_gid;
0197     __fs32 i_size;
0198     u8  i_data[3*(10+1+1+1)];
0199     u8  i_gen;
0200     __fs32 i_atime; /* time of last access */
0201     __fs32 i_mtime; /* time of last modification */
0202     __fs32 i_ctime; /* time of creation */
0203 };
0204 
0205 /* SystemV/Coherent directory entry on disk */
0206 #define SYSV_NAMELEN    14  /* max size of name in struct sysv_dir_entry */
0207 struct sysv_dir_entry {
0208     sysv_ino_t inode;
0209     char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
0210 };
0211 
0212 #define SYSV_DIRSIZE    sizeof(struct sysv_dir_entry)   /* size of every directory entry */
0213 
0214 #endif /* _LINUX_SYSV_FS_H */