include 'gsos.equ' include 'minix.equ' include 'fst.equ' include 'fst.macros' include 'M16.Debug' include 'records.equ' gde_dp record dp displacement ds.w 1 count ds.w 1 dirent_size ds.w 1 IF *>=$d4 THEN AERROR 'dp -- too large.' ENDIF endr endr get_dir_entry procname export with fst_parms with dp with gde_dp ldx return total count. ; cmp #0 beq @count jmp get_indexed_entry @count jmp count_entries forward jmp get_next_entry ; backward ; backward 0 ? == forward 0 cmp #0 beq forward eor #$ffff sec ; inc / clc ldy #fcr.dirent adc [my_fcr],y sta displacement jmp get_indexed_entry endp get_indexed_entry proc ; get the displacement entry. lda displacement beq eod bmi eod bra ok eod lda #end_of_dir sec rts ok ; if displacement is >= current dirent, use next dirent code. ldy #fcr.dirent cmp [my_fcr],y bcc hard sec sbc [my_fcr],y sta displacement jmp get_next_entry hard ; go through all directory entries until we find the one we want. ldx #0 ; zone. clc rts endp count_entries proc ; count the number of entries. with fst_parms with dp, gde_dp ; read each block and count the entries. ; only handles direct blocks. so there. ; disk inode has been copied to the dp. ldx #0 zone_loop lda disk_inode,x beq done ; directory should not be sparse! phx ; save jsr read_data_block plx ; and restore bcs exit jsr count_dirent_block lda dirent_count beq done inx cpx #v1.NR_DZONES bcs done bra zone_loop ; ; minix has 16-byte dirents. ; linux has 32-byte dirents. done ; also reset the displacement to 0. lda #0 ldy #fcr.dirent sta [my_fcr],y ldy #fcr.dirent_zone sta [my_fcr],y ldy #fcr.dirent_offset sta [my_fcr],y clc exit rts endp count_dirent_block proc ; 16-byte dirent entries -- 64 per block. with dp ldy #0 loop lda [io_buffer],y beq next inc count next ; not 32-bit safe. dec disk_inode.size beq done tya clc adc dirent_size tay cmp #1024 bcc loop done rts endp end