Subversion Repositories Kolibri OS

Rev

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

Rev 6471 Rev 6522
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: 6471 $
8
$Revision: 6522 $
9
 
9
 
10
; EXT external functions
10
; EXT external functions
11
;   in:
11
;   in:
Line 1332... Line 1332...
1332
;   in:
1332
;   in:
1333
; eax = inode from which to unlink
1333
; eax = inode from which to unlink
1334
; ebx = inode to unlink
1334
; ebx = inode to unlink
1335
;   out:
1335
;   out:
1336
; eax = current number of links to inode, -1 = error
1336
; eax = current number of links to inode, -1 = error
1337
        push    edx esi edi ebx
1337
        push    edx ebx
1338
        lea     ebx, [ebp+EXTFS.tempInodeBuffer]
1338
        lea     ebx, [ebp+EXTFS.tempInodeBuffer]
1339
        call    readInode
1339
        call    readInode
1340
        jc      .fail
1340
        jc      .fail
1341
        push    eax
1341
        push    eax
1342
        lea     esi, [ebp+EXTFS.tempInodeBuffer]
1342
        lea     esi, [ebp+EXTFS.tempInodeBuffer]
Line 1408... Line 1408...
1408
        mov     eax, [esp]
1408
        mov     eax, [esp]
1409
        call    writeInode
1409
        call    writeInode
1410
        jc      .fail
1410
        jc      .fail
1411
        movzx   eax, word [ebx+INODE.linksCount]
1411
        movzx   eax, word [ebx+INODE.linksCount]
1412
@@:
1412
@@:
1413
        pop     ebx edi esi edx
1413
        pop     ebx edx
1414
        ret
1414
        ret
Line 1415... Line 1415...
1415
 
1415
 
1416
findInode_parent:
1416
findInode:
1417
; in: esi -> path string in UTF-8
1417
; in: esi -> path string in UTF-8
1418
;   out:
1418
;   out:
1419
; edi -> file name in UTF-8
1419
; edi -> file name in UTF-8
-
 
1420
; esi = last inode number
-
 
1421
; [ebp+EXTFS.mainInodeBuffer] = last inode
-
 
1422
; ecx = parent inode number
1420
; esi = inode
1423
; CF=1 -> file not found, edi=0 -> error
1421
        push    esi
-
 
1422
        xor     edi, edi
-
 
1423
.loop:
-
 
1424
        cmp     byte [esi], '/'
-
 
1425
        jne     @f
-
 
1426
        mov     edi, esi
-
 
1427
        inc     esi
-
 
1428
        jmp     .loop
-
 
1429
 
-
 
1430
@@:
-
 
1431
        inc     esi
-
 
1432
        cmp     byte [esi-1], 0
-
 
1433
        jne     .loop
-
 
1434
        cmp     edi, 0
-
 
1435
        jne     @f
-
 
1436
; parent is root
-
 
1437
        pop     edi
-
 
1438
        dec     esi
-
 
1439
        jmp     .get_inode
-
 
1440
 
-
 
1441
@@: ; parent is folder
-
 
1442
        mov     byte [edi], 0
-
 
1443
        inc     edi
-
 
1444
        pop     esi
-
 
1445
.get_inode:
-
 
1446
        push    ebx edx
-
 
1447
        call    findInode
-
 
1448
        pop     edx ebx
-
 
1449
        ret
-
 
1450
 
-
 
1451
findInode:
-
 
1452
; in: esi -> path string in UTF-8
-
 
1453
;   out:
-
 
1454
; [ebp+EXTFS.mainInodeBuffer] = inode
-
 
1455
; esi = inode number
-
 
1456
;  dl = first byte of file/folder name
-
 
1457
        lea     edx, [ebp+EXTFS.rootInodeBuffer]
-
 
1458
        cmp     [edx+INODE.sectorsUsed], 0
-
 
1459
        je      .not_found
-
 
1460
        cmp     byte [esi], 0
-
 
1461
        jne     .next_path_part
-
 
1462
; root
-
 
1463
        push    edi ecx
1424
        push    esi
1464
        lea     esi, [ebp+EXTFS.rootInodeBuffer]
