Ignore:
Timestamp:
Apr 8, 2017, 12:28:07 AM (8 years ago)
Author:
Ben Rietbroek
Message:

Added a double check when writing LVM sectors [v1.1.1-testing]

Writing an LVM sector is always the result of modifications to a
previously loaded one. So we first do a load and validate to make sure
the addressed sector contains LVM information.

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/regular/driveio.asm

    r168 r169  
    616616
    617617IFDEF   AUX_DEBUG
    618         IF 0
     618        IF 1
    619619        DBG_TEXT_OUT_AUX    'DriveIO_SaveLVMSectorXBR:'
    620620        PUSHRF
    621621            call    DEBUG_DumpRegisters
    622             ;~ call    AuxIO_DumpSector
     622            call    AuxIO_DumpSector
    623623            ;~ call    AuxIO_DumpParagraph
    624624            ;~ call    AuxIO_TeletypeNL
     
    653653        sbb     bx, 0       ; Propagate borrow to LBA hi
    654654
     655        ; Writing an LVM sector is always the result of modifications to a
     656        ; previously loaded one. So, now that we have the LBA address of the
     657        ; LVM sector, the one about to be overwritten should be there.
     658        ; If it's not, something is seriously wrong and we quit immetiately.
     659        pusha                           ; Push our context except the flags
     660        mov     si, offset [Scratch]    ; Sector buffer to load the LVM sector
     661        call    ClearSectorBuffer       ; Make sure no old LVM info is present
     662        mov     di, ds                  ; Segment of buffer
     663        call    DriveIO_ReadSectorLBA   ; Load the old LVM sector
     664        call    LVM_ValidateSector      ; CF=1 if valid
     665        cmc                             ; Complement for disk i/o semantics
     666        popa                            ; Restore our context except the flags
     667
     668        ; OOPS, There was no LVM sector there !!
     669        jc      DriveIO_SaveLVMSectorXBR_no_lvm
     670
    655671        ; Save the LVM sector pointed to by SI
    656672        mov     di, ds                          ; Segment of that buffer
    657         call    DriveIO_WriteSectorLBA          ; Read the LVM sector
    658 
    659 IFDEF   AUX_DEBUG
    660         IF 0
     673        call    DriveIO_WriteSectorLBA          ; Write the LVM sector
     674
     675IFDEF   AUX_DEBUG
     676        IF 1
    661677        DBG_TEXT_OUT_AUX    'LVMSecSaved'
    662678        PUSHRF
     
    676692
    677693    DriveIO_SaveLVMSectorXBR_no_lvm:
    678         ; Indicate no valid LVM sector was loaded
     694        ; Indicate no valid LVM sector was saved
    679695        stc
    680696
Note: See TracChangeset for help on using the changeset viewer.