Subversion Repositories Kolibri OS

Rev

Rev 9888 | Rev 9890 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9888 Rev 9889
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2013-2022. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2013-2022. All rights reserved. ;;
4
;;  Distributed under terms of the GNU General Public License   ;;
4
;;  Distributed under terms of the GNU General Public License   ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 9888 $
8
$Revision: 9889 $
Line 9... Line 9...
9
 
9
 
Line 160... Line 160...
160
        mov     [edi+XFS.versionnum], eax
160
        mov     [edi+XFS.versionnum], eax
161
        and     eax, XFS_SB_VERSION_NUMBITS
161
        and     eax, XFS_SB_VERSION_NUMBITS
162
        mov     [edi+XFS.version], eax
162
        mov     [edi+XFS.version], eax
Line 163... Line 163...
163
 
163
 
-
 
164
        mov     [edi+XFS.conv_time_to_kos_epoch], xfs._.conv_time_to_kos_epoch
Line 164... Line 165...
164
        mov     [edi+XFS.conv_time_to_kos_epoch], xfs._.conv_time_to_kos_epoch
165
        mov     [edi+XFS.nextents_offset], xfs_inode.di_core.di_nextents
165
 
166
 
166
        movbe   eax, [ebx+xfs_sb.sb_features2]
167
        movbe   eax, [ebx+xfs_sb.sb_features2]
167
        mov     [edi+XFS.features2], eax
168
        mov     [edi+XFS.features2], eax
Line 202... Line 203...
202
        mov     [edi+XFS.da_blkinfo_size], sizeof.xfs_da3_blkinfo
203
        mov     [edi+XFS.da_blkinfo_size], sizeof.xfs_da3_blkinfo
203
        test    [edi+XFS.features_incompat], XFS_SB_FEAT_INCOMPAT_BIGTIME
204
        test    [edi+XFS.features_incompat], XFS_SB_FEAT_INCOMPAT_BIGTIME
204
        jz      @f      ; no bigtime
205
        jz      @f      ; no bigtime
205
        mov     [edi+XFS.conv_time_to_kos_epoch], xfs._.conv_bigtime_to_kos_epoch
206
        mov     [edi+XFS.conv_time_to_kos_epoch], xfs._.conv_bigtime_to_kos_epoch
206
@@:
207
@@:
-
 
208
        test    [edi+XFS.features_incompat], XFS_SB_FEAT_INCOMPAT_NREXT64
-
 
209
        jz      @f      ; no bigtime
-
 
210
        mov     [edi+XFS.nextents_offset], xfs_inode.di_core.di_big_nextents.lo_be
-
 
211
@@:
207
.vcommon:
212
.vcommon:
Line 208... Line 213...
208
 
213
 
209
        movzx   eax, [ebx+xfs_sb.sb_inodesize]
214
        movzx   eax, [ebx+xfs_sb.sb_inodesize]
210
        xchg    al, ah
215
        xchg    al, ah
Line 303... Line 308...
303
        test    eax, eax
308
        test    eax, eax
304
        jz      .error
309
        jz      .error
Line 305... Line 310...
305
 
310
 
306
        ; we do need XFS.blocksize bytes for single inode
311
        ; we do need XFS.blocksize bytes for single inode
307
        ; minimal file system structure is block, inodes are packed in blocks
-
 
308
        ; FIXME
312
        ; minimal file system structure is block, inodes are packed in blocks
309
        mov     eax, [edi+XFS.blocksize]
313
        mov     eax, [edi+XFS.blocksize]
310
        call    malloc
314
        call    malloc
311
        mov     [edi+XFS.cur_inode], eax
315
        mov     [edi+XFS.cur_inode], eax
312
        test    eax, eax
316
        test    eax, eax
Line 673... Line 677...
673
        mov     edx, [_out_buf]
677
        mov     edx, [_out_buf]
674
        mov     [ebp+XFS.cur_inode_save], ebx
678
        mov     [ebp+XFS.cur_inode_save], ebx
675
        mov     [ebp+XFS.entries_read], 0
679
        mov     [ebp+XFS.entries_read], 0
676
        mov     eax, ebx
680
        mov     eax, ebx
677
        add     eax, [ebp+XFS.inode_core_size]
681
        add     eax, [ebp+XFS.inode_core_size]
678
        movbe   edx, [ebx+xfs_inode.di_core.di_nextents]
682
        mov     edx, [ebp+XFS.nextents_offset]
-
 
683
        movbe   edx, [ebx+edx]