1425
        lea     esi, [ebp+EXTFS.rootInodeBuffer]
1465
        lea     edi, [ebp+EXTFS.mainInodeBuffer]
1426
        lea     edi, [ebp+EXTFS.mainInodeBuffer]
-
 
1427
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
1466
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
1428
        mov     edx, esi
1467
        rep movsb
1429
        rep movsb
-
 
1430
        pop     esi
-
 
1431
        pushd   0 ROOT_INODE
-
 
1432
        cmp     [edx+INODE.sectorsUsed], 0
-
 
1433
        jz      .not_found
-
 
1434
        cmp     byte [esi], 0
1468
        pop     ecx edi
1435
        jnz     .next_path_part
1469
        xor     eax, eax
1436
        xor     eax, eax
-
 
1437
        mov     edi, esi
-
 
1438
        pop     esi ecx
-
 
1439
        ret
-
 
1440
 
-
 
1441
@@:
-
 
1442
        pop     esi esi
-
 
1443
.error:
1470
        xor     dl, dl
1444
        pop     esi ecx
-
 
1445
        xor     edi, edi
1471
        mov     esi, ROOT_INODE
1446
        stc
Line 1472... Line 1447...
1472
        ret
1447
        ret
1473
 
1448
 
1474
.next_path_part:
1449
.next_path_part:
1475
        push    [edx+INODE.sectorsUsed]
1450
        push    [edx+INODE.sectorsUsed]
1476
        xor     ecx, ecx
1451
        xor     ecx, ecx
1477
.folder_block_cycle:
1452
.folder_block_cycle:
1478
        push    ecx
1453
        push    ecx
1479
        xchg    esi, edx
1454
        xchg    esi, edx
1480
        call    extfsGetFileBlock
1455
        call    extfsGetFileBlock
1481
        jc      .error_get_block
1456
        jc      @b
1482
        xchg    esi, edx
1457
        xchg    esi, edx
1483
        mov     eax, ecx
1458
        mov     eax, ecx
1484
        mov     ebx, [ebp+EXTFS.mainBlockBuffer]
1459
        mov     ebx, [ebp+EXTFS.mainBlockBuffer]
1485
        call    extfsReadBlock
1460
        call    extfsReadBlock
1486
        jc      .error_get_block
1461
        jc      @b
1487
        push    esi edx
1462
        push    esi edx
1488
        mov     edx, ebx
1463
        mov     edx, ebx
1489
        add     edx, [ebp+EXTFS.bytesPerBlock]
1464
        add     edx, [ebp+EXTFS.bytesPerBlock]
Line 1510... Line 1485...
1510
        je      @f
1485
        je      @f
1511
        cmp     byte [esi], '/'
1486
        cmp     byte [esi], '/'
1512
        jne     @b
1487
        jne     @b
1513
        inc     esi
1488
        inc     esi
1514
@@:
1489
@@:
1515
        pop     edx edx edi ecx
1490
        pop     edx edx edi ecx eax
1516
; ebx -> matched directory entry, esi -> name without parent, or not changed
1491
; ebx -> matched directory entry, esi -> name without parent, or not changed
1517
        cmp     edi, esi
1492
        cmp     edi, esi
1518
        je      .next_folder_block
-
 
1519
        cmp     byte [esi], 0
-
 
1520
        je      .get_inode_ret
-
 
1521
        mov     eax, [ebx+DIRENTRY.inodeNumber]
-
 
1522
        lea     ebx, [ebp+EXTFS.mainInodeBuffer]
-
 
1523
        call    readInode
-
 
1524
        jc      .error_get_inode
-
 
1525
        movzx   eax, [ebx+INODE.accessMode]
-
 
1526
        and     eax, TYPE_MASK
-
 
1527
        cmp     eax, DIRECTORY
-
 
1528
        jne     .not_found      ; path folder is a file
-
 
1529
        pop     ecx
1493
        jnz     @f
1530
        mov     edx, ebx
-
 
1531
        jmp     .next_path_part
-
 
1532
 
-
 
1533
.next_folder_block:
-
 
1534
        pop     eax
-
 
1535
        sub     eax, [ebp+EXTFS.sectorsPerBlock]
