/* <vms/lib/vcbdef.h>
 *
 *	LIB - volume control block definitions		[not in Starlet]
 */
#ifndef _VCBDEF_H
#define _VCBDEF_H

#define VCB$V_WRITE_IF	0
#define VCB$V_WRITE_SM	1
#define VCB$V_HOMBLKBAD 2
#define VCB$V_IDXHDRBAD 3
#define VCB$V_NOALLOC	4
#define VCB$V_EXTFID	5
#define VCB$V_GROUP	6
#define VCB$V_SYSTEM	7
#define VCB$M_WRITE_IF	(1<<VCB$V_WRITE_IF)	/* 0x01 */
#define VCB$M_WRITE_SM	(1<<VCB$V_WRITE_SM)	/* 0x02 */
#define VCB$M_HOMBLKBAD (1<<VCB$V_HOMBLKBAD)	/* 0x04 */
#define VCB$M_IDXHDRBAD (1<<VCB$V_IDXHDRBAD)	/* 0x08 */
#define VCB$M_NOALLOC	(1<<VCB$V_NOALLOC)	/* 0x10 */
#define VCB$M_EXTFID	(1<<VCB$V_EXTFID)	/* 0x20 */
#define VCB$M_GROUP	(1<<VCB$V_GROUP)	/* 0x40 */
#define VCB$M_SYSTEM	(1<<VCB$V_SYSTEM)	/* 0x80 */
#ifndef NO_VMS_V6
#define VCB$V_HIGH_SIERRA 0
#define VCB$V_NOSWITCH	  1
#define VCB$V_DSI	  2
#define VCB$V_XAR	  3
#define VCB$M_HIGH_SIERRA (1<<VCB$V_HIGH_SIERRA)	/* 0x01 */
#define VCB$M_NOSWITCH	  (1<<VCB$V_NOSWITCH)		/* 0x02 */
#define VCB$M_DSI	  (1<<VCB$V_DSI)		/* 0x04 */
#define VCB$M_XAR	  (1<<VCB$V_XAR)		/* 0x08 */
#endif
#define VCB$V_PARTFILE	0
#define VCB$V_LOGICEOVS 1
#define VCB$V_WAIMOUVOL 2
#define VCB$V_WAIREWIND 3
#define VCB$V_WAIUSRLBL 4
#define VCB$V_CANCELIO	5
#define VCB$V_MUSTCLOSE 6
#define VCB$V_NOWRITE	7
#define VCB$M_PARTFILE	(1<<VCB$V_PARTFILE)	/* 0x01 */
#define VCB$M_LOGICEOVS (1<<VCB$V_LOGICEOVS)	/* 0x02 */
#define VCB$M_WAIMOUVOL (1<<VCB$V_WAIMOUVOL)	/* 0x04 */
#define VCB$M_WAIREWIND (1<<VCB$V_WAIREWIND)	/* 0x08 */
#define VCB$M_WAIUSRLBL (1<<VCB$V_WAIUSRLBL)	/* 0x10 */
#define VCB$M_CANCELIO	(1<<VCB$V_CANCELIO)	/* 0x20 */
#define VCB$M_MUSTCLOSE (1<<VCB$V_MUSTCLOSE)	/* 0x40 */
#define VCB$M_NOWRITE	(1<<VCB$V_NOWRITE)	/* 0x80 */
#define VCB$V_SHADMAST	0
#define VCB$V_FAILED	1
#define VCB$V_REBLDNG	3
#define VCB$V_BLKASTREC 4
#define VCB$V_MVBEGUN	5
#define VCB$V_ADDING	6
#define VCB$V_PACKACKED 7
#define VCB$M_SHADMAST	(1<<VCB$V_SHADMAST)	/* 0x01 */
#define VCB$M_FAILED	(1<<VCB$V_FAILED)	/* 0x02 */
#define VCB$M_REBLDNG	(1<<VCB$V_REBLDNG)	/* 0x08 */
#define VCB$M_BLKASTREC (1<<VCB$V_BLKASTREC)	/* 0x10 */
#define VCB$M_MVBEGUN	(1<<VCB$V_MVBEGUN)	/* 0x20 */
#define VCB$M_ADDING	(1<<VCB$V_ADDING)	/* 0x40 */
#define VCB$M_PACKACKED (1<<VCB$V_PACKACKED)	/* 0x80 */
#define VCB$V_WRITETHRU 0
#define VCB$V_NOCACHE	1
#define VCB$V_MOUNTVER	2
#define VCB$V_ERASE	3
#define VCB$V_NOHIGHWATER 4
#define VCB$V_NOSHARE	5
#define VCB$V_CLUSLOCK	6
#define VCB$V_SUBSET0	7
#define VCB$M_WRITETHRU (1<<VCB$V_WRITETHRU)	/* 0x01 */
#define VCB$M_NOCACHE	(1<<VCB$V_NOCACHE)	/* 0x02 */
#define VCB$M_MOUNTVER	(1<<VCB$V_MOUNTVER)	/* 0x04 */
#define VCB$M_ERASE	(1<<VCB$V_ERASE)	/* 0x08 */
#define VCB$M_NOHIGHWATER (1<<VCB$V_NOHIGHWATER) /* 0x10 */
#define VCB$M_NOSHARE	(1<<VCB$V_NOSHARE)	/* 0x20 */
#define VCB$M_CLUSLOCK	(1<<VCB$V_CLUSLOCK)	/* 0x40 */
#define VCB$M_SUBSET0	(1<<VCB$V_SUBSET0)	/* 0x80 */

