Subversion Repositories Kolibri OS

Rev

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

Rev 6849 Rev 6852
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2013-2016. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2013-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: 6849 $
8
$Revision: 6852 $
9
 
9
 
10
; EXT external functions
10
; EXT external functions
11
;   in:
11
;   in:
Line 155... Line 155...
155
READ_ONLY_SUPPORT = 3
155
READ_ONLY_SUPPORT = 3
Line 156... Line 156...
156
 
156
 
157
struct EXTFS PARTITION
157
struct EXTFS PARTITION
158
Lock                MUTEX
158
Lock                MUTEX
159
mountType           dd  ?
-
 
160
sectorsPerBlockLog  dd  ?   ; shift for 512
159
mountType           dd  ?
161
bytesPerBlock       dd  ?
160
bytesPerBlock       dd  ?
162
sectorsPerBlock     dd  ?
161
sectorsPerBlock     dd  ?
163
dwordsPerBlock      dd  ?
162
dwordsPerBlock      dd  ?
164
dwordsPerBranch     dd  ?   ; dwordsPerBlock ^ 2
163
dwordsPerBranch     dd  ?   ; dwordsPerBlock ^ 2
Line 197... Line 196...
197
        ja      .fail
196
        ja      .fail
198
        test    [ebx+SUPERBLOCK.incompatibleFlags], not INCOMPATIBLE_SUPPORT
197
        test    [ebx+SUPERBLOCK.incompatibleFlags], not INCOMPATIBLE_SUPPORT
199
        jnz     .fail
198
        jnz     .fail
200
        cmp     [ebx+SUPERBLOCK.sectorsPerBlockLog], 6  ; 64KB
199
        cmp     [ebx+SUPERBLOCK.sectorsPerBlockLog], 6  ; 64KB
201
        ja      .fail
200
        ja      .fail
202
        cmp     [ebx+SUPERBLOCK.inodeSize], 1024
201
        cmp     [ebx+SUPERBLOCK.inodeSize], 512
203
        ja      .fail
202
        ja      .fail
204
        cmp     [ebx+SUPERBLOCK.blocksPerGroup], 0
203
        cmp     [ebx+SUPERBLOCK.blocksPerGroup], 0
205
        je      .fail
204
        je      .fail
206
        cmp     [ebx+SUPERBLOCK.inodesPerGroup], 0
205
        cmp     [ebx+SUPERBLOCK.inodesPerGroup], 0
207
        je      .fail
206
        je      .fail
Line 229... Line 228...
229
        lea     edi, [ebp+EXTFS.superblock]
228
        lea     edi, [ebp+EXTFS.superblock]
230
        mov     ecx, 512/4
229
        mov     ecx, 512/4
231
        rep movsd   ; copy superblock
230
        rep movsd   ; copy superblock
232
        mov     ecx, [ebx+SUPERBLOCK.sectorsPerBlockLog]
231
        mov     ecx, [ebx+SUPERBLOCK.sectorsPerBlockLog]
233
        inc     ecx
232
        inc     ecx
234
        mov     [ebp+EXTFS.sectorsPerBlockLog], ecx
-
 
235
        mov     eax, 1
233
        mov     eax, 1
236
        shl     eax, cl
234
        shl     eax, cl
237
        mov     [ebp+EXTFS.sectorsPerBlock], eax
235
        mov     [ebp+EXTFS.sectorsPerBlock], eax
238
        shl     eax, 9
236
        shl     eax, 9
239
        mov     [ebp+EXTFS.bytesPerBlock], eax
237
        mov     [ebp+EXTFS.bytesPerBlock], eax
Line 816... Line 814...
816
        pop     eax
814
        pop     eax
817
        cmp     eax, ROOT_INODE
815
        cmp     eax, ROOT_INODE
818
        jnz     @f
816
        jnz     @f
819
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
817
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
820
        mov     esi, edi
818
        mov     esi, edi
821
        mov     edi, [ebp+EXTFS.rootInodeBuffer]
819
        lea     edi, [ebp+EXTFS.rootInodeBuffer]
822
        rep movsb
820
        rep movsb
823
@@:
821
@@:
824
        call    getInodeLocation
822
        call    getInodeLocation
825
        jc      .ret
-
 
826
        mov     ebx, [ebp+EXTFS.tempBlockBuffer]
823
        mov     ebx, [ebp+EXTFS.tempBlockBuffer]
827
        mov     ecx, eax
824
        mov     ecx, eax
828
        call    fs_read32_sys
825
        call    fs_read32_sys
829
        test    eax, eax
826
        test    eax, eax
830
        jnz     @f
827
        jnz     @f
Line 847... Line 844...
847
readInode:
844
readInode:
848
; in: eax = inode number, ebx -> inode buffer
845
; in: eax = inode number, ebx -> inode buffer
849
        push    edx edi esi ecx ebx
846
        push    edx edi esi ecx ebx
850
        mov     edi, ebx
847
        mov     edi, ebx
851
        call    getInodeLocation
848
        call    getInodeLocation
852
        jc      @f
-
 
853
        mov     ebx, [ebp+EXTFS.tempBlockBuffer]
849
        mov     ebx, [ebp+EXTFS.tempBlockBuffer]
854
        call    fs_read32_sys
850
        call    fs_read32_sys
855
        test    eax, eax
851
        test    eax, eax