1494
        sub     eax, [ebp+EXTFS.sectorsPerBlock]
1536
        jle     .not_found
1495
        jle     .not_found
1537
        push    eax
1496
        push    eax
1538
        inc     ecx
1497
        inc     ecx
1539
        jmp     .folder_block_cycle
1498
        jmp     .folder_block_cycle
Line 1540... Line 1499...
1540
 
1499
 
1541
.get_inode_ret:
1500
@@:
1542
        pop     eax
1501
        pop     eax
1543
        mov     dl, [ebx+DIRENTRY.name]
1502
        mov     [esp], eax
1544
        mov     eax, [ebx+DIRENTRY.inodeNumber]
1503
        mov     eax, [ebx+DIRENTRY.inodeNumber]
1545
        lea     ebx, [ebp+EXTFS.mainInodeBuffer]
1504
        lea     ebx, [ebp+EXTFS.mainInodeBuffer]
1546
        mov     esi, eax
1505
        push    eax
-
 
1506
        call    readInode
-
 
1507
        jc      .error
1547
        call    readInode
1508
        cmp     byte [esi], 0
1548
        ret
-
 
-
 
1509
        je      .ret
-
 
1510
        mov     edx, ebx
-
 
1511
        movzx   eax, [ebx+INODE.accessMode]
-
 
1512
        and     eax, TYPE_MASK
-
 
1513
        cmp     eax, DIRECTORY
-
 
1514
        jz      .next_path_part
1549
 
1515
        xor     edi, edi        ; path folder is a file
1550
.not_found:
1516
.not_found:
1551
        movi    eax, ERROR_FILE_NOT_FOUND
1517
        movi    eax, ERROR_FILE_NOT_FOUND
1552
        stc
1518
        stc
1553
        ret
-
 
1554
 
-
 
1555
.error_get_block:
1519
.ret:
1556
        pop     ebx
-
 
1557
.error_get_inode:
-
 
1558
        pop     ebx
1520
        pop     esi ecx
Line 1559... Line 1521...
1559
        ret
1521
        ret
1560
 
1522
 
1561
writeSuperblock:
1523
writeSuperblock:
Line 1594... Line 1556...
1594
        push    ebx
1556
        push    ebx
1595
        call    findInode
1557
        call    findInode
1596
        pop     ebx
1558
        pop     ebx
1597
        jc      .error_ret
1559
        jc      .error_ret
1598
        lea     esi, [ebp+EXTFS.mainInodeBuffer]
1560
        lea     esi, [ebp+EXTFS.mainInodeBuffer]
1599
        test    [esi+INODE.accessMode], DIRECTORY
1561
        test    [esi+INODE.accessMode], FLAG_FILE
1600
        jz      .error_not_found
1562
        jnz     .error_not_found
1601
        jmp     @f
1563
        jmp     @f
Line 1602... Line 1564...
1602
 
1564
 
1603
.root_folder:
1565
.root_folder:
1604
        lea     esi, [ebp+EXTFS.rootInodeBuffer]
1566
        lea     esi, [ebp+EXTFS.rootInodeBuffer]
Line 1703... Line 1665...
1703
        mov     eax, [esi+INODE.dataModified]
1665
        mov     eax, [esi+INODE.dataModified]
1704
        sub     eax, 978307200
1666
        sub     eax, 978307200
1705
        call    fsTime2bdfe
1667
        call    fsTime2bdfe
1706
        pop     edx
1668
        pop     edx
1707
        or      dword [edx], KOS_DIRECTORY
1669
        or      dword [edx], KOS_DIRECTORY
1708
        test    [esi+INODE.accessMode], DIRECTORY
1670
        test    [esi+INODE.accessMode], FLAG_FILE
1709
        jnz     @f
1671
        jz      @f
1710
        xor     dword [edx], KOS_DIRECTORY  ; mark as file
1672
        xor     dword [edx], KOS_DIRECTORY  ; mark as file
1711
        mov     eax, [esi+INODE.fileSize]
1673
        mov     eax, [esi+INODE.fileSize]
1712
        stosd
1674
        stosd
1713
        mov     eax, [esi+INODE.fileSizeHigh]
