Subversion Repositories Kolibri OS

Rev

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

Rev 6468 Rev 6471
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2016. 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: 6468 $
8
$Revision: 6471 $
9
 
9
 
10
; NTFS external functions
10
; NTFS external functions
11
;   in:
11
;   in:
12
; ebx -> parameter structure of sysfunc 70
12
; ebx -> parameter structure of sysfunc 70
13
; ebp -> NTFS structure
13
; ebp -> NTFS structure
14
; esi -> path string
14
; esi -> path string in UTF-8
15
;   out:
15
;   out:
16
; eax, ebx = return values for sysfunc 70
16
; eax, ebx = return values for sysfunc 70
17
iglobal
17
iglobal
Line 1159... Line 1159...
1159
        stc
1159
        stc
1160
.end:
1160
.end:
1161
        pop     edi ecx eax
1161
        pop     edi ecx eax
1162
        ret
1162
        ret
Line 1163... Line -...
1163
 
-
 
1164
unichar_toupper:
-
 
1165
        push    eax
-
 
1166
        call    uni2ansi_char
-
 
1167
        cmp     al, '_'
-
 
1168
        jz      .unk
-
 
1169
        add     esp, 4
-
 
1170
        call    char_toupper
-
 
1171
        jmp     ansi2uni_char
-
 
1172
.unk:
-
 
1173
        pop     eax
-
 
1174
        ret
-
 
1175
 
1163
 
1176
ntfs_find_lfn:
1164
ntfs_find_lfn:
1177
; in: esi -> path string
1165
; in: esi -> path string in UTF-8
1178
;   out:
1166
;   out:
1179
; [ebp+NTFS.cur_iRecord] = target fileRecord
1167
; [ebp+NTFS.cur_iRecord] = target fileRecord
1180
; eax -> target index in the node
1168
; eax -> target index in the node
1181
; [ebp+NTFS.LastRead] = target node location
1169
; [ebp+NTFS.LastRead] = target node location
Line 1212... Line 1200...
1212
        add     esi, rootNode
1200
        add     esi, rootNode
1213
        mov     eax, [esi+nodeRealSize]
1201
        mov     eax, [esi+nodeRealSize]
1214
        add     eax, rootNode
1202
        add     eax, rootNode
1215
        cmp     [ebp+NTFS.cur_read], eax
1203
        cmp     [ebp+NTFS.cur_read], eax
1216
        jc      .err
1204
        jc      .err
1217
        mov     edi, [esp+4]
-
 
1218
        mov     eax, [ebp+NTFS.mftLastRead]
1205
        mov     eax, [ebp+NTFS.mftLastRead]
1219
        mov     [ebp+NTFS.rootLastRead], eax
1206
        mov     [ebp+NTFS.rootLastRead], eax
1220
        mov     eax, [ebp+NTFS.attr_offs]
1207
        mov     eax, [ebp+NTFS.attr_offs]
1221
        mov     [ebp+NTFS.indexRoot], eax
1208
        mov     [ebp+NTFS.indexRoot], eax
1222
; edi -> name, esi -> current index node
1209
.scanloop:  ; esi -> current index node
1223
.scanloop:
-
 
1224
        add     esi, [esi+indexOffset]
1210
        add     esi, [esi+indexOffset]
1225
.scanloopint:
1211
.scanloopint:
-
 
1212
        push    esi
1226
        test    byte [esi+indexFlags], 2
1213
        test    byte [esi+indexFlags], 2
1227
        jnz     .subnode
1214
        jnz     .subnode
1228
        push    esi
-
 
1229
        movzx   ecx, byte [esi+fileNameLength]
1215
        movzx   ecx, byte [esi+fileNameLength]
1230
        add     esi, fileName
1216
        lea     edi, [esi+fileName]
1231
        push    edi
1217
        mov     esi, [esp+8]
1232
@@:
1218
@@:
-
 
1219
        call    utf8to16
-
 
1220
        cmp     ax, '/'
1233
        lodsw
1221
        jz      .subnode
1234
        call    unichar_toupper
1222
        call    utf16toUpper
1235
        push    eax
1223
        push    eax
1236
        mov     al, [edi]
1224
        mov     ax, [edi]
1237
        inc     edi
-
 
1238
        cmp     al, '/'
-
 
1239
        jz      .slash
-
 
1240
        call    char_toupper
1225
        call    utf16toUpper
1241
        call    ansi2uni_char
-
 
1242
        cmp     ax, [esp]
1226
        cmp     [esp], ax
1243
        pop     eax
1227
        pop     eax
-
 