679
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.lo]
684
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.lo]
680
        mov     [ebp+XFS.offset_begin.lo], ecx
685
        mov     [ebp+XFS.offset_begin.lo], ecx
681
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.hi]
686
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.hi]
682
        mov     [ebp+XFS.offset_begin.hi], ecx
687
        mov     [ebp+XFS.offset_begin.hi], ecx
683
        mov     ecx, [ebp+XFS.dir2_free_offset_blocks.lo]
688
        mov     ecx, [ebp+XFS.dir2_free_offset_blocks.lo]
Line 690... Line 695...
690
        mov     edx, [_out_buf]
695
        mov     edx, [_out_buf]
691
        mov     [edx+bdfe_hdr.total_cnt], eax
696
        mov     [edx+bdfe_hdr.total_cnt], eax
692
        mov     [ebp+XFS.entries_left_in_dir], eax
697
        mov     [ebp+XFS.entries_left_in_dir], eax
693
        add     [_out_buf], sizeof.bdfe_hdr
698
        add     [_out_buf], sizeof.bdfe_hdr
694
        mov     [ebp+XFS.entries_read], 0
699
        mov     [ebp+XFS.entries_read], 0
695
        movbe   edx, [ebx+xfs_inode.di_core.di_nextents]
700
        mov     edx, [ebp+XFS.nextents_offset]
-
 
701
        movbe   edx, [ebx+edx]
696
        mov     eax, ebx
702
        mov     eax, ebx
697
        add     eax, [ebp+XFS.inode_core_size]
703
        add     eax, [ebp+XFS.inode_core_size]
698
        lea     ecx, [_out_buf]
704
        lea     ecx, [_out_buf]
699
        push    ecx
705
        push    ecx
700
        mov     [ebp+XFS.offset_begin.lo], 0
706
        mov     [ebp+XFS.offset_begin.lo], 0
Line 773... Line 779...
773
        movi    eax, ERROR_FS_FAIL
779
        movi    eax, ERROR_FS_FAIL
774
        jnz     .error
780
        jnz     .error
775
        mov     eax, ebx
781
        mov     eax, ebx
776
        add     eax, [ebp+XFS.dirblocksize]
782
        add     eax, [ebp+XFS.dirblocksize]
777
        mov     [ebp+XFS.max_dirblockaddr], eax
783
        mov     [ebp+XFS.max_dirblockaddr], eax
778
;        add     ebx, xfs_dir2_block.u
-
 
779
        add     ebx, [ebp+XFS.dir_block_size]
784
        add     ebx, [ebp+XFS.dir_block_size]
780
.next:
785
.next:
781
        movi    eax, ERROR_SUCCESS
786
        movi    eax, ERROR_SUCCESS
782
        cmp     [ebp+XFS.requested_cnt], 0
787
        cmp     [ebp+XFS.requested_cnt], 0
783
        jz      .quit
788
        jz      .quit
Line 795... Line 800...
795
 
800
 
796
proc xfs._.readdir_btree uses esi, _inode_data, _out_buf
801
proc xfs._.readdir_btree uses esi, _inode_data, _out_buf
797
        mov     [ebp+XFS.cur_inode_save], ebx
802
        mov     [ebp+XFS.cur_inode_save], ebx
798
        mov     [ebp+XFS.entries_read], 0
803
        mov     [ebp+XFS.entries_read], 0
799
        mov     eax, [ebp+XFS.inodesize]
804
        mov     eax, [ebp+XFS.inodesize]
800
        sub     eax, xfs_inode.di_u
805
        sub     eax, [ebp+XFS.inode_core_size]
801
        movzx   ecx, [ebx+xfs_inode.di_core.di_forkoff]
806
        movzx   ecx, [ebx+xfs_inode.di_core.di_forkoff]
802
        jecxz   @f
807
        jecxz   @f
803
        shl     ecx, 3
808
        shl     ecx, 3
804
        mov     eax, ecx
809
        mov     eax, ecx
-
 
810
@@:
805
@@:
811
        mov     edx, ebx
806
        lea     edx, [ebx+xfs_inode.di_u]
812
        add     edx, [ebp+XFS.inode_core_size]
807
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.lo]
813
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.lo]
808
        mov     [ebp+XFS.offset_begin.lo], ecx
814
        mov     [ebp+XFS.offset_begin.lo], ecx
809
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.hi]
815
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.hi]
810
        mov     [ebp+XFS.offset_begin.hi], ecx
816
        mov     [ebp+XFS.offset_begin.hi], ecx
