DriveSpace Functions and Structures

DSRawRead

mov    ax, 4404h             ; IOCTL command
mov    bl, Drive             ; drive number (one-based)
mov    cx, size DataPacket   ; size of data packet
mov    dx, seg DataPacket    ; address of data packet
mov    ds, dx
mov    dx, offset DataPacket 
int    21h

jc     error
cmp    DataPacket.dspResult, ; 'OK' ; test for success
jne    failure               ; call failed

Reads raw data from a compressed volume file (CVF) into a buffer.

Value Meaning
0001h ERROR_INVALID_FUNCTION
0005h ERROR_ACCESS_DENIED
0006h ERROR_INVALID_HANDLE
000Dh ERROR_INVALID_DATA

Drive
One-based driver number for a DriveSpace driver (1 = A, 2 = B, and so on). If there is more than one DriveSpace drive, any one of the corresponding drive numbers can be given.
DataPacket
Data packet consisting of a DSHDR structure, a DSRAWIO structure, and an array of RawClusterInfo structures. The dspCommand field of the DSHDR structure must be set to the letter 'R'. The buffer pointed to by the rci_pdata field of the RawClusterInfo structure receives the raw data.

See Also

DSHDR, DSRAWIO, RawClusterInfo

DSRawWrite

mov    ax, 4404h             ; IOCTL command
mov    bl, Drive             ; drive number (one-based)
mov    cx, size DataPacket   ; size of data packet
mov    dx, seg DataPacket    ; address of data packet
mov    ds, dx
mov    dx, offset DataPacket 
int    21h

jc     error
cmp    DataPacket.dspResult, ; 'OK' ; test for success
jne    failure               ; call failed

Writes raw data from a buffer into a compressed volume file (CVF).

Value Meaning
0001h ERROR_INVALID_FUNCTION
0005h ERROR_ACCESS_DENIED
0006h ERROR_INVALID_HANDLE
000Dh ERROR_INVALID_DATA

Drive
One-based driver number for a DriveSpace driver (1 = A, 2 = B, and so on). If there is more than one DriveSpace drive, any one of the corresponding drive numbers can be given.
DataPacket
Data packet consisting of a DSHDR structure, a DSRAWIO structure, and an array of RawClusterInfo structures. The dspCommand field of the DSHDR structure must be set to the letter 'W'. The buffer pointed to by the rci_pdata field of the RawClusterInfo structure receives the raw data.

See Also

DSHDR, DSRAWIO, RawClusterInfo

DSHDR

DSHDR STRUC
    dspStamp    dw  ?  ; Identifying stamp ('DM')
    dspCommand  db  ?  ; Command ('R' or 'W')
    dspResult   dw  ?  ; see below
DSHDR ENDS

Defines the portion of the IOCTL header that is common to all DriveSpace Receive Control Data IOCTLs. Notice that WORD alphanumeric constants are shown as they would be defined for MASM. Thus, 'DM' is equivalent to 444Dh, and 'OK' is equivalent to 4B4Fh. When dumped as two consecutive bytes or as a text string, these values would appear as "MD" and "KO" respectively. The dspCommand field is typically an ASCII character. For the raw read IOCTL, dspCommand is set to 'r'; for raw writes, it is set to 'w'.

dsp_result
Can be one of these values:
Value Meaning
DSRROK ('OK') Success
DSRRWRITE (0001h) Intervening write occurred
DSRRLOCK (0002h) Buffer lock failed
DSRRIO (0003h) I/O error
DSRRBADCLUS (0004h) Invalid MDFAT index
DSRRUNALLOC (0005h) Attempt to read unallocated cluster
DSRRBADSECTOR (0006h) Bad starting sector
DSRRBADSIZE (0007h) Bad cluster size
DSRRNOSIZE (0008h) Uncompressed size unknown
DSRRNOTFREE (0009h) Some target sectors were not free
DSRRXBOUND (000Ah) Allocation crosses BitFAT boundary
DSRRNULLPTR (000Bh) NULL pointer passed to write
DSRRSECCOUNT (000Ch) Sector count mismatch
DSRRPKTSIZE (000Dh) Packet size is too small
DSRRDATAWRITE (000Eh) Data was written
DSRRBADFRAG (000Fh) Bad fragment table

DSRAWIO

DSRAWIO STRUC
    dsr_hdr        db  SIZE DSHDR dup(?) ; Packet header
    dsr_flags      db  ?     ; Flags
    dsr_cclus      dw  ?     ; Count of clusters to operate on
    dsr_reserved0  dd  0     ; Reserved
    dsr_reserved1  dd  0     ; Reserved