1228
        jc      .subnode
-
 
1229
        jnz     .scanloopcont
-
 
1230
        add     edi, 2
1244
        loopz   @b
1231
        loop    @b
-
 
1232
        call    utf8to16
-
 
1233
        cmp     ax, '/'
-
 
1234
        jz      .found
-
 
1235
        test    ax, ax
1245
        jz      .found
1236
        jz      .found
1246
        pop     edi
-
 
1247
        pop     esi
-
 
1248
        jb      .subnode
-
 
1249
.scanloopcont:
1237
.scanloopcont:
-
 
1238
        pop     esi
1250
        movzx   eax, word [esi+indexAllocatedSize]
1239
        movzx   eax, word [esi+indexAllocatedSize]
1251
        add     esi, eax
1240
        add     esi, eax
1252
        jmp     .scanloopint
1241
        jmp     .scanloopint
Line 1253... Line 1242...
1253
 
1242
 
Line 1271... Line 1260...
1271
        popad
1260
        popad
1272
        pop     eax
1261
        pop     eax
1273
        jmp     .doit2
1262
        jmp     .doit2
Line 1274... Line 1263...
1274
 
1263
 
1275
.notfound:
1264
.notfound:
1276
        mov     [esp+1Ch], esi
1265
        mov     [esp+28], esi
1277
.err:
1266
.err:
1278
        popad
1267
        popad
1279
        stc
1268
        stc
1280
.ret2:
1269
.ret2:
1281
        pop     esi
1270
        pop     esi
1282
.ret:
1271
.ret:
Line 1283... Line -...
1283
        ret
-
 
1284
 
-
 
1285
.slash:
-
 
1286
        pop     eax
-
 
1287
        pop     edi
1272
        ret
-
 
1273
 
1288
        pop     esi
1274
.subnode:
1289
.subnode:
1275
        pop     esi
1290
        test    byte [esi+indexFlags], 1
1276
        test    byte [esi+indexFlags], 1
1291
        jz      .notfound
1277
        jz      .notfound
1292
        mov     eax, [ebp+NTFS.LastRead]
1278
        mov     eax, [ebp+NTFS.LastRead]
Line 1319... Line 1305...
1319
        jc      .err
1305
        jc      .err
1320
        add     esi, recordNode
1306
        add     esi, recordNode
1321
        jmp     .scanloop
1307
        jmp     .scanloop
Line 1322... Line 1308...
1322
 
1308
 
1323
.found:
-
 
1324
        cmp     byte [edi], 0
-
 
1325
        jz      @f
-
 
1326
        cmp     byte [edi], '/'
-
 
1327
        jz      @f
-
 
1328
        pop     edi
1309
.found:
1329
        pop     esi
-
 
1330
        jmp     .scanloopcont
-
 
1331
 
-
 
1332
@@:
1310
        mov     [esp+8], esi
1333
        pop     esi
1311
        pop     eax
1334
        pop     esi
1312
        mov     [esp+28], eax
1335
        mov     eax, [esi]
1313
        mov     eax, [eax+fileRecordReference]
1336
        mov     [ebp+NTFS.cur_iRecord], eax
-
 
1337
        mov     [esp+1Ch], esi
-
 
1338
        mov     [esp+4], edi
1314
        mov     [ebp+NTFS.cur_iRecord], eax
1339
        popad
1315
        popad
1340
        cmp     byte [esi], 0
1316
        cmp     byte [esi-1], 0
1341
        jz      .ret2
-
 
1342
        inc     esi
1317
        jz      .ret2
1343
        pop     eax
1318
        pop     eax
Line 1344... Line 1319...
1344
        jmp     .doit2
1319
        jmp     .doit2
1345
 
1320
 
Line 1857... Line 1832...
1857
        jz      .end
1832
        jz      .end
1858
@@:
1833
@@:
1859
        lodsw
1834
        lodsw
1860
        call    uni2ansi_char
1835
        call    uni2ansi_char
1861
        stosb
1836
        stosb
1862
        dec     ecx
-
 
1863
        jnz     @b
1837
        loop    @b
1864
        mov     byte [edi], 0
1838
        mov     byte [edi], 0
1865
        jmp     .end
1839
        jmp     .end
Line 1866... Line 1840...
1866
 
1840
 
1867
;----------------------------------------------------------------
1841
;----------------------------------------------------------------
Line 1962... Line 1936...
1962
        test    eax, eax
1936
        test    eax, eax
1963
        jz      ntfsFail
1937
        jz      ntfsFail
1964
        cmp     [ebp+NTFS.fragmentCount], 1