Line 818... Line 824...
818
        mov     [edx+bdfe_hdr.total_cnt], eax
824
        mov     [edx+bdfe_hdr.total_cnt], eax
819
        mov     [ebp+XFS.entries_left_in_dir], eax
825
        mov     [ebp+XFS.entries_left_in_dir], eax
820
        mov     [ebp+XFS.entries_read], 0
826
        mov     [ebp+XFS.entries_read], 0
821
        add     [_out_buf], sizeof.bdfe_hdr
827
        add     [_out_buf], sizeof.bdfe_hdr
822
        mov     eax, [ebp+XFS.inodesize]
828
        mov     eax, [ebp+XFS.inodesize]
823
        sub     eax, xfs_inode.di_u
829
        sub     eax, [ebp+XFS.inode_core_size]
824
        movzx   ecx, [ebx+xfs_inode.di_core.di_forkoff]
830
        movzx   ecx, [ebx+xfs_inode.di_core.di_forkoff]
825
        jecxz   @f
831
        jecxz   @f
826
        shl     ecx, 3
832
        shl     ecx, 3
827
        mov     eax, ecx
833
        mov     eax, ecx
828
@@:
834
@@:
-
 
835
        mov     edx, ebx
829
        lea     edx, [ebx+xfs_inode.di_u]
836
        add     edx, [ebp+XFS.inode_core_size]
830
        mov     [ebp+XFS.offset_begin.lo], 0
837
        mov     [ebp+XFS.offset_begin.lo], 0
831
        mov     [ebp+XFS.offset_begin.hi], 0
838
        mov     [ebp+XFS.offset_begin.hi], 0
832
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.lo]
839
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.lo]
833
        mov     [ebp+XFS.offset_end.lo], ecx
840
        mov     [ebp+XFS.offset_end.lo], ecx
834
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.hi]
841
        mov     ecx, [ebp+XFS.dir2_leaf_offset_blocks.hi]
Line 1046... Line 1053...
1046
        jz      .extents
1053
        jz      .extents
1047
        cmp     [ebx+xfs_inode.di_core.di_format], XFS_DINODE_FMT_BTREE
1054
        cmp     [ebx+xfs_inode.di_core.di_format], XFS_DINODE_FMT_BTREE
1048
        jz      .btree
1055
        jz      .btree
1049
        jmp     .error
1056
        jmp     .error
1050
.extents:
1057
.extents:
1051
        movbe   ecx, [ebx+xfs_inode.di_core.di_nextents]
1058
        mov     ecx, [ebp+XFS.nextents_offset]
-
 
1059
        movbe   ecx, [ebx+ecx]
1052
        add     ebx, [ebp+XFS.inode_core_size]
1060
        add     ebx, [ebp+XFS.inode_core_size]
1053
        mov     [ebp+XFS.offset_begin.lo], eax
1061
        mov     [ebp+XFS.offset_begin.lo], eax
1054
        mov     [ebp+XFS.offset_begin.hi], edx
1062
        mov     [ebp+XFS.offset_begin.hi], edx
1055
        stdcall xfs._.extent_list.seek, ecx
1063
        stdcall xfs._.extent_list.seek, ecx
1056
        stdcall xfs._.read_dirblock, [ebp+XFS.extent.br_startblock.lo], [ebp+XFS.extent.br_startblock.hi], [ebp+XFS.cur_dirblock]
1064
        stdcall xfs._.read_dirblock, [ebp+XFS.extent.br_startblock.lo], [ebp+XFS.extent.br_startblock.hi], [ebp+XFS.cur_dirblock]
Line 1079... Line 1087...
1079
        ret
1087
        ret
1080
endp
1088
endp
Line 1081... Line 1089...
1081
 
1089
 
1082
 
1090
 
-
 
1091
proc xfs._.lookup_leaf uses ebx esi edi, _name, _len
1083
proc xfs._.lookup_leaf uses ebx esi edi, _name, _len
1092
        mov     ecx, [ebp+XFS.nextents_offset]
1084
        movbe   ecx, [ebx+xfs_inode.di_core.di_nextents]
1093
        movbe   ecx, [ebx+ecx]
1085
        add     ebx, [ebp+XFS.inode_core_size]
1094
        add     ebx, [ebp+XFS.inode_core_size]
1086
        mov     eax, [ebp+XFS.dir2_leaf_offset_blocks.lo]
1095
        mov     eax, [ebp+XFS.dir2_leaf_offset_blocks.lo]
1087
        mov     [ebp+XFS.offset_begin.lo], ecx
