-NOTE-	This document accompanied the BRUDIR program written
	by R. J. D. Kirkman (modifications by A. Frisbie).


BRU TAPE FORMATS
----------------

Although the format of a BRU tape is complex, it is feasable to
read such tapes on other than an RSX system.   The format is described
below, mainly as deduced from dumping parts of a short tape, and from
reading the microfiche source listings for BRU on RSX-11M-Plus v2.1.
This information should not be described as guaranteed.

RECORDS MAKING UP A BRU TAPE:
-----------------------------

Len	Type	Description
---	----	-----------

80	VOL1	ANSI Volume label
512	NOBOOT	Dummy boot block that prints "This volume does not
		contain a bootable system" if the tape is booted.
80	HDR1	ANSI file label for first BRU Backupset
80	HDR2	ANSI file label 4144 byte max,internal carriage control
*TM*
80	BACKUP	Backupset control block, identifies disk dumped, date, time,
		etc. (See below for format)
512	BOOT	The boot block from the backed up disk, or NOBOOT again
512	HOME	The home block from the backed up disk.
80	UFD	UFD record for [0,0]
.....		Usually there are no directory blocks here, but if files
		such as RSX11.SYS etc exist in [0,0] directory, 
		blocks listing these appear here
80	UFD	UFD record for 1st directory.   (See below for format)
512*N	DIRECT	0..8 directory blocks per buffer, as read from the 
		above directory file.   (See below for format)

Repeat DIRECT records until all directory blocks are written.
Repeat UFD/Direct combinations.

80	HEAD	Block of 80 bytes (20*'HEAD') flags the start of file headers.
80	UFD	Repeat of UFD record for [0,0]
.....		Headers for files in [0,0] if any.
80	UFD	Repeat of first directory UFD record.
512*N	HDRS	0..8 File headers of files in the above directory. as read
		from the disk.   (See I/O Operations manual, Appendix F)
		-NOTE- BRU puts the name from the directory into the file
			header, so renamed files are not a problem.

Repeat HDRS for all blocks in directory.
Repeat for all above directories.

80	DATA	Block of 80 bytes (20*'DATA') flags start of data blocks.
48+512*N DAT	Usually 4144 bytes data block.   1..8 data blocks with 48
		byte prefix describing data.

Data blocks repeat for all the above described files, then more directories
and headers, then the bodies of more files. Ends with:

*TM*
80	EOF1	End of file mark for backupset
80	EOF2
*TM*
..................More backupsets
*TM*		Two *TM* in a row indicate end of tape.


-NOTE-
If a bootable system is on the tape, then the first block on the tape will
be 512. bytes long.  The HDR1 & HDR2 labels for the first backup set will
follow the first tape mark.


The special BRU format tape blocks are as follows:

UFD blocks:
-----------

	.ASCIZ	/UFD/
	.BLKW	3		; FileID, SeqNum, RelVol # (=0)
	.BLKW	3		; Directory filename in RAD50
	.BLKW	1		; Directory filetype in RAD50 (DIR)
	.WORD	1		; Directory version (Always 1)
	.BLKW	1		; Directory Level [0,0]=0,
				; Users =1, SCS11 might have 2+
	.BLKW	2		; Size of directory  HI,LO
	.BLKW	1		; Owner UIC for directory
	.BLKW	1		; Protection for directory
	Pad to 80 bytes with nulls.


Backupset label:
----------------

	.BLKB	12.		; Backupset name (ASCII)
	.BLKW	1		; Backup volume set # (starts at 1)
				; (Index to reels of multireel tape sets)
	.BLKB	12.		; Disk label name (ASCII)
	.BLKW	8.		; GTIM$ format (binary) 8 word data/time block
				; YR MON DAY HR MIN SEC TIC Ticks/sec
	.BLKW	1		; Size of Index file size in blocks
	.BLKW	2		; Size of MFD [0,0] in blocks
	.BLKW	2		; Size of original disk (HI,LO)
	.BLKB	2		; Two character device mnemonic (ASCII)
	.BLKW	1		; Index file position (0=BEG, 1=MID, 2=END)
	.BLKW	3	*	; Table of 3 Free File ID's for BRU to
				; use for extending INDEXF.SYS or BADBLK.SYS
				; when restoring tape to disk. (SEE NOTE BELOW!)
	.BLKB	7	**	; DDMMMYY of dump (ASCII)
	.BLKB	6	**	; HHMMSS of dump (ASCII)
	.BYTE	0	**	; terminator
	Pad to 80 bytes with ASCII months of the year in reverse order:
	"DEC", "NOV", etc.

* NOTE: These three words were not in early BRU tapes.   They were added
        by D. Girdler (Edit DG015) at DEC on 26-Dec-79 to add support for
	multi-header index files.   It is not known what happens if an
	early BRU tape is restored by a later copy of BRU with the ASCII
	date and time being interpreted as file ID's.

** NOTE: The ASCII date/time originally occured three words EARLIER in the
	record (see above note), causing problems for early version of BRUDIR.
	BRUDIR now uses the GTIM$ formatted date/time.   If you wish to know
	which version of BRU wrote the tape, check the next-to-last word
	of the buffer.   Early tapes will have "OC" (October), while later
	tapes will have "DE" (December) because of the extra three FID words.
	This information is only written because it just happens to follow
	(in BRU's memory) the information DEC wanted to write.   Thus, it
	may change or go away at any time.   As of RSX-11M-Plus v3.0, it
	appears to still be there.


Directory blocks:
-----------------

16. byte fixed length records, each

	.BLKW	3	; File ID, File Sequence #, Relative Vol # (=0).
	.BLKW	4	; RAD50 /FILENAME EXT/
	.BLKW	1	; Version number (binary)

A deleted or unused entry is flaged by having the first word, the File ID,
set to zero.


Data blocks:
------------

	.BLKW	3	; File-id (1 word)
			; 1-3 retrieval pointer relating to blocks
			; in this data buffer.

	Repeat up to a total 0f 8 3 word groups.
	If less than 8 groups, insert a null word as terminator.
	Pad to total of 24. words in header.
	Up to 8 data blocks, as described by retrieval pointers.

	Note the retrieval pointers are in the format

	.BYTE hi-disk-lbn	; (low byte of first word)
	.BYTE biased-count	; ie actual number of blocks minus 1
	.WORD low-disk-lbn	; Low-order 16 bits of Logical Block Number

	The block numbers relate to the logical blocks on the original disk,
	not to the file in any way.


Recovery of files from a BRU tape.
----------------------------------

Read UFD records, creating UFDs as you pass.   Use the directory 
entries, buffered, to create the files as you find matching file
headers, creating the files with the correct attributes including
size.   The File ID/Sequence # for the new files must be saved, along
with the old File ID, and a table of retrieval pointers built
relating disk LBNs to file VBNs.   Since there is no guarantee that
files will occur as complete units, you must be able to switch to
the correct file to write the set of virtual blocks.