#define VCB$S_VOLNAME	12
#define VCB$S_RETAINMIN 8
#define VCB$S_RETAINMAX 8
#define VCB$S_VOLCKNAM	12
#define VCB$S_MOUNTTIME 8

/*
   Files-11 A & B
 */
#define VCB$K_MRKLEN	11	/* mark length */
#define VCB$C_MRKLEN	11
#define VCB$S_VCBDEF_COMMON 36
#define VCB$K_COMLEN	36	/* length of common area */
#define VCB$C_COMLEN	36	/* length of common area */
struct vcbdef_common {
    union {
	unsigned long vcb$l_fcbfl;	/* FCB listhead forward link */
	unsigned long vcb$l_blockfl;	/* or - blocked request listhead forward link */
	unsigned long vcb$l_memqfl;	/* or - shadow set members queue forward link */
    } vcb$r_forward_link;
    union {
	unsigned long vcb$l_fcbbl;	/* FCB listhead backward link */
	unsigned long vcb$l_blockbl;	/* or - blocked request listhead backward link */
	unsigned long vcb$l_memqbl;	/* or - shadow set members queue backward link */
    } vcb$r_backward_link;
    unsigned short vcb$w_size;		/* size of VCB in bytes */
    unsigned char  vcb$b_type;		/* structure type of VCB */
 /* second mark point */
    union {
	unsigned char vcb$b_status;	/* volume status: */
	struct {
	    unsigned vcb$v_write_if  : 1; /* index file is write accessed */
	    unsigned vcb$v_write_sm  : 1; /* storage map is write accessed */
	    unsigned vcb$v_homblkbad : 1; /* primary home block is bad */
	    unsigned vcb$v_idxhdrbad : 1; /* primary index file header is bad */
	    unsigned vcb$v_noalloc   : 1; /* allocation/deallocation inhibited (bad bitmaps) */
	    unsigned vcb$v_extfid    : 1; /* volume has 24 bit file numbers */
	    unsigned vcb$v_group     : 1; /* volume is mounted /group */
	    unsigned vcb$v_system    : 1; /* volume is mounted /system */
	} vcb$r_disk_bits;
#ifndef NO_VMS_V6
	struct {
	    unsigned vcb$v_high_sierra : 1; /* Volume is High Sierra */
	    unsigned vcb$v_noswitch  : 1; /* Disable Automatic Volume Switching */
	    unsigned vcb$v_dsi	     : 1; /* Enable protection based on DSI */
	    unsigned vcb$v_xar	     : 1; /* Enable protection based on XAR */
	    unsigned		     : 2; /* unused */
	    unsigned vcb$v_group     : 1; /* volume is mounted /group */
	    unsigned vcb$v_system    : 1; /* volume is mounted /system */
	} vcb$r_cdrom_bits;
#endif
	struct {
	    unsigned vcb$v_partfile  : 1; /* partial file exists on tape */
	    unsigned vcb$v_logiceovs : 1; /* positioned at logical end of volume set */
	    unsigned vcb$v_waimouvol : 1; /* wait for volume mount */
	    unsigned vcb$v_wairewind : 1; /* wait for rewind completion */
	    unsigned vcb$v_waiusrlbl : 1; /* wait for user label */
	    unsigned vcb$v_cancelio  : 1; /* cancel I/O */
	    unsigned vcb$v_mustclose : 1; /* must close file */
	    unsigned vcb$v_nowrite   : 1; /* don't write trailers */
	} vcb$r_tape_bits;
	struct {
	    unsigned vcb$v_shadmast  : 1; /* this VCB is for shadow set master */
	    unsigned vcb$v_failed    : 1; /* member failed out of shadow set */
	    unsigned		     : 1; /* unused_bit */
	    unsigned vcb$v_rebldng   : 1; /* mount verfication rebuilding shadow set */
	    unsigned vcb$v_blkastrec : 1; /* shadowing lock blocking AST received */
	    unsigned vcb$v_mvbegun   : 1; /* mount verification initiated */
	    unsigned vcb$v_adding    : 1; /* adding member to shadow set */
	    unsigned vcb$v_packacked : 1; /* member PACKACKed during rebuild attempt */
	} vcb$r_shadow_bits;
    } vcb$r_volsts;
    unsigned short vcb$w_trans;		/* volume transaction count */
    unsigned short vcb$w_rvn;		/* relative volume number */
    unsigned long  vcb$l_aqb;		/* address of AQB */
    char	   vcb$t_volname[12];	/* volume label blank filled */
    unsigned long  vcb$l_rvt;		/* address of UCB or relative volume table */
 /* third mark point */
};