DSRAWIO ENDS

Contains information about a raw I/O IOCTL operation. Immediately precedes an array of RawClusterInfo structures.

dsr_hdr
DSHDR structure that defines the header common to all DriveSpace Receive Control Data IOCTLs.
dsr_flags
Can be DSRFLOCKED (01h) if buffers are locked. Under normal circumstances, this field must be set to zero when the IOCTL is issued.
dsr_cclus
Number of RawClusterInfo structures follow the DSRAWIO structure. This is the same as the number of clusters on which to perform the action.
dsr_reserved0 and dsr_reserved1
Reserved; must be zero.

See Also

RawClusterInfo

RawClusterInfo

RawClusterInfo STRUC
    rci_pdata      dd  ?  ; Pointer to raw cluster data buffer
    rci_isecstart  dd  ?  ; Starting sector in sector heap
    rci_ifat       dw  ?  ; FAT index
    rci_csec       db  ?  ; Count of raw sectors
    rci_flags      db  ?  ; Flags
    rci_reserved   dd  0  ; Reserved
RawClusterInfo ENDS

Contains information used by the raw cluster I/O IOCTLs. All pointers are flat model pointers. The same structure is used for both reads and writes, but the fields are treated somewhat differently.

rci_pdata
Address of the buffer from which data is written or into which data is read. The size of the buffer, in sectors, is specified by rci_csec. The client must always specify a flat address regardless of the client's mode of execution. (For an MS-DOS program, the flat address is simply segment*16 + offset.) The data read or written is raw data; no compression or decompression is applied to the data. Reads return the data as it appears on the disk; writes do not modify the data before writing it to the disk. The address passed in rci_pdata may be valid only in the context of the client thread. For example, for V86 or Win32 clients.
rci_isecstart
Starting sector of the cluster specified by rci_imdfat. On reads, this field is ignored on input and filled with the value from the MDFAT entry before returning to the client. On writes, this field specifies the starting sector at which to write the cluster. A set of writes fails if any of the target sectors are not free, or if any of the target extents overlap.
rci_ifat
FAT index of the target cluster.
rci_csec
Count of sectors that the cluster actually occupies on the disk. On reads, if the actual size of the cluster does not exactly match this value, the read is cancelled.
rci_flags
Receives the values of the specified flags in the MDFAT entry to the client. On writes, this field specifies the settings of the flags for the cluster to be written. Setting RCFMARK on a write to a CVF whose version is less than 3.0 has no effect. The mark bit is intended for the use of the off-line recompressor to prevent it from trying to recompress clusters it either successfully or unsuccessfully recompressed the last time it ran. Raw write is the only means by which this bit can be set, and normal writes to a cluster clear the bit.

The rci_flags field can a combination of these values:
Value Meaning
RCFMARK (01h) Marked cluster
RCFFRAG (02h) Fragmented cluster
RCFUNCOMP (04h) Uncompressed cluster
RCFALLOC (08h) Allocated cluster

rci_reserved
Reserved.

FRAGHDR

FRAGHDR STRUC
    fhcFrag    dd  ?         ; Count of fragments
    fhaFrag    dd  ? DUP (?) ; Variable size array of fragment entries
FRAGHDR ENDS

Contains information about fragmented clusters. The first sector of fragmented sections contains a FRAGHDR structure.

The count of sectors stored for each fragment header entry is actually the count of sectors in the fragment minus one. Also, the first entry in fhaFrag describes the first fragment in the cluster, just as the MDFAT entry does.

You can use the following values to retrieve information from a segment entry in the fhaFrag array:

Value Meaning
FG_SECTORWIDTH (23) Width of sector number
FG_SECTORSHIFT (0) Shift sector number to low end
FG_SECTORMASK (((1 SHL FG_SECTORWIDTH) - 1) SHL FG_SECTORSHIFT) Mask for sector number
FG_RESERVEDWIDTH (3) Width of reserved bits
FG_RESERVEDSHIFT (FG_SECTORSHIFT + FG_SECTORWIDTH) Shift reserved bits to low end
FG_RESERVEDMASK (((1 SHL FG_RESERVEDWIDTH) - 1) SHL FG_RESERVEDSHIFT) Mask for reserved bits
FG_CSECWIDTH (6) Width of sector count
FG_CSECSHIFT (FG_RESERVEDSHIFT + FG_RESERVEDWIDTH) Shift sector count to low end
FG_CSECMASK (((1 SHL FG_CSECWIDTH) - 1) SHL FG_CSECSHIFT) Mask for sector count