1096
        mov     [ebp+XFS.offset_begin.lo], ecx
Line 1122... Line 1131...
1122
        .hash dd ?
1131
        .hash dd ?
1123
endl
1132
endl
1124
        mov     [ebp+XFS.cur_inode_save], ebx
1133
        mov     [ebp+XFS.cur_inode_save], ebx
1125
        stdcall xfs_hashname, [_name+4], [_len]
1134
        stdcall xfs_hashname, [_name+4], [_len]
1126
        mov     [.hash], eax
1135
        mov     [.hash], eax
1127
        mov     eax, ebx
-
 
1128
        add     eax, [ebp+XFS.inode_core_size]
1136
        mov     edx, [ebp+XFS.nextents_offset]
1129
        movbe   edx, [ebx+xfs_inode.di_core.di_nextents]
1137
        movbe   edx, [ebx+edx]
1130
        mov     esi, [ebp+XFS.dir2_leaf_offset_blocks.lo]
1138
        mov     esi, [ebp+XFS.dir2_leaf_offset_blocks.lo]
1131
.begin:
1139
.begin:
1132
        mov     ebx, [ebp+XFS.cur_inode_save]
1140
        mov     ebx, [ebp+XFS.cur_inode_save]
1133
        mov     eax, ebx
1141
        mov     eax, ebx
1134
        add     eax, [ebp+XFS.inode_core_size]
1142
        add     eax, [ebp+XFS.inode_core_size]
1135
        movbe   edx, [ebx+xfs_inode.di_core.di_nextents]
1143
        mov     edx, [ebp+XFS.nextents_offset]
-
 
1144
        movbe   edx, [ebx+edx]
1136
        mov     ebx, eax
1145
        mov     ebx, eax
1137
        mov     [ebp+XFS.offset_begin.lo], esi
1146
        mov     [ebp+XFS.offset_begin.lo], esi
1138
        mov     [ebp+XFS.offset_begin.hi], 0
1147
        mov     [ebp+XFS.offset_begin.hi], 0
1139
        stdcall xfs._.extent_list.seek, edx
1148
        stdcall xfs._.extent_list.seek, edx
1140
        stdcall xfs._.read_dirblock, [ebp+XFS.extent.br_startblock.lo], [ebp+XFS.extent.br_startblock.hi], [ebp+XFS.cur_dirblock]
1149
        stdcall xfs._.read_dirblock, [ebp+XFS.extent.br_startblock.lo], [ebp+XFS.extent.br_startblock.hi], [ebp+XFS.cur_dirblock]
Line 1212... Line 1221...
1212
        movzx   ecx, [ebx+xfs_inode.di_core.di_forkoff]
1221
        movzx   ecx, [ebx+xfs_inode.di_core.di_forkoff]
1213
        shl     ecx, 3
1222
        shl     ecx, 3
1214
        test    ecx, ecx
1223
        test    ecx, ecx
1215
        jnz     @f
1224
        jnz     @f
1216
        mov     ecx, [ebp+XFS.inodesize]
1225
        mov     ecx, [ebp+XFS.inodesize]
1217
        sub     ecx, xfs_inode.di_u
1226
        sub     ecx, [ebp+XFS.inode_core_size]
1218
@@:
1227
@@:
1219
        add     ebx, xfs_inode.di_u
1228
        add     ebx, [ebp+XFS.inode_core_size]
1220
        stdcall xfs._.btree_read_block, ebx, ecx, eax, edx, [ebp+XFS.cur_dirblock]
1229
        stdcall xfs._.btree_read_block, ebx, ecx, eax, edx, [ebp+XFS.cur_dirblock]
1221
        mov     ebx, [ebp+XFS.cur_dirblock]
1230
        mov     ebx, [ebp+XFS.cur_dirblock]
1222
        cmp     [ebx+xfs_da_intnode.hdr.info.magic], XFS_DA_NODE_MAGIC
1231
        cmp     [ebx+xfs_da_intnode.hdr.info.magic], XFS_DA_NODE_MAGIC
1223
        jz      .next_level
1232
        jz      .next_level
1224
        cmp     [ebx+xfs_dir2_leaf.hdr.info.magic], XFS_DIR2_LEAFN_MAGIC
1233
        cmp     [ebx+xfs_dir2_leaf.hdr.info.magic], XFS_DIR2_LEAFN_MAGIC
Line 1443... Line 1452...
1443
        ret
1452
        ret
1444
endp
1453
endp
Line 1445... Line 1454...
1445
 
1454
 
1446
 