856
        jnz     @b
852
        jnz     @b
857
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
853
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
858
        mov     esi, edx
854
        mov     esi, edx
859
        add     esi, ebx
855
        add     esi, ebx
860
        rep movsb
856
        rep movsb
861
        xor     eax, eax
857
        xor     eax, eax
862
@@:
-
 
863
        pop     ebx ecx esi edi edx
858
        pop     ebx ecx esi edi edx
864
        ret
859
        ret
Line 865... Line 860...
865
 
860
 
866
indirectBlockAlloc:
861
indirectBlockAlloc:
Line 1422... Line 1417...
1422
        xor     ecx, ecx
1417
        xor     ecx, ecx
1423
        lea     esi, [ebp+EXTFS.inodeBuffer]
1418
        lea     esi, [ebp+EXTFS.inodeBuffer]
1424
        mov     ebx, esi
1419
        mov     ebx, esi
1425
        call    readInode
1420
        call    readInode
1426
        jc      .error_inode_read
1421
        jc      .error_inode_read
1427
        mov     ecx, [ebp+EXTFS.sectorsPerBlockLog]
-
 
1428
        add     ecx, 9
-
 
1429
        mov     eax, [esi+INODE.fileSize]
1422
        mov     eax, [esi+INODE.fileSize]
1430
        shr     eax, cl
1423
        xor     edx, edx
-
 
1424
        div     [ebp+EXTFS.bytesPerBlock]
1431
        xor     ecx, ecx
1425
        xor     ecx, ecx
1432
.searchBlock:
1426
.searchBlock:
1433
        push    eax     ; blocks total
1427
        push    eax     ; blocks total
1434
        push    ecx     ; current file block number
1428
        push    ecx     ; current file block number
1435
        cmp     eax, ecx
1429
        cmp     eax, ecx
Line 2310... Line 2304...
2310
        jz      .error
2304
        jz      .error
2311
        mov     eax, esi
2305
        mov     eax, esi
2312
        call    extfsInodeAlloc
2306
        call    extfsInodeAlloc
2313
        jc      .error
2307
        jc      .error
2314
        push    ebx esi edi
2308
        push    ebx esi edi
2315
        xor     al, al
-
 
2316
        lea     edi, [ebp+EXTFS.inodeBuffer]
2309
        lea     edi, [ebp+EXTFS.inodeBuffer]
2317
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
2310
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
-
 
2311
        xor     eax, eax
2318
        rep stosb
2312
        rep stosb
2319
        lea     edi, [ebp+EXTFS.inodeBuffer]
-
 
2320
        call    fsGetTime
2313
        call    fsGetTime
2321
        add     eax, 978307200
2314
        add     eax, 978307200
2322
        mov     [edi+INODE.accessedTime], eax
2315
        lea     ebx, [ebp+EXTFS.inodeBuffer]
2323
        mov     [edi+INODE.dataModified], eax
2316
        mov     [ebx+INODE.accessedTime], eax
2324
        mov     ebx, edi
2317
        mov     [ebx+INODE.dataModified], eax
2325
        pop     edi esi edx
2318
        pop     edi esi edx
2326
; edx = allocated inode number, edi -> filename, esi = parent inode number
2319
; edx = allocated inode number, edi -> filename, esi = parent inode number
2327
        mov     [ebx+INODE.accessMode], DIRECTORY or PERMISSIONS
2320
        mov     [ebx+INODE.accessMode], DIRECTORY or PERMISSIONS
2328
        mov     eax, edx
2321
        mov     eax, edx
2329
        call    writeInode
2322
        call    writeInode
Line 2385... Line 2378...
2385
        jz      .error
2378
        jz      .error
2386
        mov     eax, esi
2379
        mov     eax, esi
2387
        call    extfsInodeAlloc
2380
        call    extfsInodeAlloc
2388
        jc      .error
2381
        jc      .error
2389
        push    ebx ebx esi edi
2382
        push    ebx ebx esi edi
2390
        xor     al, al
-
 
2391
        lea     edi, [ebp+EXTFS.inodeBuffer]
2383
        lea     edi, [ebp+EXTFS.inodeBuffer]
2392
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
2384
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
-
 
2385
        xor     eax, eax
2393
        rep stosb
2386
        rep stosb
2394
        lea     edi, [ebp+EXTFS.inodeBuffer]
-
 
2395
        call    fsGetTime
2387
        call    fsGetTime
2396
        add     eax, 978307200
2388
        add     eax, 978307200
2397
        mov     [edi+INODE.accessedTime], eax
2389
        lea     ebx, [ebp+EXTFS.inodeBuffer]
2398
        mov     [edi+INODE.dataModified], eax
2390
        mov     [ebx+INODE.accessedTime], eax
2399
        mov     ebx, edi
2391
        mov     [ebx+INODE.dataModified], eax
2400
        pop     edi esi edx
2392
        pop     edi esi edx
2401
; edx = allocated inode number, edi -> filename, esi = parent inode number
2393
; edx = allocated inode number, edi -> filename, esi = parent inode number
2402
        mov     [ebx+INODE.accessMode], FLAG_FILE or PERMISSIONS
2394
        mov     [ebx+INODE.accessMode], FLAG_FILE or PERMISSIONS
2403
        mov     eax, edx
2395
        mov     eax, edx
2404
        call    writeInode
2396
        call    writeInode