xref: /illumos-gate/usr/src/grub/grub-0.97/stage2/jfs.h (revision 1b8adde7)
17c478bd9Sstevel@tonic-gate /* jfs.h - an extractions from linux/include/linux/jfs/jfs* into one file */
27c478bd9Sstevel@tonic-gate /*
37c478bd9Sstevel@tonic-gate  *  GRUB  --  GRand Unified Bootloader
47c478bd9Sstevel@tonic-gate  *  Copyright (C) 2000  International Business Machines  Corp.
57c478bd9Sstevel@tonic-gate  *  Copyright (C) 2001  Free Software Foundation, Inc.
67c478bd9Sstevel@tonic-gate  *
77c478bd9Sstevel@tonic-gate  *  This program is free software;  you can redistribute it and/or modify
87c478bd9Sstevel@tonic-gate  *  it under the terms of the GNU General Public License as published by
97c478bd9Sstevel@tonic-gate  *  the Free Software Foundation; either version 2 of the License, or
107c478bd9Sstevel@tonic-gate  *  (at your option) any later version.
117c478bd9Sstevel@tonic-gate  *
127c478bd9Sstevel@tonic-gate  *  This program is distributed in the hope that it will be useful,
137c478bd9Sstevel@tonic-gate  *  but WITHOUT ANY WARRANTY;  without even the implied warranty of
147c478bd9Sstevel@tonic-gate  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
157c478bd9Sstevel@tonic-gate  *  the GNU General Public License for more details.
167c478bd9Sstevel@tonic-gate  *
177c478bd9Sstevel@tonic-gate  *  You should have received a copy of the GNU General Public License
187c478bd9Sstevel@tonic-gate  *  along with this program;  if not, write to the Free Software
197c478bd9Sstevel@tonic-gate  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate 
227c478bd9Sstevel@tonic-gate #ifndef _JFS_H_
237c478bd9Sstevel@tonic-gate #define _JFS_H_
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate /* those are from jfs_filsys.h */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  *	 file system option (superblock flag)
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate /* platform option (conditional compilation) */
317c478bd9Sstevel@tonic-gate #define JFS_AIX		0x80000000	/* AIX support */
327c478bd9Sstevel@tonic-gate /*	POSIX name/directory  support */
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #define JFS_OS2		0x40000000	/* OS/2 support */
357c478bd9Sstevel@tonic-gate /*	case-insensitive name/directory support */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define JFS_LINUX      	0x10000000	/* Linux support */
387c478bd9Sstevel@tonic-gate /*	case-sensitive name/directory support */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /* directory option */
417c478bd9Sstevel@tonic-gate #define JFS_UNICODE	0x00000001	/* unicode name */
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /* bba */
447c478bd9Sstevel@tonic-gate #define	JFS_SWAP_BYTES		0x00100000	/* running on big endian computer */
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  *	buffer cache configuration
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate /* page size */
517c478bd9Sstevel@tonic-gate #ifdef PSIZE
527c478bd9Sstevel@tonic-gate #undef PSIZE
537c478bd9Sstevel@tonic-gate #endif
547c478bd9Sstevel@tonic-gate #define	PSIZE		4096	/* page size (in byte) */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  *	fs fundamental size
587c478bd9Sstevel@tonic-gate  *
597c478bd9Sstevel@tonic-gate  * PSIZE >= file system block size >= PBSIZE >= DISIZE
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate #define	PBSIZE		512	/* physical block size (in byte) */
627c478bd9Sstevel@tonic-gate #define DISIZE		512	/* on-disk inode size (in byte) */
637c478bd9Sstevel@tonic-gate #define L2DISIZE	9
647c478bd9Sstevel@tonic-gate #define	INOSPERIAG	4096	/* number of disk inodes per iag */
657c478bd9Sstevel@tonic-gate #define	L2INOSPERIAG	12
667c478bd9Sstevel@tonic-gate #define INOSPEREXT	32	/* number of disk inode per extent */
677c478bd9Sstevel@tonic-gate #define L2INOSPEREXT	5
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* Minimum number of bytes supported for a JFS partition */
707c478bd9Sstevel@tonic-gate #define MINJFS			(0x1000000)
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * fixed byte offset address
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate #define SUPER1_OFF	0x8000	/* primary superblock */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #define AITBL_OFF	(SUPER1_OFF + PSIZE + (PSIZE << 1))
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate /*
807c478bd9Sstevel@tonic-gate  *	fixed reserved inode number
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate /* aggregate inode */
837c478bd9Sstevel@tonic-gate #define	AGGREGATE_I	1	/* aggregate inode map inode */
847c478bd9Sstevel@tonic-gate #define	FILESYSTEM_I	16	/* 1st/only fileset inode in ait:
857c478bd9Sstevel@tonic-gate 				 * fileset inode map inode
867c478bd9Sstevel@tonic-gate 				 */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /* per fileset inode */
897c478bd9Sstevel@tonic-gate #define	ROOT_I		2	/* fileset root inode */
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  *	directory configuration
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate #define JFS_NAME_MAX	255
957c478bd9Sstevel@tonic-gate #define JFS_PATH_MAX	PSIZE
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate typedef unsigned char u8;
987c478bd9Sstevel@tonic-gate typedef char s8;
997c478bd9Sstevel@tonic-gate typedef unsigned short u16;
1007c478bd9Sstevel@tonic-gate typedef short s16;
1017c478bd9Sstevel@tonic-gate typedef unsigned int u32;
1027c478bd9Sstevel@tonic-gate typedef int s32;
1037c478bd9Sstevel@tonic-gate typedef unsigned long long u64;
1047c478bd9Sstevel@tonic-gate typedef long long s64;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate typedef u16 UniChar;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /* these from jfs_btree.h */
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /* btpaget_t flag */
1117c478bd9Sstevel@tonic-gate #define BT_TYPE		0x07	/* B+-tree index */
1127c478bd9Sstevel@tonic-gate #define	BT_ROOT		0x01	/* root page */
1137c478bd9Sstevel@tonic-gate #define	BT_LEAF		0x02	/* leaf page */
1147c478bd9Sstevel@tonic-gate #define	BT_INTERNAL	0x04	/* internal page */
1157c478bd9Sstevel@tonic-gate #define	BT_RIGHTMOST	0x10	/* rightmost page */
1167c478bd9Sstevel@tonic-gate #define	BT_LEFTMOST	0x20	/* leftmost page */
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /* those are from jfs_types.h */
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate struct timestruc_t {
1217c478bd9Sstevel@tonic-gate 	u32 tv_sec;
1227c478bd9Sstevel@tonic-gate 	u32 tv_nsec;
1237c478bd9Sstevel@tonic-gate };
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /*
1267c478bd9Sstevel@tonic-gate  *	physical xd (pxd)
1277c478bd9Sstevel@tonic-gate  */
1287c478bd9Sstevel@tonic-gate typedef struct {
1297c478bd9Sstevel@tonic-gate 	unsigned len:24;
1307c478bd9Sstevel@tonic-gate 	unsigned addr1:8;
1317c478bd9Sstevel@tonic-gate 	u32 addr2;
1327c478bd9Sstevel@tonic-gate } pxd_t;
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /* xd_t field extraction */
1357c478bd9Sstevel@tonic-gate #define	lengthPXD(pxd)	((pxd)->len)
1367c478bd9Sstevel@tonic-gate #define	addressPXD(pxd)	(((s64)((pxd)->addr1)) << 32 | ((pxd)->addr2))
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  *	data extent descriptor (dxd)
1407c478bd9Sstevel@tonic-gate  */
1417c478bd9Sstevel@tonic-gate typedef struct {
1427c478bd9Sstevel@tonic-gate 	unsigned flag:8;	/* 1: flags */
1437c478bd9Sstevel@tonic-gate 	unsigned rsrvd:24;	/* 3: */
1447c478bd9Sstevel@tonic-gate 	u32 size;		/* 4: size in byte */
1457c478bd9Sstevel@tonic-gate 	unsigned len:24;	/* 3: length in unit of fsblksize */
1467c478bd9Sstevel@tonic-gate 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
1477c478bd9Sstevel@tonic-gate 	u32 addr2;		/* 4: address in unit of fsblksize */
1487c478bd9Sstevel@tonic-gate } dxd_t;			/* - 16 - */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate /*
1517c478bd9Sstevel@tonic-gate  *	DASD limit information - stored in directory inode
1527c478bd9Sstevel@tonic-gate  */
1537c478bd9Sstevel@tonic-gate typedef struct dasd {
1547c478bd9Sstevel@tonic-gate 	u8 thresh;		/* Alert Threshold (in percent) */
1557c478bd9Sstevel@tonic-gate 	u8 delta;		/* Alert Threshold delta (in percent)   */
1567c478bd9Sstevel@tonic-gate 	u8 rsrvd1;
1577c478bd9Sstevel@tonic-gate 	u8 limit_hi;		/* DASD limit (in logical blocks)       */
1587c478bd9Sstevel@tonic-gate 	u32 limit_lo;		/* DASD limit (in logical blocks)       */
1597c478bd9Sstevel@tonic-gate 	u8 rsrvd2[3];
1607c478bd9Sstevel@tonic-gate 	u8 used_hi;		/* DASD usage (in logical blocks)       */
1617c478bd9Sstevel@tonic-gate 	u32 used_lo;		/* DASD usage (in logical blocks)       */
1627c478bd9Sstevel@tonic-gate } dasd_t;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /* from jfs_superblock.h */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #define JFS_MAGIC 	0x3153464A	/* "JFS1" */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate struct jfs_superblock
1707c478bd9Sstevel@tonic-gate {
1717c478bd9Sstevel@tonic-gate 	u32 s_magic;		/* 4: magic number */
1727c478bd9Sstevel@tonic-gate 	u32 s_version;		/* 4: version number */
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	s64 s_size;		/* 8: aggregate size in hardware/LVM blocks;
1757c478bd9Sstevel@tonic-gate 				 * VFS: number of blocks
1767c478bd9Sstevel@tonic-gate 				 */
1777c478bd9Sstevel@tonic-gate 	s32 s_bsize;		/* 4: aggregate block size in bytes;
1787c478bd9Sstevel@tonic-gate 				 * VFS: fragment size
1797c478bd9Sstevel@tonic-gate 				 */
1807c478bd9Sstevel@tonic-gate 	s16 s_l2bsize;		/* 2: log2 of s_bsize */
1817c478bd9Sstevel@tonic-gate 	s16 s_l2bfactor;	/* 2: log2(s_bsize/hardware block size) */
1827c478bd9Sstevel@tonic-gate 	s32 s_pbsize;		/* 4: hardware/LVM block size in bytes */
1837c478bd9Sstevel@tonic-gate 	s16 s_l2pbsize;		/* 2: log2 of s_pbsize */
1847c478bd9Sstevel@tonic-gate 	s16 pad;		/* 2: padding necessary for alignment */
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate 	u32 s_agsize;		/* 4: allocation group size in aggr. blocks */
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 	u32 s_flag;		/* 4: aggregate attributes:
1897c478bd9Sstevel@tonic-gate 				 *    see jfs_filsys.h
1907c478bd9Sstevel@tonic-gate 				 */
1917c478bd9Sstevel@tonic-gate 	u32 s_state;		/* 4: mount/unmount/recovery state:
1927c478bd9Sstevel@tonic-gate 				 *    see jfs_filsys.h
1937c478bd9Sstevel@tonic-gate 				 */
1947c478bd9Sstevel@tonic-gate 	s32 s_compress;		/* 4: > 0 if data compression */
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate 	pxd_t s_ait2;		/* 8: first extent of secondary
1977c478bd9Sstevel@tonic-gate 				 *    aggregate inode table
1987c478bd9Sstevel@tonic-gate 				 */
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 	pxd_t s_aim2;		/* 8: first extent of secondary
2017c478bd9Sstevel@tonic-gate 				 *    aggregate inode map
2027c478bd9Sstevel@tonic-gate 				 */
2037c478bd9Sstevel@tonic-gate 	u32 s_logdev;		/* 4: device address of log */
2047c478bd9Sstevel@tonic-gate 	s32 s_logserial;	/* 4: log serial number at aggregate mount */
2057c478bd9Sstevel@tonic-gate 	pxd_t s_logpxd;		/* 8: inline log extent */
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	pxd_t s_fsckpxd;	/* 8: inline fsck work space extent */
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 	struct timestruc_t s_time;	/* 8: time last updated */
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate 	s32 s_fsckloglen;	/* 4: Number of filesystem blocks reserved for
2127c478bd9Sstevel@tonic-gate 				 *    the fsck service log.
2137c478bd9Sstevel@tonic-gate 				 *    N.B. These blocks are divided among the
2147c478bd9Sstevel@tonic-gate 				 *         versions kept.  This is not a per
2157c478bd9Sstevel@tonic-gate 				 *         version size.
2167c478bd9Sstevel@tonic-gate 				 *    N.B. These blocks are included in the
2177c478bd9Sstevel@tonic-gate 				 *         length field of s_fsckpxd.
2187c478bd9Sstevel@tonic-gate 				 */
2197c478bd9Sstevel@tonic-gate 	s8 s_fscklog;		/* 1: which fsck service log is most recent
2207c478bd9Sstevel@tonic-gate 				 *    0 => no service log data yet
2217c478bd9Sstevel@tonic-gate 				 *    1 => the first one
2227c478bd9Sstevel@tonic-gate 				 *    2 => the 2nd one
2237c478bd9Sstevel@tonic-gate 				 */
2247c478bd9Sstevel@tonic-gate 	char s_fpack[11];	/* 11: file system volume name
2257c478bd9Sstevel@tonic-gate 				 *     N.B. This must be 11 bytes to
2267c478bd9Sstevel@tonic-gate 				 *          conform with the OS/2 BootSector
2277c478bd9Sstevel@tonic-gate 				 *          requirements
2287c478bd9Sstevel@tonic-gate 				 */
2297c478bd9Sstevel@tonic-gate 
2307c478bd9Sstevel@tonic-gate 	/* extendfs() parameter under s_state & FM_EXTENDFS */
2317c478bd9Sstevel@tonic-gate 	s64 s_xsize;		/* 8: extendfs s_size */
2327c478bd9Sstevel@tonic-gate 	pxd_t s_xfsckpxd;	/* 8: extendfs fsckpxd */
2337c478bd9Sstevel@tonic-gate 	pxd_t s_xlogpxd;	/* 8: extendfs logpxd */
2347c478bd9Sstevel@tonic-gate 	/* - 128 byte boundary - */
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 	/*
2377c478bd9Sstevel@tonic-gate 	 *      DFS VFS support (preliminary)
2387c478bd9Sstevel@tonic-gate 	 */
2397c478bd9Sstevel@tonic-gate 	char s_attach;		/* 1: VFS: flag: set when aggregate is attached
2407c478bd9Sstevel@tonic-gate 				 */
2417c478bd9Sstevel@tonic-gate 	u8 rsrvd4[7];		/* 7: reserved - set to 0 */
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate 	u64 totalUsable;	/* 8: VFS: total of 1K blocks which are
2447c478bd9Sstevel@tonic-gate 				 * available to "normal" (non-root) users.
2457c478bd9Sstevel@tonic-gate 				 */
2467c478bd9Sstevel@tonic-gate 	u64 minFree;		/* 8: VFS: # of 1K blocks held in reserve for
2477c478bd9Sstevel@tonic-gate 				 * exclusive use of root.  This value can be 0,
2487c478bd9Sstevel@tonic-gate 				 * and if it is then totalUsable will be equal
2497c478bd9Sstevel@tonic-gate 				 * to # of blocks in aggregate.  I believe this
2507c478bd9Sstevel@tonic-gate 				 * means that minFree + totalUsable = # blocks.
2517c478bd9Sstevel@tonic-gate 				 * In that case, we don't need to store both
2527c478bd9Sstevel@tonic-gate 				 * totalUsable and minFree since we can compute
2537c478bd9Sstevel@tonic-gate 				 * one from the other.  I would guess minFree
2547c478bd9Sstevel@tonic-gate 				 * would be the one we should store, and
2557c478bd9Sstevel@tonic-gate 				 * totalUsable would be the one we should
2567c478bd9Sstevel@tonic-gate 				 * compute.  (Just a guess...)
2577c478bd9Sstevel@tonic-gate 				 */
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate 	u64 realFree;		/* 8: VFS: # of free 1K blocks can be used by
2607c478bd9Sstevel@tonic-gate 				 * "normal" users.  It may be this is something
2617c478bd9Sstevel@tonic-gate 				 * we should compute when asked for instead of
2627c478bd9Sstevel@tonic-gate 				 * storing in the superblock.  I don't know how
2637c478bd9Sstevel@tonic-gate 				 * often this information is needed.
2647c478bd9Sstevel@tonic-gate 				 */
2657c478bd9Sstevel@tonic-gate 	/*
2667c478bd9Sstevel@tonic-gate 	 *      graffiti area
2677c478bd9Sstevel@tonic-gate 	 */
2687c478bd9Sstevel@tonic-gate };
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate /* from jfs_dtree.h */
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  *      entry segment/slot
2747c478bd9Sstevel@tonic-gate  *
2757c478bd9Sstevel@tonic-gate  * an entry consists of type dependent head/only segment/slot and
2767c478bd9Sstevel@tonic-gate  * additional segments/slots linked vi next field;
2777c478bd9Sstevel@tonic-gate  * N.B. last/only segment of entry is terminated by next = -1;
2787c478bd9Sstevel@tonic-gate  */
2797c478bd9Sstevel@tonic-gate /*
2807c478bd9Sstevel@tonic-gate  *	directory page slot
2817c478bd9Sstevel@tonic-gate  */
2827c478bd9Sstevel@tonic-gate typedef struct {
2837c478bd9Sstevel@tonic-gate 	s8 next;		/* 1: */
2847c478bd9Sstevel@tonic-gate 	s8 cnt;			/* 1: */
2857c478bd9Sstevel@tonic-gate 	UniChar name[15];	/* 30: */
2867c478bd9Sstevel@tonic-gate } dtslot_t;			/* (32) */
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate #define DTSLOTDATALEN	15
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate /*
2917c478bd9Sstevel@tonic-gate  *	 internal node entry head/only segment
2927c478bd9Sstevel@tonic-gate  */
2937c478bd9Sstevel@tonic-gate typedef struct {
2947c478bd9Sstevel@tonic-gate 	pxd_t xd;		/* 8: child extent descriptor */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	s8 next;		/* 1: */
2977c478bd9Sstevel@tonic-gate 	u8 namlen;		/* 1: */
2987c478bd9Sstevel@tonic-gate 	UniChar name[11];	/* 22: 2-byte aligned */
2997c478bd9Sstevel@tonic-gate } idtentry_t;			/* (32) */
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate /*
3027c478bd9Sstevel@tonic-gate  *	leaf node entry head/only segment
3037c478bd9Sstevel@tonic-gate  *
3047c478bd9Sstevel@tonic-gate  * 	For legacy filesystems, name contains 13 unichars -- no index field
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate typedef struct {
3077c478bd9Sstevel@tonic-gate 	u32 inumber;		/* 4: 4-byte aligned */
3087c478bd9Sstevel@tonic-gate 	s8 next;		/* 1: */
3097c478bd9Sstevel@tonic-gate 	u8 namlen;		/* 1: */
3107c478bd9Sstevel@tonic-gate 	UniChar name[11];	/* 22: 2-byte aligned */
3117c478bd9Sstevel@tonic-gate 	u32 index;		/* 4: index into dir_table */
3127c478bd9Sstevel@tonic-gate } ldtentry_t;			/* (32) */
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #define DTLHDRDATALEN	11
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * dir_table used for directory traversal during readdir
3187c478bd9Sstevel@tonic-gate */
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate /*
3217c478bd9Sstevel@tonic-gate  * Maximum entry in inline directory table
3227c478bd9Sstevel@tonic-gate  */
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate typedef struct dir_table_slot {
3257c478bd9Sstevel@tonic-gate 	u8 rsrvd;	/* 1: */
3267c478bd9Sstevel@tonic-gate 	u8 flag;	/* 1: 0 if free */
3277c478bd9Sstevel@tonic-gate 	u8 slot;	/* 1: slot within leaf page of entry */
3287c478bd9Sstevel@tonic-gate 	u8 addr1;	/* 1: upper 8 bits of leaf page address */
3297c478bd9Sstevel@tonic-gate 	u32 addr2;	/* 4: lower 32 bits of leaf page address -OR-
3307c478bd9Sstevel@tonic-gate 			      index of next entry when this entry was deleted */
3317c478bd9Sstevel@tonic-gate } dir_table_slot_t;	/* (8) */
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate  *	directory root page (in-line in on-disk inode):
3357c478bd9Sstevel@tonic-gate  *
3367c478bd9Sstevel@tonic-gate  * cf. dtpage_t below.
3377c478bd9Sstevel@tonic-gate  */
3387c478bd9Sstevel@tonic-gate typedef union {
3397c478bd9Sstevel@tonic-gate 	struct {
3407c478bd9Sstevel@tonic-gate 		dasd_t DASD;	/* 16: DASD limit/usage info  F226941 */
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate 		u8 flag;	/* 1: */
3437c478bd9Sstevel@tonic-gate 		s8 nextindex;	/* 1: next free entry in stbl */
3447c478bd9Sstevel@tonic-gate 		s8 freecnt;	/* 1: free count */
3457c478bd9Sstevel@tonic-gate 		s8 freelist;	/* 1: freelist header */
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate 		u32 idotdot;	/* 4: parent inode number */
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 		s8 stbl[8];	/* 8: sorted entry index table */
3507c478bd9Sstevel@tonic-gate 	} header;		/* (32) */
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate 	dtslot_t slot[9];
3537c478bd9Sstevel@tonic-gate } dtroot_t;
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate /*
3567c478bd9Sstevel@tonic-gate  *	directory regular page:
3577c478bd9Sstevel@tonic-gate  *
3587c478bd9Sstevel@tonic-gate  *	entry slot array of 32 byte slot
3597c478bd9Sstevel@tonic-gate  *
3607c478bd9Sstevel@tonic-gate  * sorted entry slot index table (stbl):
3617c478bd9Sstevel@tonic-gate  * contiguous slots at slot specified by stblindex,
3627c478bd9Sstevel@tonic-gate  * 1-byte per entry
3637c478bd9Sstevel@tonic-gate  *   512 byte block:  16 entry tbl (1 slot)
3647c478bd9Sstevel@tonic-gate  *  1024 byte block:  32 entry tbl (1 slot)
3657c478bd9Sstevel@tonic-gate  *  2048 byte block:  64 entry tbl (2 slot)
3667c478bd9Sstevel@tonic-gate  *  4096 byte block: 128 entry tbl (4 slot)
3677c478bd9Sstevel@tonic-gate  *
3687c478bd9Sstevel@tonic-gate  * data area:
3697c478bd9Sstevel@tonic-gate  *   512 byte block:  16 - 2 =  14 slot
3707c478bd9Sstevel@tonic-gate  *  1024 byte block:  32 - 2 =  30 slot
3717c478bd9Sstevel@tonic-gate  *  2048 byte block:  64 - 3 =  61 slot
3727c478bd9Sstevel@tonic-gate  *  4096 byte block: 128 - 5 = 123 slot
3737c478bd9Sstevel@tonic-gate  *
3747c478bd9Sstevel@tonic-gate  * N.B. index is 0-based; index fields refer to slot index
3757c478bd9Sstevel@tonic-gate  * except nextindex which refers to entry index in stbl;
3767c478bd9Sstevel@tonic-gate  * end of entry stot list or freelist is marked with -1.
3777c478bd9Sstevel@tonic-gate  */
3787c478bd9Sstevel@tonic-gate typedef union {
3797c478bd9Sstevel@tonic-gate 	struct {
3807c478bd9Sstevel@tonic-gate 		s64 next;	/* 8: next sibling */
3817c478bd9Sstevel@tonic-gate 		s64 prev;	/* 8: previous sibling */
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate 		u8 flag;	/* 1: */
3847c478bd9Sstevel@tonic-gate 		s8 nextindex;	/* 1: next entry index in stbl */
3857c478bd9Sstevel@tonic-gate 		s8 freecnt;	/* 1: */
3867c478bd9Sstevel@tonic-gate 		s8 freelist;	/* 1: slot index of head of freelist */
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate 		u8 maxslot;	/* 1: number of slots in page slot[] */
3897c478bd9Sstevel@tonic-gate 		s8 stblindex;	/* 1: slot index of start of stbl */
3907c478bd9Sstevel@tonic-gate 		u8 rsrvd[2];	/* 2: */
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 		pxd_t self;	/* 8: self pxd */
3937c478bd9Sstevel@tonic-gate 	} header;		/* (32) */
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate 	dtslot_t slot[128];
3967c478bd9Sstevel@tonic-gate } dtpage_t;
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate /* from jfs_xtree.h */
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate /*
4017c478bd9Sstevel@tonic-gate  *      extent allocation descriptor (xad)
4027c478bd9Sstevel@tonic-gate  */
4037c478bd9Sstevel@tonic-gate typedef struct xad {
4047c478bd9Sstevel@tonic-gate 	unsigned flag:8;	/* 1: flag */
4057c478bd9Sstevel@tonic-gate 	unsigned rsvrd:16;	/* 2: reserved */
4067c478bd9Sstevel@tonic-gate 	unsigned off1:8;	/* 1: offset in unit of fsblksize */
4077c478bd9Sstevel@tonic-gate 	u32 off2;		/* 4: offset in unit of fsblksize */
4087c478bd9Sstevel@tonic-gate 	unsigned len:24;	/* 3: length in unit of fsblksize */
4097c478bd9Sstevel@tonic-gate 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
4107c478bd9Sstevel@tonic-gate 	u32 addr2;		/* 4: address in unit of fsblksize */
4117c478bd9Sstevel@tonic-gate } xad_t;			/* (16) */
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate /* xad_t field extraction */
4147c478bd9Sstevel@tonic-gate #define offsetXAD(xad)	(((s64)((xad)->off1)) << 32 | ((xad)->off2))
4157c478bd9Sstevel@tonic-gate #define addressXAD(xad)	(((s64)((xad)->addr1)) << 32 | ((xad)->addr2))
4167c478bd9Sstevel@tonic-gate #define lengthXAD(xad)	((xad)->len)
4177c478bd9Sstevel@tonic-gate 
4187c478bd9Sstevel@tonic-gate /* possible values for maxentry */
4197c478bd9Sstevel@tonic-gate #define XTPAGEMAXSLOT   256
4207c478bd9Sstevel@tonic-gate #define XTENTRYSTART    2
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate /*
4237c478bd9Sstevel@tonic-gate  *      xtree page:
4247c478bd9Sstevel@tonic-gate  */
4257c478bd9Sstevel@tonic-gate typedef union {
4267c478bd9Sstevel@tonic-gate 	struct xtheader {
4277c478bd9Sstevel@tonic-gate 		s64 next;	/* 8: */
4287c478bd9Sstevel@tonic-gate 		s64 prev;	/* 8: */
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate 		u8 flag;	/* 1: */
4317c478bd9Sstevel@tonic-gate 		u8 rsrvd1;	/* 1: */
4327c478bd9Sstevel@tonic-gate 		s16 nextindex;	/* 2: next index = number of entries */
4337c478bd9Sstevel@tonic-gate 		s16 maxentry;	/* 2: max number of entries */
4347c478bd9Sstevel@tonic-gate 		s16 rsrvd2;	/* 2: */
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate 		pxd_t self;	/* 8: self */
4377c478bd9Sstevel@tonic-gate 	} header;		/* (32) */
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate 	xad_t xad[XTPAGEMAXSLOT];	/* 16 * maxentry: xad array */
4407c478bd9Sstevel@tonic-gate } xtpage_t;
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate /* from jfs_dinode.h */
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate struct dinode {
4457c478bd9Sstevel@tonic-gate 	/*
4467c478bd9Sstevel@tonic-gate 	 *      I. base area (128 bytes)
4477c478bd9Sstevel@tonic-gate 	 *      ------------------------
4487c478bd9Sstevel@tonic-gate 	 *
4497c478bd9Sstevel@tonic-gate 	 * define generic/POSIX attributes
4507c478bd9Sstevel@tonic-gate 	 */
4517c478bd9Sstevel@tonic-gate 	u32 di_inostamp;	/* 4: stamp to show inode belongs to fileset */
4527c478bd9Sstevel@tonic-gate 	s32 di_fileset;		/* 4: fileset number */
4537c478bd9Sstevel@tonic-gate 	u32 di_number;		/* 4: inode number, aka file serial number */
4547c478bd9Sstevel@tonic-gate 	u32 di_gen;		/* 4: inode generation number */
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate 	pxd_t di_ixpxd;		/* 8: inode extent descriptor */
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate 	s64 di_size;		/* 8: size */
4597c478bd9Sstevel@tonic-gate 	s64 di_nblocks;		/* 8: number of blocks allocated */
4607c478bd9Sstevel@tonic-gate 
4617c478bd9Sstevel@tonic-gate 	u32 di_nlink;		/* 4: number of links to the object */
4627c478bd9Sstevel@tonic-gate 
4637c478bd9Sstevel@tonic-gate 	u32 di_uid;		/* 4: user id of owner */
4647c478bd9Sstevel@tonic-gate 	u32 di_gid;		/* 4: group id of owner */
4657c478bd9Sstevel@tonic-gate 
4667c478bd9Sstevel@tonic-gate 	u32 di_mode;		/* 4: attribute, format and permission */
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate 	struct timestruc_t di_atime;	/* 8: time last data accessed */
4697c478bd9Sstevel@tonic-gate 	struct timestruc_t di_ctime;	/* 8: time last status changed */
4707c478bd9Sstevel@tonic-gate 	struct timestruc_t di_mtime;	/* 8: time last data modified */
4717c478bd9Sstevel@tonic-gate 	struct timestruc_t di_otime;	/* 8: time created */
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate 	dxd_t di_acl;		/* 16: acl descriptor */
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate 	dxd_t di_ea;		/* 16: ea descriptor */
4767c478bd9Sstevel@tonic-gate 
4777c478bd9Sstevel@tonic-gate 	s32 di_next_index;  /* 4: Next available dir_table index */
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate 	s32 di_acltype;		/* 4: Type of ACL */
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate 	/*
4827c478bd9Sstevel@tonic-gate 	 * 	Extension Areas.
4837c478bd9Sstevel@tonic-gate 	 *
4847c478bd9Sstevel@tonic-gate 	 *	Historically, the inode was partitioned into 4 128-byte areas,
4857c478bd9Sstevel@tonic-gate 	 *	the last 3 being defined as unions which could have multiple
4867c478bd9Sstevel@tonic-gate 	 *	uses.  The first 96 bytes had been completely unused until
4877c478bd9Sstevel@tonic-gate 	 *	an index table was added to the directory.  It is now more
4887c478bd9Sstevel@tonic-gate 	 *	useful to describe the last 3/4 of the inode as a single
4897c478bd9Sstevel@tonic-gate 	 *	union.  We would probably be better off redesigning the
4907c478bd9Sstevel@tonic-gate 	 *	entire structure from scratch, but we don't want to break
4917c478bd9Sstevel@tonic-gate 	 *	commonality with OS/2's JFS at this time.
4927c478bd9Sstevel@tonic-gate 	 */
4937c478bd9Sstevel@tonic-gate 	union {
4947c478bd9Sstevel@tonic-gate 		struct {
4957c478bd9Sstevel@tonic-gate 			/*
4967c478bd9Sstevel@tonic-gate 			 * This table contains the information needed to
4977c478bd9Sstevel@tonic-gate 			 * find a directory entry from a 32-bit index.
4987c478bd9Sstevel@tonic-gate 			 * If the index is small enough, the table is inline,
4997c478bd9Sstevel@tonic-gate 			 * otherwise, an x-tree root overlays this table
5007c478bd9Sstevel@tonic-gate 			 */
5017c478bd9Sstevel@tonic-gate 			dir_table_slot_t _table[12];	/* 96: inline */
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate 			dtroot_t _dtroot;		/* 288: dtree root */
5047c478bd9Sstevel@tonic-gate 		} _dir;					/* (384) */
5057c478bd9Sstevel@tonic-gate #define di_dirtable	u._dir._table
5067c478bd9Sstevel@tonic-gate #define di_dtroot	u._dir._dtroot
5077c478bd9Sstevel@tonic-gate #define di_parent       di_dtroot.header.idotdot
5087c478bd9Sstevel@tonic-gate #define di_DASD		di_dtroot.header.DASD
5097c478bd9Sstevel@tonic-gate 
5107c478bd9Sstevel@tonic-gate 		struct {
5117c478bd9Sstevel@tonic-gate 			union {
5127c478bd9Sstevel@tonic-gate 				u8 _data[96];		/* 96: unused */
5137c478bd9Sstevel@tonic-gate 				struct {
5147c478bd9Sstevel@tonic-gate 					void *_imap;	/* 4: unused */
5157c478bd9Sstevel@tonic-gate 					u32 _gengen;	/* 4: generator */
5167c478bd9Sstevel@tonic-gate 				} _imap;
5177c478bd9Sstevel@tonic-gate 			} _u1;				/* 96: */
5187c478bd9Sstevel@tonic-gate #define di_gengen	u._file._u1._imap._gengen
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate 			union {
5217c478bd9Sstevel@tonic-gate 				xtpage_t _xtroot;
5227c478bd9Sstevel@tonic-gate 				struct {
5237c478bd9Sstevel@tonic-gate 					u8 unused[16];	/* 16: */
5247c478bd9Sstevel@tonic-gate 					dxd_t _dxd;	/* 16: */
5257c478bd9Sstevel@tonic-gate 					union {
5267c478bd9Sstevel@tonic-gate 						u32 _rdev;	/* 4: */
5277c478bd9Sstevel@tonic-gate 						u8 _fastsymlink[128];
5287c478bd9Sstevel@tonic-gate 					} _u;
5297c478bd9Sstevel@tonic-gate 					u8 _inlineea[128];
5307c478bd9Sstevel@tonic-gate 				} _special;
5317c478bd9Sstevel@tonic-gate 			} _u2;
5327c478bd9Sstevel@tonic-gate 		} _file;
5337c478bd9Sstevel@tonic-gate #define di_xtroot	u._file._u2._xtroot
5347c478bd9Sstevel@tonic-gate #define di_dxd		u._file._u2._special._dxd
5357c478bd9Sstevel@tonic-gate #define di_btroot	di_xtroot
5367c478bd9Sstevel@tonic-gate #define di_inlinedata	u._file._u2._special._u
5377c478bd9Sstevel@tonic-gate #define di_rdev		u._file._u2._special._u._rdev
5387c478bd9Sstevel@tonic-gate #define di_fastsymlink	u._file._u2._special._u._fastsymlink
5397c478bd9Sstevel@tonic-gate #define di_inlineea     u._file._u2._special._inlineea
5407c478bd9Sstevel@tonic-gate 	} u;
5417c478bd9Sstevel@tonic-gate };
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate typedef struct dinode dinode_t;
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate /* di_mode */
5467c478bd9Sstevel@tonic-gate #define IFMT	0xF000		/* S_IFMT - mask of file type */
5477c478bd9Sstevel@tonic-gate #define IFDIR	0x4000		/* S_IFDIR - directory */
5487c478bd9Sstevel@tonic-gate #define IFREG	0x8000		/* S_IFREG - regular file */
5497c478bd9Sstevel@tonic-gate #define IFLNK	0xA000		/* S_IFLNK - symbolic link */
5507c478bd9Sstevel@tonic-gate 
5517c478bd9Sstevel@tonic-gate /* extended mode bits (on-disk inode di_mode) */
5527c478bd9Sstevel@tonic-gate #define INLINEEA        0x00040000	/* inline EA area free */
5537c478bd9Sstevel@tonic-gate 
5547c478bd9Sstevel@tonic-gate /* from jfs_imap.h */
5557c478bd9Sstevel@tonic-gate 
5567c478bd9Sstevel@tonic-gate #define	EXTSPERIAG	128	/* number of disk inode extent per iag  */
5577c478bd9Sstevel@tonic-gate #define SMAPSZ		4	/* number of words per summary map      */
5587c478bd9Sstevel@tonic-gate #define	MAXAG		128	/* maximum number of allocation groups  */
5597c478bd9Sstevel@tonic-gate 
5607c478bd9Sstevel@tonic-gate /*
5617c478bd9Sstevel@tonic-gate  *	inode allocation map:
5627c478bd9Sstevel@tonic-gate  *
5637c478bd9Sstevel@tonic-gate  * inode allocation map consists of
5647c478bd9Sstevel@tonic-gate  * . the inode map control page and
5657c478bd9Sstevel@tonic-gate  * . inode allocation group pages (per 4096 inodes)
5667c478bd9Sstevel@tonic-gate  * which are addressed by standard JFS xtree.
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate /*
5697c478bd9Sstevel@tonic-gate  *	inode allocation group page (per 4096 inodes of an AG)
5707c478bd9Sstevel@tonic-gate  */
5717c478bd9Sstevel@tonic-gate typedef struct {
5727c478bd9Sstevel@tonic-gate 	s64 agstart;		/* 8: starting block of ag              */
5737c478bd9Sstevel@tonic-gate 	s32 iagnum;		/* 4: inode allocation group number     */
5747c478bd9Sstevel@tonic-gate 	s32 inofreefwd;		/* 4: ag inode free list forward        */
5757c478bd9Sstevel@tonic-gate 	s32 inofreeback;	/* 4: ag inode free list back           */
5767c478bd9Sstevel@tonic-gate 	s32 extfreefwd;		/* 4: ag inode extent free list forward */
5777c478bd9Sstevel@tonic-gate 	s32 extfreeback;	/* 4: ag inode extent free list back    */
5787c478bd9Sstevel@tonic-gate 	s32 iagfree;		/* 4: iag free list                     */
5797c478bd9Sstevel@tonic-gate 
5807c478bd9Sstevel@tonic-gate 	/* summary map: 1 bit per inode extent */
5817c478bd9Sstevel@tonic-gate 	s32 inosmap[SMAPSZ];	/* 16: sum map of mapwords w/ free inodes;
5827c478bd9Sstevel@tonic-gate 				 *      note: this indicates free and backed
5837c478bd9Sstevel@tonic-gate 				 *      inodes, if the extent is not backed the
5847c478bd9Sstevel@tonic-gate 				 *      value will be 1.  if the extent is
5857c478bd9Sstevel@tonic-gate 				 *      backed but all inodes are being used the
5867c478bd9Sstevel@tonic-gate 				 *      value will be 1.  if the extent is
5877c478bd9Sstevel@tonic-gate 				 *      backed but at least one of the inodes is
5887c478bd9Sstevel@tonic-gate 				 *      free the value will be 0.
5897c478bd9Sstevel@tonic-gate 				 */
5907c478bd9Sstevel@tonic-gate 	s32 extsmap[SMAPSZ];	/* 16: sum map of mapwords w/ free extents */
5917c478bd9Sstevel@tonic-gate 	s32 nfreeinos;		/* 4: number of free inodes             */
5927c478bd9Sstevel@tonic-gate 	s32 nfreeexts;		/* 4: number of free extents            */
5937c478bd9Sstevel@tonic-gate 	/* (72) */
5947c478bd9Sstevel@tonic-gate 	u8 pad[1976];		/* 1976: pad to 2048 bytes */
5957c478bd9Sstevel@tonic-gate 	/* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */
5967c478bd9Sstevel@tonic-gate 	u32 wmap[EXTSPERIAG];	/* 512: working allocation map  */
5977c478bd9Sstevel@tonic-gate 	u32 pmap[EXTSPERIAG];	/* 512: persistent allocation map */
5987c478bd9Sstevel@tonic-gate 	pxd_t inoext[EXTSPERIAG];	/* 1024: inode extent addresses */
5997c478bd9Sstevel@tonic-gate } iag_t;			/* (4096) */
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate #endif /* _JFS_H_ */
602