From 1ec4fec015235a8a58db89add2ed7dbe9aed72ba Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 13 Aug 2015 14:05:19 -0400 Subject: [PATCH] updates --- fst.equ | 15 ++- get_dir_entry.aii | 308 ++++++++++++++++++++++++++++++++++++++++++++++ get_file_info.aii | 167 ++++++++++++++----------- gsos.equ | 1 + id_disk.aii | 6 +- main.aii | 57 +++++++++ minix.equ | 45 ++++++- open.aii | 27 +++- records.equ | 88 ++++++++++--- 9 files changed, 609 insertions(+), 105 deletions(-) create mode 100644 get_dir_entry.aii diff --git a/fst.equ b/fst.equ index 716fc39..ea6267b 100644 --- a/fst.equ +++ b/fst.equ @@ -10,7 +10,6 @@ my_fcr ds.l 1 call_class ds.w 1 - device ds.w 1 ; device for id_disk. tool_error ds.w 1 @@ -19,12 +18,12 @@ inode ds.w 1 parent_inode ds.w 1 disk_inode ds v1_inode - +;super ds v1_super IF *>=$d4 THEN AERROR 'dp -- too large.' ENDIF - endr + endr fcr record 0 @@ -40,15 +39,19 @@ access ds.w 1 ; fst-specific items -ino ds.w 1 +inode ds.w 1 disk_inode ds v1_inode dirty ds.w 1 mark ds.l 1 ; current position + ; dirent stuff. +dirent ds.w 1 ; current directory entry. +dirent_zone ds.w 1 ; current directory zone [0-6] +dirent_offset ds.w 1 ; current directory offset -sizeof equ * +__sizeof equ * endr vcr record 0 @@ -70,7 +73,7 @@ first_inode_block ds.w 1 first_imap_block ds.w 1 first_zmap_block ds.w 1 -sizeof equ * +__sizeof equ * endr diff --git a/get_dir_entry.aii b/get_dir_entry.aii new file mode 100644 index 0000000..7f10a24 --- /dev/null +++ b/get_dir_entry.aii @@ -0,0 +1,308 @@ + + 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 \ No newline at end of file diff --git a/get_file_info.aii b/get_file_info.aii index 7476539..ec9aaee 100644 --- a/get_file_info.aii +++ b/get_file_info.aii @@ -13,6 +13,8 @@ entry path_to_inode + entry load_inode + import id_disk import device_read @@ -25,80 +27,16 @@ get_file_info procname export jsr path_to_inode - bcc @inode - rtl -@inode - ; we have an inode. and my_vcr is valid. - ; we need to actually _load_ the inode. + bcs exit + + jsr load_inode + bcs exit - ; todo -- check if inode # is valid? - ; todo -- check if bit set in imap? ;~DebugSetTrace #1 ;pla ; prev value - ldy #vcr.first_inode_block - lda [my_vcr],y - asl a ; x 2 - sta dev_blk_num - - ; 32 inodes per block. - ; however, I'd rather read half-block chunks, with means - ; 16 inodes per half-block. - lda inode - dec a ; inode 1 is offset 0. - lsr a ; / 2 - lsr a ; / 4 - lsr a ; / 8 - lsr a ; / 16 - ;lsr a ; / 32 - - clc - adc dev_blk_num - sta dev_blk_num - - lda #512 - sta dev_req_cnt - - - lda device - sta dev_num - - jsr device_read - bcc ok - rtl -ok - - ; find the inode... - lda inode - dec a ; inode 1 is offset 0. - and #$0f - ; multiply by 32 - asl a ; x 2 - asl a ; x 4 - asl a ; x 8 - asl a ; x 16 - asl a ; x 32 - clc - adc io_buffer - sta ptr - lda #0 - adc io_buffer+2 - sta ptr+2 - - ; copy to dp - ldy #v1_inode.sizeof-2 - ldx #v1_inode.sizeof-2 -@loop - lda [ptr],y - sta disk_inode,x - dey - dey - dex - dex - bpl @loop - ;pha ; space ;~DebugSetTrace #0 @@ -126,6 +64,8 @@ class0 cmp #0 rtl +exit + rtl import do_ignore import do_access @@ -173,8 +113,97 @@ do_access proc +load_inode proc export + ; + ; loads inode into disk_inode. + ; + ; inputs : + ; my_vcr + ; inode + ; device + ; + ; outputs : + ; disk_inode + ; error in a/c -path_to_inode proc + ; todo -- check if inode # is valid? + ; todo -- check if bit set in imap? + + + with fst_parms + with dev_parms + with dp + + ldy #vcr.first_inode_block + lda [my_vcr],y + asl a ; x 2 + sta dev_blk_num + + ; 32 inodes per block. + ; however, I'd rather read half-block chunks, with means + ; 16 inodes per half-block. + lda inode + dec a ; inode 1 is offset 0. + lsr a ; / 2 + lsr a ; / 4 + lsr a ; / 8 + lsr a ; / 16 + ;lsr a ; / 32 + + clc + adc dev_blk_num + sta dev_blk_num + + lda #512 + sta dev_req_cnt + + lda device + sta dev_num + + jsr device_read + bcc ok + rtl +ok + + ; find the inode... + lda inode + dec a ; inode 1 is offset 0. + and #$0f + ; multiply by 32 + asl a ; x 2 + asl a ; x 4 + asl a ; x 8 + asl a ; x 16 + asl a ; x 32 + clc + adc #v1_inode.__sizeof-2 + tay + + ;adc io_buffer + ;sta ptr + ;lda #0 + ;adc io_buffer+2 + ;sta ptr+2 + + ; copy to dp + ldx #v1_inode.__sizeof-2 +@loop + lda [io_buffer],y + sta disk_inode,x + dey + dey + dex + dex + bpl @loop + + lda #0 + clc + rts + + + endp + +path_to_inode proc export with dp,fst_parms diff --git a/gsos.equ b/gsos.equ index b603944..59d19dd 100644 --- a/gsos.equ +++ b/gsos.equ @@ -201,6 +201,7 @@ write_enabled equ $0002 ;1=Write Enabled backup_enabled equ $0020 ;1=Needs to be backed up rename_enabled equ $0040 ;1=Rename allowed destroy_enabled equ $0080 ;1=Destroy is enabled + read_access equ $01 write_access equ $02 invis_bit equ $04 diff --git a/id_disk.aii b/id_disk.aii index 6d47c3d..722d216 100644 --- a/id_disk.aii +++ b/id_disk.aii @@ -165,7 +165,7 @@ dump_vcr ; drop through. create_vcr - lda #vcr.sizeof + lda #vcr.__sizeof ldx #default_name ldy #^default_name jsl alloc_vcr @@ -199,7 +199,7 @@ create_vcr adc my_vcr+2 sta ptr+2 - ldy #v1_super.sizeof-2 + ldy #v1_super.__sizeof-2 @loop lda [dev_parms.dev_buff],y sta [ptr],y @@ -235,7 +235,7 @@ create_vcr sta [my_vcr],y - ~DebugHexDump