1675
        mov     eax, [esi+INODE.fileSizeHigh]
1714
        stosd
1676
        stosd
Line 1928... Line 1890...
1928
        mov     edx, [ebx+16]
1890
        mov     edx, [ebx+16]
1929
        cmp     byte [esi], 0
1891
        cmp     byte [esi], 0
1930
        jz      .is_root
1892
        jz      .is_root
1931
        push    edx
1893
        push    edx
1932
        call    findInode
1894
        call    findInode
1933
        mov     ebx, edx
-
 
1934
        pop     edx
1895
        pop     edx
1935
        lea     esi, [ebp+EXTFS.mainInodeBuffer]
1896
        lea     esi, [ebp+EXTFS.mainInodeBuffer]
1936
        jnc     @f
1897
        jnc     @f
1937
        push    eax
1898
        push    eax
1938
        call    ext_unlock
1899
        call    ext_unlock
1939
        pop     eax
1900
        pop     eax
1940
        ret
1901
        ret
Line 1941... Line 1902...
1941
 
1902
 
1942
.is_root:
1903
.is_root:
1943
        xor     ebx, ebx
1904
        mov     edi, esi
1944
        lea     esi, [ebp+EXTFS.rootInodeBuffer]
1905
        lea     esi, [ebp+EXTFS.rootInodeBuffer]
-
 
1906
@@:
1945
@@:
1907
        mov     bl, [edi]
1946
        xor     eax, eax
1908
        xor     eax, eax
1947
        mov     edi, edx
1909
        mov     edi, edx
1948
        mov     ecx, 40/4
1910
        mov     ecx, 40/4
1949
        rep stosd
1911
        rep stosd
1950
        cmp     bl, '.'
1912
        cmp     bl, '.'
1951
        jne     @f
1913
        jne     @f
1952
        or      dword [edx], KOS_HIDDEN
1914
        or      dword [edx], KOS_HIDDEN
1953
@@:
1915
@@:
1954
        or      dword [edx], KOS_DIRECTORY
1916
        or      dword [edx], KOS_DIRECTORY
1955
        test    [esi+INODE.accessMode], DIRECTORY
1917
        test    [esi+INODE.accessMode], FLAG_FILE
1956
        jnz     @f
1918
        jz      @f
1957
        xor     dword [edx], KOS_DIRECTORY  ; mark as file
1919
        xor     dword [edx], KOS_DIRECTORY  ; mark as file
1958
        mov     eax, [esi+INODE.fileSize]
1920
        mov     eax, [esi+INODE.fileSize]
1959
        mov     ebx, [esi+INODE.fileSizeHigh]
1921
        mov     ebx, [esi+INODE.fileSizeHigh]
1960
        mov     dword [edx+32], eax
1922
        mov     dword [edx+32], eax
Line 2009... Line 1971...
2009
        ret
1971
        ret
Line 2010... Line 1972...
2010
 
1972
 
2011
;----------------------------------------------------------------
1973
;----------------------------------------------------------------
2012
ext_Delete:
1974
ext_Delete:
2013
        call    extfsWritingInit
-
 
2014
        push    esi
1975
        call    extfsWritingInit
2015
        call    findInode
1976
        call    findInode
2016
        mov     ebx, esi
-
 
2017
        pop     esi
1977
        mov     ebx, esi
2018
        push    eax
1978
        push    eax
2019
        jc      .ret
1979
        jc      .ret
2020
        pop     eax
1980
        pop     eax
2021
        lea     edx, [ebp+EXTFS.mainInodeBuffer]
1981
        lea     edx, [ebp+EXTFS.mainInodeBuffer]
2022
        movzx   edx, [edx+INODE.accessMode]
1982
        movzx   edx, [edx+INODE.accessMode]
2023
        and     edx, TYPE_MASK
1983
        and     edx, TYPE_MASK
2024
        cmp     edx, DIRECTORY
1984
        cmp     edx, DIRECTORY
2025
        jne     .file
1985
        jne     .file
2026
        push    esi ebx edx 0
1986
        push    ebx ecx edx 0
2027
        lea     esi, [ebp+EXTFS.mainInodeBuffer]