1455
 
1447
proc xfs._.extent_unpack uses eax ebx ecx edx, _extent_data
1456
proc xfs._.extent_unpack uses eax ebx ecx edx, _extent_data
1448
        ; extents come as packet 128bit bitfields
1457
        ; extents come as packed 128bit bitfields
1449
        ; unpack them to access internal fields
1458
        ; unpack them to access internal fields
Line 1450... Line 1459...
1450
        ; write result to the XFS.extent structure
1459
        ; write result to the XFS.extent structure
Line 1781... Line 1790...
1781
        cmp     [ebx+xfs_inode.di_core.di_format], XFS_DINODE_FMT_BTREE
1790
        cmp     [ebx+xfs_inode.di_core.di_format], XFS_DINODE_FMT_BTREE
1782
        jz      .btree
1791
        jz      .btree
1783
.extent_list:
1792
.extent_list:
1784
        mov     eax, ebx
1793
        mov     eax, ebx
1785
        add     eax, [ebp+XFS.inode_core_size]
1794
        add     eax, [ebp+XFS.inode_core_size]
1786
        movbe   edx, [ebx+xfs_inode.di_core.di_nextents]
1795
        mov     edx, [ebp+XFS.nextents_offset]
-
 
1796
        movbe   edx, [ebx+edx]
1787
        mov     ecx, [.offset_begin.lo]
1797
        mov     ecx, [.offset_begin.lo]
1788
        mov     [ebp+XFS.offset_begin.lo], ecx
1798
        mov     [ebp+XFS.offset_begin.lo], ecx
1789
        mov     ecx, [.offset_begin.hi]
1799
        mov     ecx, [.offset_begin.hi]
1790
        mov     [ebp+XFS.offset_begin.hi], ecx
1800
        mov     [ebp+XFS.offset_begin.hi], ecx
1791
        mov     ecx, [.offset_end.lo]
1801
        mov     ecx, [.offset_end.lo]
Line 1920... Line 1930...
1920
        xchg    cl, ch
1930
        xchg    cl, ch
1921
        add     ebx, sizeof.xfs_bmdr_block
1931
        add     ebx, sizeof.xfs_bmdr_block
1922
        jmp     .common
1932
        jmp     .common
1923
.not_root:
1933
.not_root:
1924
        mov     esi, [ebp+XFS.blocksize]
1934
        mov     esi, [ebp+XFS.blocksize]
1925
        sub     esi, sizeof.xfs_bmbt_block
1935
        sub     esi, [ebp+XFS.bmbt_block_size]
1926
        shr     esi, 4
1936
        shr     esi, 4
1927
        shl     esi, 3
1937
        shl     esi, 3
1928
        movzx   eax, [ebx+xfs_bmbt_block.bb_level]
1938
        movzx   eax, [ebx+xfs_bmbt_block.bb_level]
1929
        movzx   ecx, [ebx+xfs_bmbt_block.bb_numrecs]
1939
        movzx   ecx, [ebx+xfs_bmbt_block.bb_numrecs]
1930
        xchg    cl, ch
1940
        xchg    cl, ch
1931
        add     ebx, sizeof.xfs_bmbt_block
1941
        add     ebx, [ebp+XFS.bmbt_block_size]
1932
.common:
1942
.common:
1933
        test    eax, eax
1943
        test    eax, eax
1934
        jz      .leaf
1944
        jz      .leaf
1935
.node:
1945
.node:
1936
.next_rec:
1946
.next_rec:
Line 2127... Line 2137...
2127
        ret
2137
        ret
2128
endp
2138
endp
Line 2129... Line 2139...
2129
 
2139
 
2130
 
2140
 
-
 
2141
proc xfs._.get_last_dirblock uses ecx
2131
proc xfs._.get_last_dirblock uses ecx
2142
        mov     eax, [ebp+XFS.nextents_offset]
2132
        movbe   eax, [ebx+xfs_inode.di_core.di_nextents]
2143
        movbe   eax, [ebx+eax]
2133
assert (sizeof.xfs_bmbt_rec AND (sizeof.xfs_bmbt_rec - 1)) = 0
2144
assert (sizeof.xfs_bmbt_rec AND (sizeof.xfs_bmbt_rec - 1)) = 0
2134
        shl     eax, BSF sizeof.xfs_bmbt_rec
2145
        shl     eax, BSF sizeof.xfs_bmbt_rec
2135
        add     eax, [ebp+XFS.inode_core_size]
2146
        add     eax, [ebp+XFS.inode_core_size]