#define VCB$V_SUBSYSTEM 0
#define VCB$M_SUBSYSTEM (1<<VCB$V_SUBSYSTEM)	/* 0x01 */
#define VCB$S_ACB	28
#define VCB$S_MIN_CLASS 20
#define VCB$S_MAX_CLASS 20
#define VCB$S_VCBDEF_DISKS 240
#define VCB$K_LENGTH	240	/* length of standard VCB */
#define VCB$C_LENGTH	240
struct vcbdef_disks {
    char vcb$b_filldisks[36];		/* struct vcbdef_common; */
    unsigned long  vcb$l_homelbn;	/* LBN of volume home block */
    unsigned long  vcb$l_home2lbn;	/* LBN of alternate volume home block */
    unsigned long  vcb$l_ixhdr2lbn;	/* LBN of alternate index file header */
    unsigned long  vcb$l_ibmaplbn;	/* LBN of index file bitmap */
    unsigned long  vcb$l_sbmaplbn;	/* LBN of storage bitmap */
    union {
	unsigned short vcb$w_ibmapsize; /* size of index file bitmap */
	unsigned char  vcb$b_ibmapsize; /* size of index file bitmap (old form) */
    } vcb$r_ibmapsize;
    union {
	unsigned short vcb$w_ibmapvbn;	/* current VBN in index file bit map */
	unsigned char  vcb$b_ibmapvbn;	/* current VBN in index file bit map (old form) */
    } vcb$r_ibmapvbn;
    union {
	unsigned short vcb$w_sbmapsize; /* size of storage bitmap */
	unsigned char  vcb$b_sbmapsize; /* size of storage bitmap (old form) */
    } vcb$r_sbmapsize;
    union {
	unsigned short vcb$w_sbmapvbn;	/* current VBN in storage map */
	unsigned char  vcb$b_sbmapvbn;	/* current VBN in storage map (old form) */
    } vcb$r_sbmapvbn;
    unsigned short vcb$w_cluster;	/* volume cluster size */
    unsigned short vcb$w_extend;	/* volume default file extension length */
    unsigned long  vcb$l_free;		/* number of free blocks on volume */
    unsigned long  vcb$l_maxfiles;	/* maximum number of files allowed on volume */
    unsigned char  vcb$b_window;	/* volume default window size */
    char	   vcb$b_lru_lim;	/* volume directory LRU size limit */
    unsigned short vcb$w_fileprot;	/* volume default file protection */
    unsigned short vcb$w_mcount;	/* mount count */
    unsigned char  vcb$b_eofdelta;	/* index file EOF update count */
    unsigned char  vcb$b_resfiles;	/* number of reserved files on volume */
    unsigned short vcb$w_recordsz;	/* number of bytes in a record */
    unsigned char  vcb$b_blockfact;	/* volume blocking factor */
    union {
	unsigned char vcb$b_status2;	/* second status byte */
	struct {
	    unsigned vcb$v_writethru : 1; /* volume is to be write-through cached */
	    unsigned vcb$v_nocache   : 1; /* all cacheing is disabled on volume */
	    unsigned vcb$v_mountver  : 1; /* volume can undergo mount verification */
	    unsigned vcb$v_erase     : 1; /* erase data when blocks removed from file */
	    unsigned vcb$v_nohighwater : 1; /* turn off high-water marking (d = on) */
	    unsigned vcb$v_noshare   : 1; /* non-shared mount */
	    unsigned vcb$v_cluslock  : 1; /* cluster wide locking necessary */
	    unsigned vcb$v_subset0   : 1; /* ODS-2 subset 0 volume */
	} vcb$r_status2_overlay;
    } vcb$r_status2_overlay;
    unsigned long  vcb$l_quotafcb;	/* address of FCB of disk quota file */
    unsigned long  vcb$l_cache;		/* address of volume cache block */
    unsigned long  vcb$l_quocache;	/* address of volume quota cache */
    unsigned short vcb$w_quosize;	/* length of quota cache to allocate */
    unsigned short vcb$w_penderr;	/* count of pending write errors */
    unsigned long  vcb$l_serialnum;	/* volume serial number (disks only) */
#ifndef NO_VMS_V6
    union {
	unsigned long vcb$l_status3;	/* third status field */
	struct {
	    unsigned  vcb$v_subsystem : 1; /* protected subsystems enabled */
	} vcb$r_status3_bits;
	unsigned long vcb$l_reserved1;
    } vcb$r_status3_overlay;
#else
    unsigned long  vcb$l_reserved1;	/* reserved */
#endif
#define vcb$l_jnliocnt vcb$l_reserved1	/*(former name)*/
    long	   vcb$q_retainmin[2];	/* minimum file retention period */
    long	   vcb$q_retainmax[2];	/* maximum file retention period */
    unsigned long  vcb$l_vollkid;	/* volume lock id */
    char	   vcb$t_volcknam[12];	/* name for volume locks */
    unsigned long  vcb$l_blockid;	/* volume blocking lock. */
    long	   vcb$q_mounttime[2];	/* volume mount time */
    unsigned long  vcb$l_memhdfl;	/* shadow set members queue header fl */
    unsigned long  vcb$l_memhdbl;	/* shadow set members queue header bl */
    unsigned short vcb$w_activity;	/* activity count/flag */
    unsigned char  vcb$b_spl_cnt;	/* number of devices spooled to volume */
    unsigned char  vcb$b_shad_sts;	/* status byte relative to memhdfl */
    unsigned long  vcb$l_shad_lkid;	/* shadowing lock lock-id */
    unsigned char  vcb$b_acb[28];	/* ACB for blocking AST */
    union {
	unsigned char vcb$b_min_class[20]; /* minimum classification */
	void	     *vcb$l_orb;	/* pointer to the volume's ORB */
    } vcb$r_min_class;
    struct {
	unsigned char vcb$b_max_class[20]; /* maximum classification */
    } vcb$r_max_class;
};