1987
        lea     esi, [ebp+EXTFS.mainInodeBuffer]
2028
.checkDirectory:
1988
.checkDirectory:
2029
        mov     ecx, [esp]
1989
        mov     ecx, [esp]
2030
        call    extfsGetFileBlock
1990
        call    extfsGetFileBlock
Line 2055... Line 2015...
2055
        jb      .dir_entry
2015
        jb      .dir_entry
2056
        inc     dword[esp]
2016
        inc     dword[esp]
2057
        jmp     .checkDirectory
2017
        jmp     .checkDirectory
Line 2058... Line 2018...
2058
 
2018
 
2059
.empty:
2019
.empty:
2060
        pop     edx edx ebx esi
2020
        pop     edx edx ecx ebx
2061
.file:
-
 
2062
        call    findInode_parent
-
 
2063
        jc      .error
2021
.file:
2064
        mov     eax, esi
-
 
2065
; save file/folder's and parent's inode
2022
        mov     eax, ecx
2066
        push    ebx eax
-
 
2067
        cmp     edx, DIRECTORY
-
 
2068
        jne     @f
-
 
2069
; Unlink '.'
-
 
2070
        mov     eax, [esp+4]
-
 
2071
        call    unlinkInode
-
 
2072
        cmp     eax, -1
-
 
2073
        je      .error_stack8
-
 
2074
; Unlink '..'
-
 
2075
        mov     eax, [esp+4]
-
 
2076
        mov     ebx, [esp]
2023
        push    ebx ecx
2077
        call    unlinkInode
2024
        call    unlinkInode
2078
        cmp     eax, -1
2025
        cmp     eax, -1
2079
        je      .error_stack8
-
 
2080
@@:
2026
        je      .error_stack8
2081
        pop     eax
-
 
2082
        mov     ebx, [esp]
-
 
2083
        call    unlinkInode
-
 
2084
        cmp     eax, -1
-
 
2085
        je      .error_stack4
2027
        pop     ebx
2086
        test    eax, eax
2028
        test    eax, eax
2087
        jz      @f
-
 
2088
; has hardlinks
2029
        jz      @f
-
 
2030
        xor     eax, eax
-
 
2031
        cmp     edx, DIRECTORY
2089
        xor     eax, eax
2032
        jnz     .error_stack4_eax   ; hardlinks
2090
        mov     [esp], eax
2033
        mov     eax, [esp]
2091
        jmp     .disk_sync
-
 
2092
 
2034
        call    unlinkInode
2093
@@:
2035
@@:
2094
        mov     eax, [esp]
2036
        mov     eax, [esp]
2095
        lea     ebx, [ebp+EXTFS.mainInodeBuffer]
2037
        lea     ebx, [ebp+EXTFS.mainInodeBuffer]
2096
        call    readInode
2038
        call    readInode
Line 2192... Line 2134...
2192
        ret
2134
        ret
Line 2193... Line 2135...
2193
 
2135
 
2194
.not_empty:
2136
.not_empty:
2195
        pop     eax
2137
        pop     eax
2196
.error_stack8:
2138
.error_stack8:
2197
        pop     eax
-
 
2198
.error_stack4:
-
 
2199
        pop     eax
2139
        pop     eax eax
2200
        push    ERROR_ACCESS_DENIED
2140
        push    ERROR_ACCESS_DENIED
Line 2201... Line 2141...
2201
        jmp     .disk_sync
2141
        jmp     .disk_sync
2202
 
2142
 
Line 2211... Line 2151...
2211
        jmp     .disk_sync
2151
        jmp     .disk_sync
Line 2212... Line 2152...
2212
 
2152
 
2213
;----------------------------------------------------------------
2153
;----------------------------------------------------------------
2214
ext_CreateFolder:
2154
ext_CreateFolder:
2215
        call    extfsWritingInit
-
 
2216
        push    esi
2155
        call    extfsWritingInit
2217
        call    findInode
-
 
2218
        pop     esi
2156
        call    findInode
2219
        jnc     .success    ; exist
2157
        jnc     .success    ; exist
2220
        call    findInode_parent
2158
        test    edi, edi