1938
        cmp     [ebp+NTFS.fragmentCount], 1
1965
        jnz     ntfsUnsupported     ; record fragmented
1939
        jnz     ntfsUnsupported     ; record fragmented
1966
; 2. Prepare directory record
1940
; 2. Prepare directory record
1967
        mov     ecx, esi
1941
        mov     edi, esi
-
 
1942
        mov     edx, eax
-
 
1943
        xor     ecx, ecx
1968
@@:         ; count characters
1944
@@:         ; count characters
1969
        inc     ecx
1945
        call    utf8to16
1970
        cmp     byte [ecx], '/'
1946
        cmp     ax, '/'
1971
        jz      ntfsNotFound    ; path folder not found
1947
        jz      ntfsNotFound    ; path folder not found
1972
        cmp     byte [ecx], 0
1948
        inc     ecx
-
 
1949
        test    ax, ax
1973
        jnz     @b
1950
        jnz     @b
1974
        sub     ecx, esi
1951
        dec     ecx
1975
        push    ecx     ; name length
1952
        push    ecx     ; name length in chars
-
 
1953
        push    edi
1976
        shl     ecx, 1
1954
        shl     ecx, 1
1977
        add     ecx, fileName+7
1955
        add     ecx, fileName+7
1978
        and     ecx, not 7
1956
        and     ecx, not 7
1979
        mov     edi, [ebp+NTFS.cur_index_buf]
1957
        mov     edi, [ebp+NTFS.cur_index_buf]
1980
        mov     edx, [ebx+12]
1958
        mov     eax, [ebx+12]
1981
        mov     [ebp+NTFS.fileRealSize], edx
1959
        mov     [ebp+NTFS.fileRealSize], eax
1982
        mov     edx, [ebx+16]
1960
        mov     eax, [ebx+16]
1983
        mov     [ebp+NTFS.fileDataBuffer], edx
1961
        mov     [ebp+NTFS.fileDataBuffer], eax
1984
        push    esi
-
 
1985
        push    ecx     ; index length
1962
        push    ecx     ; index length
-
 
1963
        mov     eax, edx
1986
        mov     edx, ecx
1964
        mov     edx, ecx
1987
        cmp     dword [edi], 'INDX'
1965
        cmp     dword [edi], 'INDX'
1988
        jz      .indexRecord
1966
        jz      .indexRecord
1989
        mov     esi, [ebp+NTFS.frs_buffer]  ; indexRoot
1967
        mov     esi, [ebp+NTFS.frs_buffer]  ; indexRoot
1990
        mov     ecx, [esi+recordRealSize]
1968
        mov     ecx, [esi+recordRealSize]
Line 2481... Line 2459...
2481
        pop     ecx
2459
        pop     ecx
2482
        mov     [ebp+NTFS.indexPointer], edi
2460
        mov     [ebp+NTFS.indexPointer], edi
2483
        mov     [edi+fileNameLength], cl
2461
        mov     [edi+fileNameLength], cl
2484
        add     edi, fileName
2462
        add     edi, fileName
2485
@@:         ; record filename
2463
@@:         ; record filename
2486
        lodsb
-
 
2487
        call    ansi2uni_char
2464
        call    utf8to16
2488
        stosw
2465
        stosw
2489
        dec     ecx
-
 
2490
        jnz     @b
2466
        loop    @b
2491
        mov     eax, [ebp+NTFS.LastRead]
2467
        mov     eax, [ebp+NTFS.LastRead]
2492
        mov     [ebp+NTFS.nodeLastRead], eax
2468
        mov     [ebp+NTFS.nodeLastRead], eax
2493
        cmp     [ebp+NTFS.bFolder], 0
2469
        cmp     [ebp+NTFS.bFolder], 0
2494
        jz      @f
2470
        jz      @f
2495
        mov     edi, [ebp+NTFS.indexPointer]
2471
        mov     edi, [ebp+NTFS.indexPointer]
Line 2803... Line 2779...
2803
        push    ecx
2779
        push    ecx
2804
@@:
2780
@@:
2805
        add     esi, 510
2781
        add     esi, 510
2806
        movsw
2782
        movsw
2807
        mov     [esi-2], ax
2783
        mov     [esi-2], ax
2808
        dec     ecx
-
 
2809
        jnz     @b
2784
        loop    @b
2810
        mov     eax, edx
2785
        mov     eax, edx
2811
        xor     edx, edx
2786
        xor     edx, edx
2812
        pop     ecx
2787
        pop     ecx
2813
        jmp     fs_write64_sys
2788
        jmp     fs_write64_sys