/* <vms/lib/scbdef.h>
 *
 *	F11DEF - storage control block for ODS level 2	[not in Starlet]
 */
#ifndef _SCBDEF_H
#define _SCBDEF_H

/*
   Format of storage control block, Files-11 Structure Level 2
 */
#define SCB$C_LEVEL2	512	/* 1000 octal = structure level 2 */
#define SCB$V_MAPDIRTY	0
#define SCB$V_MAPALLOC	1
#define SCB$V_FILALLOC	2
#define SCB$V_QUODIRTY	3
#define SCB$V_HDRWRITE	4
#define SCB$V_CORRUPT	5
#define SCB$M_MAPDIRTY	(1<<SCB$V_MAPDIRTY)	/* 0x01 */
#define SCB$M_MAPALLOC	(1<<SCB$V_MAPALLOC)	/* 0x02 */
#define SCB$M_FILALLOC	(1<<SCB$V_FILALLOC)	/* 0x04 */
#define SCB$M_QUODIRTY	(1<<SCB$V_QUODIRTY)	/* 0x08 */
#define SCB$M_HDRWRITE	(1<<SCB$V_HDRWRITE)	/* 0x10 */
#define SCB$M_CORRUPT	(1<<SCB$V_CORRUPT)	/* 0x20 */
#define SCB$V_MAPDIRTY2 0
#define SCB$V_MAPALLOC2 1
#define SCB$V_FILALLOC2 2
#define SCB$V_QUODIRTY2 3
#define SCB$V_HDRWRITE2 4
#define SCB$V_CORRUPT2	5
#define SCB$M_MAPDIRTY2 (1<<SCB$V_MAPDIRTY2)	/* 0x01 */
#define SCB$M_MAPALLOC2 (1<<SCB$V_MAPALLOC2)	/* 0x02 */
#define SCB$M_FILALLOC2 (1<<SCB$V_FILALLOC2)	/* 0x04 */
#define SCB$M_QUODIRTY2 (1<<SCB$V_QUODIRTY2)	/* 0x08 */
#define SCB$M_HDRWRITE2 (1<<SCB$V_HDRWRITE2)	/* 0x10 */
#define SCB$M_CORRUPT2	(1<<SCB$V_CORRUPT2)	/* 0x20 */
#define SCB$V_NORMAL	0
#define SCB$V_NEW	1
#define SCB$V_REBLDNG	2
#define SCB$V_VERIFY	3
#define SCB$V_MVBEGUN	4
#define SCB$V_COPYING	5
#define SCB$V_MERGING	6
#define SCB$V_MINIMRG	7
#define SCB$V_CPY_RESET 8
#define SCB$V_BOOTING	9
#define SCB$V_WLG	10
#define SCB$V_INVWLG	11
#define SCB$V_FAILED	15
#define SCB$M_NORMAL	(1<<SCB$V_NORMAL)	/* 0x01 */
#define SCB$M_NEW	(1<<SCB$V_NEW)		/* 0x02 */
#define SCB$M_REBLDNG	(1<<SCB$V_REBLDNG)	/* 0x04 */
#define SCB$M_VERIFY	(1<<SCB$V_VERIFY)	/* 0x08 */
#define SCB$M_MVBEGUN	(1<<SCB$V_MVBEGUN)	/* 0x10 */
#define SCB$M_COPYING	(1<<SCB$V_COPYING)	/* 0x20 */
#define SCB$M_MERGING	(1<<SCB$V_MERGING)	/* 0x40 */
#define SCB$M_MINIMRG	(1<<SCB$V_MINIMRG)	/* 0x80 */
#define SCB$M_CPY_RESET (1<<SCB$V_CPY_RESET)	/* 0x0100 */
#define SCB$M_BOOTING	(1<<SCB$V_BOOTING)	/* 0x0200 */
#define SCB$M_WLG	(1<<SCB$V_WLG)		/* 0x0400 */
#define SCB$M_INVWLG	(1<<SCB$V_INVWLG)	/* 0x0800 */
#define SCB$M_FAILED	(1<<SCB$V_FAILED)	/* 0x8000 */
#define SCB$V_MBR_FCPY	0
#define SCB$V_MBR_MERGE 1
#define SCB$V_MBR_CIP	2
#define SCB$V_MBR_MASTER 3
#define SCB$V_MBR_ERROR 4
#define SCB$V_MBR_SRC	5
#define SCB$V_MBR_DCD	6
#define SCB$V_MBR_VALID 7
#define SCB$M_MBR_FCPY	(1<<SCB$V_MBR_FCPY)	/* 0x01 */
#define SCB$M_MBR_MERGE (1<<SCB$V_MBR_MERGE)	/* 0x02 */
#define SCB$M_MBR_CIP	(1<<SCB$V_MBR_CIP)	/* 0x04 */
#define SCB$M_MBR_MASTER (1<<SCB$V_MBR_MASTER)	/* 0x08 */
#define SCB$M_MBR_ERROR (1<<SCB$V_MBR_ERROR)	/* 0x10 */
#define SCB$M_MBR_SRC	(1<<SCB$V_MBR_SRC)	/* 0x20 */
#define SCB$M_MBR_DCD	(1<<SCB$V_MBR_DCD)	/* 0x40 */
#define SCB$M_MBR_VALID (1<<SCB$V_MBR_VALID)	/* 0x80 */