2221
        jc      .error
2159
        jz      .error
2222
        mov     eax, esi
2160
        mov     eax, esi
2223
        xor     ebx, ebx
2161
        xor     ebx, ebx
2224
        inc     ebx
2162
        inc     ebx
2225
        call    extfsResourceAlloc
2163
        call    extfsResourceAlloc
Line 2295... Line 2233...
2295
parent_link db "..", 0
2233
parent_link db "..", 0
Line 2296... Line 2234...
2296
 
2234
 
2297
;----------------------------------------------------------------
2235
;----------------------------------------------------------------
2298
ext_CreateFile:
2236
ext_CreateFile:
2299
        call    extfsWritingInit
2237
        call    extfsWritingInit
2300
        push    ebx esi
2238
        push    0 ebx
2301
        call    findInode
-
 
2302
        mov     esi, [esp]
2239
        call    findInode
2303
        jc      @f
-
 
2304
        call    ext_unlock
-
 
2305
        call    ext_Delete
-
 
2306
        push    eax
-
 
2307
        call    ext_lock
-
 
2308
        pop     eax
2240
        jnc     .exist
2309
        test    eax, eax
-
 
2310
        jnz     .error
-
 
2311
        mov     esi, [esp]
-
 
2312
@@:
-
 
2313
        call    findInode_parent
2241
        test    edi, edi
2314
        jc      .error
2242
        jz      .error
2315
        mov     eax, esi
2243
        mov     eax, esi
2316
        xor     ebx, ebx
2244
        xor     ebx, ebx
2317
        inc     ebx
2245
        inc     ebx
2318
        call    extfsResourceAlloc
2246
        call    extfsResourceAlloc
2319
        jc      .error
2247
        jc      .error
2320
        inc     ebx
2248
        inc     ebx
2321
        push    ebx esi edi
2249
        push    ebx ebx esi edi
2322
        xor     al, al
2250
        xor     al, al
2323
        lea     edi, [ebp+EXTFS.tempInodeBuffer]
2251
        lea     edi, [ebp+EXTFS.tempInodeBuffer]
2324
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
2252
        movzx   ecx, [ebp+EXTFS.superblock.inodeSize]
2325
        rep stosb
2253
        rep stosb
Line 2332... Line 2260...
2332
        pop     edi esi edx
2260
        pop     edi esi edx
2333
; edx = allocated inode number, edi -> filename, esi = parent inode number
2261
; edx = allocated inode number, edi -> filename, esi = parent inode number
2334
        mov     [ebx+INODE.accessMode], FLAG_FILE or PERMISSIONS
2262
        mov     [ebx+INODE.accessMode], FLAG_FILE or PERMISSIONS
2335
        mov     eax, edx
2263
        mov     eax, edx
2336
        call    writeInode
2264
        call    writeInode
2337
        jc      .error
2265
        jc      .error2
2338
; link parent to child
2266
; link parent to child
2339
        mov     eax, esi
2267
        mov     eax, esi
2340
        mov     ebx, edx
2268
        mov     ebx, edx
2341
        mov     esi, edi
2269
        mov     esi, edi
2342
        mov     dl, DIR_FLAG_FILE
2270
        mov     dl, DIR_FLAG_FILE
2343
        call    linkInode
2271
        call    linkInode
2344
        jc      .error
2272
        jc      .error2
2345
        pop     esi ebx
2273
        pop     esi ebx
2346
        call    ext_unlock
2274
        push    ebx esi
-
 
2275
        mov     ecx, [ebx+12]
2347
        jmp     ext_WriteFile
2276
        jmp     ext_WriteFile.start
Line -... Line 2277...
-
 
2277
 
-
 
2278
.exist:
-
 
2279
        lea     edx, [ebp+EXTFS.mainInodeBuffer]
-
 
2280
        movi    eax, ERROR_ACCESS_DENIED
-
 
2281
        test    [edx+INODE.accessMode], FLAG_FILE
-
 
2282
        jz      .error  ; not a file
-
 
2283
        pop     ebx
-
 
2284
        push    ebx esi
-
 
2285
        mov     eax, esi
-
 
2286
        mov     ecx, [ebx+12]
