Subversion Repositories Kolibri OS

Rev

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

Rev 6409 Rev 6411
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: 6409 $
8
$Revision: 6411 $
Line 9... Line 9...
9
 
9
 
10
; NTFS driver
10
; NTFS driver
Line 1173... Line 1173...
1173
 
1173
 
1174
ntfs_find_lfn:
1174
ntfs_find_lfn:
1175
; in: [esi]+[esp+4] = name
1175
; in: [esi]+[esp+4] = name
1176
;   out:
1176
;   out:
1177
; [ebp+NTFS.cur_iRecord] = target fileRecord
1177
; [ebp+NTFS.cur_iRecord] = target fileRecord
-
 
1178
; eax -> target index in the node
1178
; eax -> index in the target node
1179
; [ebp+NTFS.LastRead] = target node location
-
 
1180
; [ebp+NTFS.indexPointer] -> index, that points the target subnode
1179
; [ebp+NTFS.indexPointer] -> index, that points the target subnode
1181
; [ebp+NTFS.nodeLastRead] = branch node location
-
 
1182
; [ebp+NTFS.indexRoot] -> attribute
1180
; [ebp+NTFS.indexRoot] -> attribute
1183
; [ebp+NTFS.rootLastRead] = directory fileRecord location
1181
; [ebp+NTFS.cur_size] = index record size in sectors
1184
; [ebp+NTFS.cur_size] = index record size in sectors
1182
; [ebp+NTFS.cur_subnode_size] = index record size in clusters or sectors
-
 
1183
; [ebp+NTFS.rootLastRead] = directory fileRecord sector
1185
; [ebp+NTFS.cur_subnode_size] = index record size in clusters or sectors
1184
; CF=1 -> file not found, eax=0 -> error
1186
; CF=1 -> file not found, eax=0 -> error
1185
        mov     [ebp+NTFS.cur_iRecord], 5   ; start from root directory
1187
        mov     [ebp+NTFS.cur_iRecord], 5   ; start from root directory
1186
.doit2:
1188
.doit2:
1187
        mov     [ebp+NTFS.cur_attr], 0x90   ; $INDEX_ROOT
1189
        mov     [ebp+NTFS.cur_attr], 0x90   ; $INDEX_ROOT
Line 1279... Line 1281...
1279
        pop     edi
1281
        pop     edi
1280
        pop     esi
1282
        pop     esi
1281
.subnode:
1283
.subnode:
1282
        test    byte [esi+indexFlags], 1
1284
        test    byte [esi+indexFlags], 1
1283
        jz      .notfound
1285
        jz      .notfound
-
 
1286
        mov     eax, [ebp+NTFS.LastRead]
-
 
1287
        mov     [ebp+NTFS.nodeLastRead], eax
-
 
1288
        mov     [ebp+NTFS.indexPointer], esi
1284
        movzx   eax, word [esi+indexAllocatedSize]
1289
        movzx   eax, word [esi+indexAllocatedSize]
1285
        mov     eax, [esi+eax-8]
1290
        mov     eax, [esi+eax-8]
1286
        mov     edx, [ebp+NTFS.cur_size]
1291
        mov     edx, [ebp+NTFS.cur_size]
1287
        push    edx
1292
        push    edx
1288
        cmp     edx, [ebp+NTFS.cur_subnode_size]
1293
        cmp     edx, [ebp+NTFS.cur_subnode_size]
1289
        jz      @f
1294
        jz      @f
1290
        mul     [ebp+NTFS.sectors_per_cluster]
1295
        mul     [ebp+NTFS.sectors_per_cluster]
1291
@@:
1296
@@:
1292
        mov     [ebp+NTFS.indexPointer], esi
-
 
1293
        mov     esi, [ebp+NTFS.cur_index_buf]
1297
        mov     esi, [ebp+NTFS.cur_index_buf]
1294
        xchg    [ebp+NTFS.secondIndexBuffer], esi
1298
        xchg    [ebp+NTFS.secondIndexBuffer], esi
1295
        mov     [ebp+NTFS.cur_index_buf], esi
1299
        mov     [ebp+NTFS.cur_index_buf], esi
1296
        mov     [ebp+NTFS.cur_buf], esi
1300
        mov     [ebp+NTFS.cur_buf], esi
1297
        mov     [ebp+NTFS.cur_attr], 0xA0   ; $INDEX_ALLOCATION
1301
        mov     [ebp+NTFS.cur_attr], 0xA0   ; $INDEX_ALLOCATION
Line 1990... Line 1994...
1990
        sub     eax, [ebp+NTFS.cur_index_buf]
1994
        sub     eax, [ebp+NTFS.cur_index_buf]
1991
        add     eax, edi
1995
        add     eax, edi
1992
        mov     edi, [ebp+NTFS.cur_index_buf]
1996
        mov     edi, [ebp+NTFS.cur_index_buf]
1993
        jmp     .common
1997
        jmp     .common
Line 1994... Line -...
1994
 
-
 
1995
.growTree:
1998
 
1996
        xchg    [ebp+NTFS.secondIndexBuffer], edi
1999
.growTree:  ; create indexRecord
1997
        mov     [ebp+NTFS.cur_index_buf], edi
-
 
1998
; create indexRecord
2000
        mov     edi, [ebp+NTFS.cur_index_buf]
1999
        mov     ecx, 10
2001
        mov     ecx, 10
2000
        xor     eax, eax
2002
        xor     eax, eax
2001
        rep stosd
2003
        rep stosd
2002
        mov     esi, [ebp+NTFS.indexRoot]
2004
        mov     esi, [ebp+NTFS.indexRoot]