/*
   shadow set member volume control block fields
 */
#define VCB$S_WORK	8
#define VCB$S_SHDM_RESV 8
#define VCB$S_VCBDEF_SHADOW 68
#define VCB$K_SHAD_LEN	68	/* shadow set member VCB length */
struct vcbdef_shadow {
    char vcb$b_fillshadow[36];		/* struct vcbdef_common; */
    unsigned long  vcb$l_mem_ucb;	/* shadow set member UCB address */
    unsigned long  vcb$l_mast_ucb;	/* shadow set master UCB address */
    unsigned long  vcb$l_mast_vcb;	/* shadow set master VCB address */
    unsigned short vcb$w_copy_type;	/* member's MSCP copy type */
    unsigned short vcb$w_cpyseqnum;	/* IO$_COPYSHAD sequence number */
    unsigned long  vcb$q_work[2];	/* per-member workspace */
    unsigned long  vcb$q_shdm_resv[2];	/* reserved for future enhancements */
};

#ifndef NO_VMS_V6
/*
   Files-11 C & D
 */
#define VCB$S_VCBDEF_CDROM 88
struct vcbdef_cdrom {
    char vcb$b_fillcdrom[36];		/* struct vcbdef_common; */
    unsigned long  vcb$l_voldesc;	/* LBN of volume descriptor block */
    void	  *vcb$l_orphaned_vcb;	/* singlely linked list of orphaned VCB's */
    unsigned long  vcb$l_ptvector;	/* address path table vector */
    unsigned long  vcb$l_lbncache;	/* address of LBN cache listhead */
    unsigned long  vcb$l_ptindex;	/* LBN of path table index */
    unsigned short vcb$w_lbsize;	/* ISO 9660 logical block size */
    unsigned short vcb$w_mxdirnm;	/* maximum directory record number */
    unsigned short vcb$w_lbblocks;	/* number of 512-byte blocks per logical block */
    unsigned short vcb$w_minread;	/* minimum number of LBNs to read at once */
    unsigned short vcb$w_rdbytes;	/* number of bytes to read from disk at once */
    unsigned short vcb$w_lastgrp;	/* highest volume number of last volume group */
    unsigned long  vcb$l_free;		/* number of free blocks on volume */
    unsigned long  vcb$l_maxfiles;	/* maximum number of files allowed on volume */
    unsigned char  vcb$b_window;	/* volume default window size */
    char	   vcb$b_lru_lim;	/* volume directory LRU size limit */
    unsigned short vcb$w_ptrvn;		/* RVN of volume containing current path table */
    unsigned short vcb$w_mcount;	/* mount count */
    unsigned char  vcb$b_fat_rfm;	/* override FAT record format */
    unsigned char  vcb$b_fat_rat;	/* override FAT record attributes */
    unsigned short vcb$w_fat_mrs;	/* override FAT maximum record size */
    unsigned char  vcb$b_sectors;	/* number of sectors on volume */
    unsigned char  vcb$b_status2;	/* second status byte */
};
#endif

