qdosmsq:traps:trap_3:rhdr

FS_HEADR/IOF_RHDR

This trap reads a file header.

Call ParametersReturn Parameters
D0.B$47D0.LError code.
D1.L D1.WLength of header read.
D2.LBuffer length D2.LPreserved.
D3.WTimeoutD3.LPreserved.
A0.LChannel ID A0.LPreserved.
A1.LPointer to bufferA1.LUpdated.
ERR_NCNot complete.
ERR_NOChannel not found.
ERR_BOBuffer full.
  • All registers not shown above are not used on entry and are preserved on exit.
  • The length of header is 64 bytes for a directory driver and 15 bytes for other device drivers.
  • After the buffer has been read A1.L points to one after the last character read.
  • The form of header is shown below.
  • The file type (byte 5) is 0 for data files, 1 for executable files, 2 for relocatable files and 255 for subdirectories.

File Header

AddressLengthContents
$00longFile length
$04byteFile access set to 0 in QDOS v1.03
$05byteFile type
$06longSize of data space for executable files
$0AlongUnused

Additionally for Directory Drivers

AddressLengthContents
$0EwordLength of filename
$1036 bytesFilename
$34longUpdate date
$38wordVersion number
$3AwordReserved
$3ClongBackup date

The example below shows how to read the header of an executable file and put its length into D2.L.

Read_h  lea     -64(a7),a7      ; Space on the stack for the header.
        movea.l a7,a1           ; Point to the space.
        moveq   #64,d2          ; Length of buffer.
        moveq   #-1,d3          ; Timeout.
        moveq   #$47,d0         ; FS_HEADR
        trap    #3              ; Read the header.
        tst.l   d0              ; OK? . .
        bne     error           ; . . no!
        movea.l a7,a1           ; Reset A1
        subq.b  #1,5(a1)        ; Check for executable file
        bne     error           ; OOPS!
        move.l  (a1),d2         ; Set file length in D2
        lea     64(a7),a7       ; Tidy stack

 ; We could now load the file into memory.    
  • qdosmsq/traps/trap_3/rhdr.txt
  • Last modified: 2009/02/17 11:47
  • by george.gwilt