#define SCB$S_VOLOCKNAME 12
#define SCB$S_MOUNTTIME 8
#define SCB$S_GENERNUM	8
#define SCB$S_UNIT_ID	8
#define SCB$K_MAXMBRS	3	/* #maxmbrs [not a public symbol] */
#define SCB$S_MBRSIZ	8	/* #mbrsiz  [not a public symbol] */
#define SCB$S_MEMBER_IDS 24	/*(maxmbrs * mbrsiz)*/

#define SCB$K_LENGTH	512	/* length of Structure */
#define SCB$C_LENGTH	512
#define SCB$S_SCBDEF	512
struct scbdef {
    union {
	unsigned short scb$w_struclev;	/* file structure level */
	struct {
	    unsigned char scb$b_strucver; /* file structure version */
	    unsigned char scb$b_struclev; /* principal file structure level */
	} scb$r_struclev_fields;
    } scb$r_struclev_overlay;
    unsigned short scb$w_cluster;	/* storage map cluster factor */
    unsigned long scb$l_volsize;	/* volume size in logical blocks */
    unsigned long scb$l_blksize;	/* number of physical blocks per logical block */
    unsigned long scb$l_sectors;	/* number of sectors per track */
    unsigned long scb$l_tracks;		/* number of tracks per cylinder */
    unsigned long scb$l_cylinder;	/* number of cylinders */
    union {
	unsigned long scb$l_status;	/* volume status flags */
	struct {
	    unsigned scb$v_mapdirty : 1; /* storage map is dirty (partially updated) */
	    unsigned scb$v_mapalloc : 1; /* storage map is preallocated (lost blocks) */
	    unsigned scb$v_filalloc : 1; /* file numbers are preallocated (lost header slots) */
	    unsigned scb$v_quodirty : 1; /* quota file is dirty (partially updated) */
	    unsigned scb$v_hdrwrite : 1; /* file headers are write back cached */
	    unsigned scb$v_corrupt  : 1; /* file structure is corrupt */
	    unsigned		    : 26; /* padding */
	} scb$r_status_bits;
    } scb$r_status_overlay;
    union {
	unsigned long scb$l_status2;	/* backup status - bits must match those above */
	struct {
	    unsigned scb$v_mapdirty2 : 1; /* storage map is dirty (partially updated) */
	    unsigned scb$v_mapalloc2 : 1; /* storage map is preallocated (lost blocks) */
	    unsigned scb$v_filalloc2 : 1; /* file numbers are preallocated (lost header slots) */
	    unsigned scb$v_quodirty2 : 1; /* quota file is dirty (partially updated) */
	    unsigned scb$v_hdrwrite2 : 1; /* file headers are write back cached */
	    unsigned scb$v_corrupt2  : 1; /* file structure is corrupt */
	    unsigned		     : 26; /* padding */
	} scb$r_status2_bits;
    } scb$r_status2_overlay;
    unsigned short scb$w_writecnt;	/* count of write access mounters. */
    char scb$t_volockname[12];		/* name used for file system serialization on volume. */
    long scb$q_mounttime[2];		/* time of last initial mount. */
    unsigned short scb$w_backrev;	/* BACKUP revision number. */
    long scb$q_genernum[2];		/* shadow set revision number. */
    long scb$q_unit_id[2];		/* virtual Unit specifier */
    union {
	unsigned short scb$w_shadow_status; /* volume status: */
	unsigned short scb$w_status;	/* duplicate pointer to top */
	struct {
	    unsigned scb$v_normal     : 1; /* shadow set populated and online */
	    unsigned scb$v_new	      : 1; /* newly created, no members yet */
	    unsigned scb$v_rebldng    : 1; /* rebuilding shadow set */
	    unsigned scb$v_verify     : 1; /* this SS needs verification */
	    unsigned scb$v_mvbegun    : 1; /* mount verification initiated */
	    unsigned scb$v_copying    : 1; /* full copy in progreess */
	    unsigned scb$v_merging    : 1; /* merge copy in progress */
	    unsigned scb$v_minimrg    : 1; /* mini-merge in progress */
	    unsigned scb$v_cpy_reset  : 1; /* copy mode is reset. */
	    unsigned scb$v_booting    : 1; /* shadow set in booting state */
	    unsigned scb$v_wlg	      : 1; /* write logging */
	    unsigned scb$v_invwlg     : 1; /* invalid write logging */
	    unsigned		      : 3; /* filler */
	    unsigned scb$v_failed     : 1; /* shadow set not populated */
	} scb$r_shadow_status_bits;
    } scb$r_shadow_status_overlay;
    union {
	unsigned char scb$b_member_status; /* member status bytes */
	struct {
	    unsigned scb$v_mbr_fcpy   : 1; /* member involved in copy */
	    unsigned scb$v_mbr_merge  : 1; /* member being merged */
	    unsigned scb$v_mbr_cip    : 1; /* copy (or merge) in progress */
	    unsigned scb$v_mbr_master : 1; /* member with guaranteed correct */
					   /*  SCB; same member as MEMBERSHIP_LOCK */
	    unsigned scb$v_mbr_error  : 1; /* Error processing in progress */
	    unsigned scb$v_mbr_src    : 1; /* member can be used for source */
	    unsigned scb$v_mbr_dcd    : 1; /* assisted copy source */
	    unsigned scb$v_mbr_valid  : 1; /* status information is valid */
	} scb$r_member_status_bits;
    }  scb$r_member_status_overlay[3];
    unsigned	: 8, : 8, : 8;		/* char fill[3]; reserved for alignment */
    struct {
	long scb_q_member_id[2];	/* unit ID for member */
    }  scb$q_member_ids[3];
    unsigned long scb$l_scb_lbn;	/* unit Control Block for VU */
    unsigned char scb$b_devices;	/* number of devices in SS */
    unsigned char scb$b_members;	/* number of full members */
    unsigned char scb$b_mast_indx;	/* array index to master UCB */
    unsigned char scb$b_mrg_targets;	/* merge Copy Targets */
    unsigned char scb$b_fc_targets;	/* full Copy Targets */
    char scbdef$$_fill[397];		/* padd remainder of block */
    unsigned short scb$w_checksum;	/* block checksum */
};

#endif	/*_SCBDEF_H*/