-
 
2287
        call    extfsTruncateFile
-
 
2288
        jnc     ext_WriteFile.start
-
 
2289
.error2:
2348
 
2290
        pop     ebx
2349
.error:
2291
.error:
2350
        push    eax
2292
        push    eax
2351
        call    ext_unlock
2293
        call    ext_unlock
2352
        pop     eax ebx ebx
2294
        pop     eax ebx ebx
Line 2356... Line 2298...
2356
;----------------------------------------------------------------
2298
;----------------------------------------------------------------
2357
ext_WriteFile:
2299
ext_WriteFile:
2358
        call    extfsWritingInit
2300
        call    extfsWritingInit
2359
        push    0 ebx
2301
        push    0 ebx
2360
        call    findInode
2302
        call    findInode
-
 
2303
        pop     ebx
-
 
2304
        push    ebx esi
2361
        jc      .error
2305
        jc      .error
2362
        lea     edx, [ebp+EXTFS.mainInodeBuffer]
2306
        lea     edx, [ebp+EXTFS.mainInodeBuffer]
2363
        movi    eax, ERROR_ACCESS_DENIED
2307
        movi    eax, ERROR_ACCESS_DENIED
2364
        test    [edx+INODE.accessMode], FLAG_FILE
2308
        test    [edx+INODE.accessMode], FLAG_FILE
2365
        jz      .error  ; not a file
2309
        jz      .error  ; not a file
2366
        mov     ebx, [esp]
-
 
2367
        push    esi     ; inode number
-
 
2368
        mov     eax, esi
-
 
2369
        mov     ecx, [ebx+4]
2310
        mov     ecx, [ebx+4]
-
 
2311
        add     ecx, [ebx+12]
-
 
2312
.start:
-
 
2313
        mov     eax, esi
2370
        call    extfsExtendFile
2314
        call    extfsExtendFile
2371
        jc      .error2
2315
        jc      .error
-
 
2316
        mov     eax, [ebx+4]
2372
        mov     ecx, [ebx+12]
2317
        mov     ecx, [ebx+12]
2373
        mov     esi, [ebx+16]
2318
        mov     esi, [ebx+16]
2374
        mov     eax, [edx+INODE.fileSize]
-
 
2375
        push    eax
2319
        push    eax
2376
        xor     edx, edx
2320
        xor     edx, edx
2377
        div     [ebp+EXTFS.bytesPerBlock]
2321
        div     [ebp+EXTFS.bytesPerBlock]
2378
        test    edx, edx
2322
        test    edx, edx
2379
        jz      .start_aligned
2323
        jz      .start_aligned
Line 2449... Line 2393...
2449
        xor     ecx, ecx
2393
        xor     ecx, ecx
2450
.error_inode_size:
2394
.error_inode_size:
2451
        mov     [esp+12], eax
2395
        mov     [esp+12], eax
2452
.write_inode:
2396
.write_inode:
2453
        lea     ebx, [ebp+EXTFS.tempInodeBuffer]
2397
        lea     ebx, [ebp+EXTFS.tempInodeBuffer]
2454
        pop     [ebx+INODE.fileSize]
-
 
2455
        pop     eax
2398
        pop     eax eax
2456
        call    writeInode
2399
        call    writeInode
2457
        pop     ebx
2400
        pop     ebx
2458
        mov     ebx, [ebx+12]
2401
        mov     ebx, [ebx+12]
2459
        sub     ebx, ecx
2402
        sub     ebx, ecx
2460
        test    eax, eax
2403
        test    eax, eax
Line 2467... Line 2410...
2467
@@:
2410
@@:
2468
        call    ext_unlock
2411
        call    ext_unlock
2469
        pop     eax
2412
        pop     eax
2470
        ret
2413
        ret
Line 2471... Line -...
2471
 
-
 
2472
.error2:
-
 
2473
        pop     ebx
2414
 
2474
.error:
2415
.error:
2475
        pop     ebx ebx
2416
        pop     ebx ebx ebx
2476
        push    eax
2417
        push    eax
Line 2477... Line 2418...
2477
        jmp     @b
2418
        jmp     @b
2478
 
2419