/*
   MTAACP volume control block fields
 */
#define VCB$S_EXP_DATE	8
#define VCB$S_VCBDEF2	120
struct vcbdef2 {
    char vcb$b_filltape[36];		/* struct vcbdef_common; */
    union {
	unsigned long vcb$l_cur_fid;	  /* current file identification */
	struct {
	    unsigned short vcb$w_cur_num; /* current file section number */
	    unsigned short vcb$w_cur_seq; /* current file sequence number */
	} vcb$r_cur_fid_fields;
    } vcb$r_cur_fid_overlay;
    union {
	unsigned long vcb$l_start_fid;	/* file identification at start of search */
	struct {
	    unsigned short vcb$w_start_num; /* file section number at start of search */
	    unsigned short vcb$w_start_seq; /* file sequence number at start of search */
	} vcb$r_start_fid_fields;
    } vcb$r_start_fid_overlay;
    union {
	unsigned short vcb$w_mode;	/* mode of operation */
	struct {
	    unsigned vcb$v_ovrexp     : 1; /* override expiration */
	    unsigned vcb$v_ovracc     : 1; /* override access */
	    unsigned vcb$v_ovrlbl     : 1; /* override labels */
	    unsigned vcb$v_ovrsetid   : 1; /* override set identifier */
	    unsigned vcb$v_intchg     : 1; /* interchange tape */
	    unsigned vcb$v_ebcdic     : 1; /* EBCDIC code set */
	    unsigned vcb$v_novol2     : 1; /* do not write a VOL2 label */
	    unsigned vcb$v_nohdr3     : 1; /* do not write HDR3 labels */
	    unsigned vcb$v_starfile   : 1; /* current file is a starlet produced file */
	    unsigned vcb$v_enusereot  : 1; /* set when user handling of EOT is enabled */
	    unsigned vcb$v_blank      : 1; /* set for AVL when no read should happen first */
	    unsigned vcb$v_init       : 1; /* set for AVL when next vol mounted should be inited */
	    unsigned vcb$v_noauto     : 1; /* MTAACP not running in AVL and AVR mode */
	    unsigned vcb$v_ovrvolo    : 1; /* override the VOL1 owner ident field */
	    unsigned vcb$v_fil_access : 1; /* set if access routine allows check of VMS protection on file */
	    unsigned		      : 1; /* padding */
	} vcb$r_mode_bits;
    } vcb$r_mode_overlay;
    unsigned char  vcb$b_tm;		/* number of TM's into file */
    unsigned char  vcb$b_cur_rvn;	/* current relative volume */
    unsigned long  vcb$l_st_record;	/* number of records up to and including last tape mark */
    unsigned long  vcb$l_mvl;		/* address of magnetic tape volume list */
    unsigned long  vcb$l_wcb;		/* address of window for this volume */
    unsigned long  vcb$l_vpfl;		/* virtual page list head */
    unsigned long  vcb$l_vpbl;		/* virtual page list tail */
    unsigned long  vcb$l_usrlblast;	/* address of user label AST control block */
    unsigned char  vcb$b_lblcnt;	/* count of HDRn labels read on file open */
 /* note that FCP and MTAACP share VCB$W_MCOUNT(displacement 80) */
    char vcbdef2$$_fill[39];		/* skip over fields up to RETAINMIN=112 */
    long	   vcb$q_exp_date[2];	/* default file expiration date */
};

#define VCB$S_QNAME	20
#define VCB$S_VCBDEF3	32
struct vcbdef3 {
    char vcbdef3$$_fill[11];
    unsigned char vcb$b_qnamecnt;	/* byte count of queue name */
    char vcb$t_qname[20];		/* ASCII name of queue for this device */
};
/*
   journal ACP volume control block fields
 */

#endif	/*_VCBDEF_H*/
