xref: /openbmc/linux/include/linux/sysv_fs.h (revision b2441318)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds #ifndef _LINUX_SYSV_FS_H
31da177e4SLinus Torvalds #define _LINUX_SYSV_FS_H
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #define __packed2__	__attribute__((packed, aligned(2)))
61da177e4SLinus Torvalds 
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #ifndef __KERNEL__
91da177e4SLinus Torvalds typedef u16 __fs16;
101da177e4SLinus Torvalds typedef u32 __fs16;
111da177e4SLinus Torvalds #endif
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds /* inode numbers are 16 bit */
141da177e4SLinus Torvalds typedef __fs16 sysv_ino_t;
151da177e4SLinus Torvalds 
161da177e4SLinus Torvalds /* Block numbers are 24 bit, sometimes stored in 32 bit.
171da177e4SLinus Torvalds    On Coherent FS, they are always stored in PDP-11 manner: the least
181da177e4SLinus Torvalds    significant 16 bits come last. */
191da177e4SLinus Torvalds typedef __fs32 sysv_zone_t;
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds /* 0 is non-existent */
221da177e4SLinus Torvalds #define SYSV_BADBL_INO	1	/* inode of bad blocks file */
231da177e4SLinus Torvalds #define SYSV_ROOT_INO	2	/* inode of root directory */
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds /* Xenix super-block data on disk */
271da177e4SLinus Torvalds #define XENIX_NICINOD	100	/* number of inode cache entries */
281da177e4SLinus Torvalds #define XENIX_NICFREE	100	/* number of free block list chunk entries */
291da177e4SLinus Torvalds struct xenix_super_block {
301da177e4SLinus Torvalds 	__fs16		s_isize; /* index of first data zone */
311da177e4SLinus Torvalds 	__fs32		s_fsize __packed2__; /* total number of zones of this fs */
321da177e4SLinus Torvalds 	/* the start of the free block list: */
331da177e4SLinus Torvalds 	__fs16		s_nfree;	/* number of free blocks in s_free, <= XENIX_NICFREE */
341da177e4SLinus Torvalds 	sysv_zone_t	s_free[XENIX_NICFREE]; /* first free block list chunk */
351da177e4SLinus Torvalds 	/* the cache of free inodes: */
361da177e4SLinus Torvalds 	__fs16		s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
371da177e4SLinus Torvalds 	sysv_ino_t	s_inode[XENIX_NICINOD]; /* some free inodes */
381da177e4SLinus Torvalds 	/* locks, not used by Linux: */
391da177e4SLinus Torvalds 	char		s_flock;	/* lock during free block list manipulation */
401da177e4SLinus Torvalds 	char		s_ilock;	/* lock during inode cache manipulation */
411da177e4SLinus Torvalds 	char		s_fmod;		/* super-block modified flag */
421da177e4SLinus Torvalds 	char		s_ronly;	/* flag whether fs is mounted read-only */
431da177e4SLinus Torvalds 	__fs32		s_time __packed2__; /* time of last super block update */
441da177e4SLinus Torvalds 	__fs32		s_tfree __packed2__; /* total number of free zones */
451da177e4SLinus Torvalds 	__fs16		s_tinode;	/* total number of free inodes */
461da177e4SLinus Torvalds 	__fs16		s_dinfo[4];	/* device information ?? */
471da177e4SLinus Torvalds 	char		s_fname[6];	/* file system volume name */
481da177e4SLinus Torvalds 	char		s_fpack[6];	/* file system pack name */
491da177e4SLinus Torvalds 	char		s_clean;	/* set to 0x46 when filesystem is properly unmounted */
501da177e4SLinus Torvalds 	char		s_fill[371];
511da177e4SLinus Torvalds 	s32		s_magic;	/* version of file system */
521da177e4SLinus Torvalds 	__fs32		s_type;		/* type of file system: 1 for 512 byte blocks
531da177e4SLinus Torvalds 								2 for 1024 byte blocks
541da177e4SLinus Torvalds 								3 for 2048 byte blocks */
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds };
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds /*
591da177e4SLinus Torvalds  * SystemV FS comes in two variants:
601da177e4SLinus Torvalds  * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
611da177e4SLinus Torvalds  * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
621da177e4SLinus Torvalds  */
631da177e4SLinus Torvalds #define SYSV_NICINOD	100	/* number of inode cache entries */
641da177e4SLinus Torvalds #define SYSV_NICFREE	50	/* number of free block list chunk entries */
651da177e4SLinus Torvalds 
661da177e4SLinus Torvalds /* SystemV4 super-block data on disk */
671da177e4SLinus Torvalds struct sysv4_super_block {
681da177e4SLinus Torvalds 	__fs16	s_isize;	/* index of first data zone */
691da177e4SLinus Torvalds 	u16	s_pad0;
701da177e4SLinus Torvalds 	__fs32	s_fsize;	/* total number of zones of this fs */
711da177e4SLinus Torvalds 	/* the start of the free block list: */
721da177e4SLinus Torvalds 	__fs16	s_nfree;	/* number of free blocks in s_free, <= SYSV_NICFREE */
731da177e4SLinus Torvalds 	u16	s_pad1;
741da177e4SLinus Torvalds 	sysv_zone_t	s_free[SYSV_NICFREE]; /* first free block list chunk */
751da177e4SLinus Torvalds 	/* the cache of free inodes: */
761da177e4SLinus Torvalds 	__fs16	s_ninode;	/* number of free inodes in s_inode, <= SYSV_NICINOD */
771da177e4SLinus Torvalds 	u16	s_pad2;
781da177e4SLinus Torvalds 	sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
791da177e4SLinus Torvalds 	/* locks, not used by Linux: */
801da177e4SLinus Torvalds 	char	s_flock;	/* lock during free block list manipulation */
811da177e4SLinus Torvalds 	char	s_ilock;	/* lock during inode cache manipulation */
821da177e4SLinus Torvalds 	char	s_fmod;		/* super-block modified flag */
831da177e4SLinus Torvalds 	char	s_ronly;	/* flag whether fs is mounted read-only */
841da177e4SLinus Torvalds 	__fs32	s_time;		/* time of last super block update */
851da177e4SLinus Torvalds 	__fs16	s_dinfo[4];	/* device information ?? */
861da177e4SLinus Torvalds 	__fs32	s_tfree;	/* total number of free zones */
871da177e4SLinus Torvalds 	__fs16	s_tinode;	/* total number of free inodes */
881da177e4SLinus Torvalds 	u16	s_pad3;
891da177e4SLinus Torvalds 	char	s_fname[6];	/* file system volume name */
901da177e4SLinus Torvalds 	char	s_fpack[6];	/* file system pack name */
911da177e4SLinus Torvalds 	s32	s_fill[12];
921da177e4SLinus Torvalds 	__fs32	s_state;	/* file system state: 0x7c269d38-s_time means clean */
931da177e4SLinus Torvalds 	s32	s_magic;	/* version of file system */
941da177e4SLinus Torvalds 	__fs32	s_type;		/* type of file system: 1 for 512 byte blocks
951da177e4SLinus Torvalds 								2 for 1024 byte blocks */
961da177e4SLinus Torvalds };
971da177e4SLinus Torvalds 
981da177e4SLinus Torvalds /* SystemV2 super-block data on disk */
991da177e4SLinus Torvalds struct sysv2_super_block {
1001da177e4SLinus Torvalds 	__fs16	s_isize; 		/* index of first data zone */
1011da177e4SLinus Torvalds 	__fs32	s_fsize __packed2__;	/* total number of zones of this fs */
1021da177e4SLinus Torvalds 	/* the start of the free block list: */
1031da177e4SLinus Torvalds 	__fs16	s_nfree;		/* number of free blocks in s_free, <= SYSV_NICFREE */
1041da177e4SLinus Torvalds 	sysv_zone_t s_free[SYSV_NICFREE];	/* first free block list chunk */
1051da177e4SLinus Torvalds 	/* the cache of free inodes: */
1061da177e4SLinus Torvalds 	__fs16	s_ninode;		/* number of free inodes in s_inode, <= SYSV_NICINOD */
1071da177e4SLinus Torvalds 	sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
1081da177e4SLinus Torvalds 	/* locks, not used by Linux: */
1091da177e4SLinus Torvalds 	char	s_flock;		/* lock during free block list manipulation */
1101da177e4SLinus Torvalds 	char	s_ilock;		/* lock during inode cache manipulation */
1111da177e4SLinus Torvalds 	char	s_fmod;			/* super-block modified flag */
1121da177e4SLinus Torvalds 	char	s_ronly;		/* flag whether fs is mounted read-only */
1131da177e4SLinus Torvalds 	__fs32	s_time __packed2__;	/* time of last super block update */
1141da177e4SLinus Torvalds 	__fs16	s_dinfo[4];		/* device information ?? */
1151da177e4SLinus Torvalds 	__fs32	s_tfree __packed2__;	/* total number of free zones */
1161da177e4SLinus Torvalds 	__fs16	s_tinode;		/* total number of free inodes */
1171da177e4SLinus Torvalds 	char	s_fname[6];		/* file system volume name */
1181da177e4SLinus Torvalds 	char	s_fpack[6];		/* file system pack name */
1191da177e4SLinus Torvalds 	s32	s_fill[14];
1201da177e4SLinus Torvalds 	__fs32	s_state;		/* file system state: 0xcb096f43 means clean */
1211da177e4SLinus Torvalds 	s32	s_magic;		/* version of file system */
1221da177e4SLinus Torvalds 	__fs32	s_type;			/* type of file system: 1 for 512 byte blocks
1231da177e4SLinus Torvalds 								2 for 1024 byte blocks */
1241da177e4SLinus Torvalds };
1251da177e4SLinus Torvalds 
1261da177e4SLinus Torvalds /* V7 super-block data on disk */
1271da177e4SLinus Torvalds #define V7_NICINOD     100     /* number of inode cache entries */
1281da177e4SLinus Torvalds #define V7_NICFREE     50      /* number of free block list chunk entries */
1291da177e4SLinus Torvalds struct v7_super_block {
1301da177e4SLinus Torvalds 	__fs16 s_isize;        /* index of first data zone */
1311da177e4SLinus Torvalds 	__fs32 s_fsize __packed2__; /* total number of zones of this fs */
1321da177e4SLinus Torvalds 	/* the start of the free block list: */
1331da177e4SLinus Torvalds 	__fs16 s_nfree;        /* number of free blocks in s_free, <= V7_NICFREE */
1341da177e4SLinus Torvalds 	sysv_zone_t s_free[V7_NICFREE]; /* first free block list chunk */
1351da177e4SLinus Torvalds 	/* the cache of free inodes: */
1361da177e4SLinus Torvalds 	__fs16 s_ninode;       /* number of free inodes in s_inode, <= V7_NICINOD */
1371da177e4SLinus Torvalds 	sysv_ino_t      s_inode[V7_NICINOD]; /* some free inodes */
1381da177e4SLinus Torvalds 	/* locks, not used by Linux or V7: */
1391da177e4SLinus Torvalds 	char    s_flock;        /* lock during free block list manipulation */
1401da177e4SLinus Torvalds 	char    s_ilock;        /* lock during inode cache manipulation */
1411da177e4SLinus Torvalds 	char    s_fmod;         /* super-block modified flag */
1421da177e4SLinus Torvalds 	char    s_ronly;        /* flag whether fs is mounted read-only */
1431da177e4SLinus Torvalds 	__fs32  s_time __packed2__; /* time of last super block update */
1441da177e4SLinus Torvalds 	/* the following fields are not maintained by V7: */
1451da177e4SLinus Torvalds 	__fs32  s_tfree __packed2__; /* total number of free zones */
1461da177e4SLinus Torvalds 	__fs16  s_tinode;       /* total number of free inodes */
1471da177e4SLinus Torvalds 	__fs16  s_m;            /* interleave factor */
1481da177e4SLinus Torvalds 	__fs16  s_n;            /* interleave factor */
1491da177e4SLinus Torvalds 	char    s_fname[6];     /* file system name */
1501da177e4SLinus Torvalds 	char    s_fpack[6];     /* file system pack name */
1511da177e4SLinus Torvalds };
1520bcaa65aSLubomir Rintel /* Constants to aid sanity checking */
1530bcaa65aSLubomir Rintel /* This is not a hard limit, nor enforced by v7 kernel. It's actually just
1540bcaa65aSLubomir Rintel  * the limit used by Seventh Edition's ls, though is high enough to assume
1550bcaa65aSLubomir Rintel  * that no reasonable file system would have that much entries in root
1560bcaa65aSLubomir Rintel  * directory. Thus, if we see anything higher, we just probably got the
1570bcaa65aSLubomir Rintel  * endiannes wrong. */
1580bcaa65aSLubomir Rintel #define V7_NFILES	1024
1590bcaa65aSLubomir Rintel /* The disk addresses are three-byte (despite direct block addresses being
1600bcaa65aSLubomir Rintel  * aligned word-wise in inode). If the most significant byte is non-zero,
1610bcaa65aSLubomir Rintel  * something is most likely wrong (not a filesystem, bad bytesex). */
1620bcaa65aSLubomir Rintel #define V7_MAXSIZE	0x00ffffff
1631da177e4SLinus Torvalds 
1641da177e4SLinus Torvalds /* Coherent super-block data on disk */
1651da177e4SLinus Torvalds #define COH_NICINOD	100	/* number of inode cache entries */
1661da177e4SLinus Torvalds #define COH_NICFREE	64	/* number of free block list chunk entries */
1671da177e4SLinus Torvalds struct coh_super_block {
1681da177e4SLinus Torvalds 	__fs16		s_isize;	/* index of first data zone */
1691da177e4SLinus Torvalds 	__fs32		s_fsize __packed2__; /* total number of zones of this fs */
1701da177e4SLinus Torvalds 	/* the start of the free block list: */
1711da177e4SLinus Torvalds 	__fs16 s_nfree;	/* number of free blocks in s_free, <= COH_NICFREE */
1721da177e4SLinus Torvalds 	sysv_zone_t	s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
1731da177e4SLinus Torvalds 	/* the cache of free inodes: */
1741da177e4SLinus Torvalds 	__fs16		s_ninode;	/* number of free inodes in s_inode, <= COH_NICINOD */
1751da177e4SLinus Torvalds 	sysv_ino_t	s_inode[COH_NICINOD]; /* some free inodes */
1761da177e4SLinus Torvalds 	/* locks, not used by Linux: */
1771da177e4SLinus Torvalds 	char		s_flock;	/* lock during free block list manipulation */
1781da177e4SLinus Torvalds 	char		s_ilock;	/* lock during inode cache manipulation */
1791da177e4SLinus Torvalds 	char		s_fmod;		/* super-block modified flag */
1801da177e4SLinus Torvalds 	char		s_ronly;	/* flag whether fs is mounted read-only */
1811da177e4SLinus Torvalds 	__fs32		s_time __packed2__; /* time of last super block update */
1821da177e4SLinus Torvalds 	__fs32		s_tfree __packed2__; /* total number of free zones */
1831da177e4SLinus Torvalds 	__fs16		s_tinode;	/* total number of free inodes */
1841da177e4SLinus Torvalds 	__fs16		s_interleave_m;	/* interleave factor */
1851da177e4SLinus Torvalds 	__fs16		s_interleave_n;
1861da177e4SLinus Torvalds 	char		s_fname[6];	/* file system volume name */
1871da177e4SLinus Torvalds 	char		s_fpack[6];	/* file system pack name */
1881da177e4SLinus Torvalds 	__fs32		s_unique;	/* zero, not used */
1891da177e4SLinus Torvalds };
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds /* SystemV/Coherent inode data on disk */
1921da177e4SLinus Torvalds struct sysv_inode {
1931da177e4SLinus Torvalds 	__fs16 i_mode;
1941da177e4SLinus Torvalds 	__fs16 i_nlink;
1951da177e4SLinus Torvalds 	__fs16 i_uid;
1961da177e4SLinus Torvalds 	__fs16 i_gid;
1971da177e4SLinus Torvalds 	__fs32 i_size;
1981da177e4SLinus Torvalds 	u8  i_data[3*(10+1+1+1)];
1991da177e4SLinus Torvalds 	u8  i_gen;
2001da177e4SLinus Torvalds 	__fs32 i_atime;	/* time of last access */
2011da177e4SLinus Torvalds 	__fs32 i_mtime;	/* time of last modification */
2021da177e4SLinus Torvalds 	__fs32 i_ctime;	/* time of creation */
2031da177e4SLinus Torvalds };
2041da177e4SLinus Torvalds 
2051da177e4SLinus Torvalds /* SystemV/Coherent directory entry on disk */
2061da177e4SLinus Torvalds #define SYSV_NAMELEN	14	/* max size of name in struct sysv_dir_entry */
2071da177e4SLinus Torvalds struct sysv_dir_entry {
2081da177e4SLinus Torvalds 	sysv_ino_t inode;
2091da177e4SLinus Torvalds 	char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
2101da177e4SLinus Torvalds };
2111da177e4SLinus Torvalds 
2121da177e4SLinus Torvalds #define SYSV_DIRSIZE	sizeof(struct sysv_dir_entry)	/* size of every directory entry */
2131da177e4SLinus Torvalds 
2141da177e4SLinus Torvalds #endif /* _LINUX_SYSV_FS_H */
215