Line 2025... Line 2027...
2025
        push    esi
2027
        push    esi
2026
        mov     ecx, [esi+nodeRealSize]
2028
        mov     ecx, [esi+nodeRealSize]
2027
        sub     ecx, [esi+indexOffset]
2029
        sub     ecx, [esi+indexOffset]
2028
        add     eax, ecx
2030
        add     eax, ecx
2029
        mov     [edi+nodeRealSize], eax
2031
        mov     [edi+nodeRealSize], eax
-
 
2032
        mov     eax, [esi+nonLeafFlag]
-
 
2033
        mov     [edi+nonLeafFlag], eax
2030
        shr     ecx, 2
2034
        shr     ecx, 2
2031
        add     esi, [esi+indexOffset]
2035
        add     esi, [esi+indexOffset]
2032
        add     edi, [edi+indexOffset]
2036
        add     edi, [edi+indexOffset]
2033
        rep movsd       ; copy root indexes
2037
        rep movsd       ; copy root indexes
2034
; clear root node
2038
; clear root node
Line 2218... Line 2222...
2218
        sub     ecx, eax
2222
        sub     ecx, eax
2219
        jnc     @b
2223
        jnc     @b
2220
        add     eax, 8
2224
        add     eax, 8
2221
        mov     esi, [ebp+NTFS.secondIndexBuffer]
2225
        mov     esi, [ebp+NTFS.secondIndexBuffer]
2222
        cmp     dword [esi], 'INDX'
2226
        cmp     dword [esi], 'INDX'
2223
        jz      .errorPop3      ; move index to the branch node
2227
        jz      @f
2224
; move index to the root node
2228
; move index to the root node
2225
        mov     esi, [ebp+NTFS.frs_buffer]
2229
        mov     esi, [ebp+NTFS.frs_buffer]
2226
        mov     ecx, eax
2230
        mov     ecx, eax
2227
        add     ecx, 8
2231
        add     ecx, 8
2228
        add     ecx, [esi+recordRealSize]
2232
        add     ecx, [esi+recordRealSize]
2229
        cmp     [esi+recordAllocatedSize], ecx
2233
        cmp     [esi+recordAllocatedSize], ecx
2230
        jc      .errorPop3      ; tree grow required
2234
        jc      .growTree
2231
        push    edi eax
2235
        push    edi eax
2232
        call    .ntfsNodeAlloc
2236
        call    .ntfsNodeAlloc
2233
        pop     ecx edi
2237
        pop     ecx edi
2234
        jc      ntfsErrorPop3
2238
        jc      ntfsErrorPop3
2235
        push    edi
2239
        push    edi
Line 2267... Line 2271...
2267
        shr     ecx, 2
2271
        shr     ecx, 2
2268
        cld
2272
        cld
2269
        rep movsd   ; insert index
2273
        rep movsd   ; insert index
2270
        mov     eax, [ebp+NTFS.newRecord]
2274
        mov     eax, [ebp+NTFS.newRecord]
2271
        stosd
2275
        stosd
-
 
2276
        jmp     .splitNode
-
 
2277
 
-
 
2278
@@:         ; move index to the branch node
-
 
2279
        add     esi, recordNode
-
 
2280
        mov     ecx, [esi+nodeRealSize]
-
 
2281
        add     eax, ecx
-
 
2282
        cmp     [esi+nodeAllocatedSize], eax
-
 
2283
        jc      .errorPop3      ; tree grow required
-
 
2284
        mov     [esi+nodeRealSize], eax
-
 
2285
        push    edi
-
 
2286
        lea     edi, [esi+eax-4]
-
 
2287
        add     esi, ecx
-
 
2288
        sub     eax, ecx
-
 
2289
        mov     ecx, esi
-
 
2290
        sub     ecx, [ebp+NTFS.indexPointer]
-
 
2291
        shr     ecx, 2
-
 
2292
        sub     esi, 4
-
 
2293
        std
-
 
2294
        rep movsd   ; make space
-
 
2295
        mov     [edi], ecx
-
 
2296
        mov     edi, esi
-
 
2297
        add     edi, 4
-
 
2298
        mov     esi, [esp]
-
 
2299
        add     word [esi+indexAllocatedSize], 8
-
 
2300
        mov     byte [esi+indexFlags], 1
-
 
2301
        mov     ecx, eax
-
 
2302
        sub     ecx, 8
-
 
2303
        shr     ecx, 2
-
 
2304
        cld
-
 
2305
        rep movsd   ; insert index
-
 
2306
        push    esi edi
-
 
2307
        call    .ntfsNodeAlloc
-
 
2308
        pop     edi esi ecx
-
 
2309
        jc      ntfsErrorPop3
-
 
2310
        push    ecx
-
 
2311
        mov     eax, [ebp+NTFS.newRecord]
-
 
2312
        stosd
-
 
2313
        mov     ebx, [ebp+NTFS.secondIndexBuffer]
-
 
2314
        mov     edx, [ebp+NTFS.nodeLastRead]
-
 
2315
        push    esi
-
 
2316
        call    writeRecord
-
 
2317
        pop     esi
2272
; split node
2318
.splitNode:
2273
        mov     edi, [ebp+NTFS.cur_index_buf]
2319
        mov     edi, [ebp+NTFS.cur_index_buf]
2274
        mov     eax, edi
2320
        mov     eax, edi
2275
        add     eax, recordNode
2321
        add     eax, recordNode
2276
        add     eax, [edi+recordNode+nodeRealSize]
2322
        add     eax, [edi+recordNode+nodeRealSize]
2277
        sub     eax, esi
2323
        sub     eax, esi