Subversion Repositories Kolibri OS

Rev

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

Rev 88 Rev 91
Line 912... Line 912...
912
        add     edi, 0x20
912
        add     edi, 0x20
913
        cmp     edi, 0x100000+512*33
913
        cmp     edi, 0x100000+512*33
914
        cmc
914
        cmc
915
        ret
915
        ret
Line -... Line 916...
-
 
916
 
-
 
917
ramdisk_root_extend_dir:
-
 
918
        stc
-
 
919
        ret
-
 
920
 
-
 
921
ramdisk_notroot_next:
-
 
922
        add     edi, 0x20
-
 
923
        test    edi, 0x1FF
-
 
924
        jz      ramdisk_notroot_next_sector
-
 
925
        ret     ; CF=0
-
 
926
ramdisk_notroot_next_sector:
-
 
927
        push    ecx
-
 
928
        mov     ecx, [eax]
-
 
929
        mov     ecx, [ecx*2+0x280000]
-
 
930
        and     ecx, 0xFFF
-
 
931
        cmp     ecx, 2849
-
 
932
        jae     ramdisk_notroot_first.err2
-
 
933
        mov     [eax], ecx
-
 
934
        pop     ecx
-
 
935
ramdisk_notroot_first:
-
 
936
        mov     eax, [eax]
-
 
937
        cmp     eax, 2
-
 
938
        jb      .err
-
 
939
        cmp     eax, 2849
-
 
940
        jae     .err
-
 
941
        shl     eax, 9
-
 
942
        lea     edi, [eax+(31 shl 9)+0x100000]
-
 
943
        clc
-
 
944
        ret
-
 
945
.err2:
-
 
946
        pop     ecx
-
 
947
.err:
-
 
948
        stc
-
 
949
        ret
-
 
950
ramdisk_notroot_next_write:
-
 
951
        test    edi, 0x1FF
-
 
952
        jz      ramdisk_notroot_next_sector
-
 
953
ramdisk_root_next_write:
-
 
954
        ret
-
 
955
 
-
 
956
ramdisk_notroot_extend_dir:
-
 
957
        pusha
-
 
958
        xor     eax, eax
-
 
959
        mov     edi, 0x280000
-
 
960
        mov     ecx, 2849
-
 
961
        repnz   scasw
-
 
962
        jnz     .notfound
-
 
963
        mov     word [edi-2], 0xFFF
-
 
964
        sub     edi, 0x280000
-
 
965
        shr     edi, 1
-
 
966
        dec     edi
-
 
967
        mov     eax, [esp+28]
-
 
968
        mov     ecx, [eax]
-
 
969
        mov     [0x280000+ecx*2], di
-
 
970
        mov     [eax], edi
-
 
971
        shl     edi, 9
-
 
972
        add     edi, (31 shl 9)+0x100000
-
 
973
        mov     [esp], edi
-
 
974
        xor     eax, eax
-
 
975
        mov     ecx, 128
-
 
976
        rep     stosd
-
 
977
        popa
-
 
978
        clc
-
 
979
        ret
-
 
980
.notfound:
-
 
981
        popa
-
 
982
        stc
-
 
983
        ret
916
 
984
 
917
rd_find_lfn:
985
rd_find_lfn:
918
; in: esi->name
986
; in: esi->name
919
; out: CF=1 - file not found
987
; out: CF=1 - file not found
920
;      else CF=0 and edi->direntry
988
;      else CF=0 and edi->direntry
-
 
989
        push    esi edi
921
        push    esi edi
990
        push    0
922
        push    ramdisk_root_first
991
        push    ramdisk_root_first
-
 
992
        push    ramdisk_root_next
923
        push    ramdisk_root_next
993
.loop:
924
        call    fat_find_lfn
994
        call    fat_find_lfn
925
        jc      .notfound
995
        jc      .notfound
926
        cmp     byte [esi], 0
996
        cmp     byte [esi], 0
-
 
997
        jz      .found
927
        jnz     .notfound
998
        test    byte [edi+11], 10h
-
 
999
        jz      .notfound
928
        add     esp, 12
1000
        movzx   eax, word [edi+26]
-
 
1001
        mov     [esp+8], eax
-
 
1002
        mov     dword [esp+4], ramdisk_notroot_first
929
        pop     esi
1003
        mov     dword [esp], ramdisk_notroot_next
930
        ret     ; CF=0
1004
        jmp     .loop
931
.notfound:
1005
.notfound:
932
        add     esp, 8
1006
        add     esp, 12
933
        pop     edi esi
1007
        pop     edi esi
934
        stc
1008
        stc
-
 
1009
        ret
-
 
1010
.found:
-
 
1011
        mov     eax, [esp+8]
-
 
1012
        add     esp, 16         ; CF=0
-
 
1013
        pop     esi
Line 935... Line 1014...
935
        ret
1014
        ret
936
 
1015
 
937
;----------------------------------------------------------------
1016
;----------------------------------------------------------------
938
;
1017
;
Line 1039... Line 1118...
1039
;  ret ebx = size or 0xffffffff file not found
1118
;  ret ebx = size or 0xffffffff file not found
1040
;      eax = 0 ok read or other = errormsg
1119
;      eax = 0 ok read or other = errormsg
1041
;
1120
;
1042
;--------------------------------------------------------------
1121
;--------------------------------------------------------------
1043
fs_RamdiskReadFolder:
1122
fs_RamdiskReadFolder:
-
 
1123
        push    edi
1044
        cmp     byte [esi], 0
1124
        cmp     byte [esi], 0
1045
        jz      @f
1125
        jz      .root
1046
; ramdisk doesn't support folders
1126
        call    rd_find_lfn
-
 
1127
        jnc     .found
1047
        mov     eax, ERROR_ACCESS_DENIED
1128
        pop     edi
1048
        or      ebx, -1
1129
        or      ebx, -1
-
 
1130
        mov     eax, ERROR_FILE_NOT_FOUND
1049
        ret
1131
        ret
-
 
1132
.found:
-
 
1133
        test    byte [edi+11], 0x10
-
 
1134
        jnz     .found_dir
-
 
1135
        pop     edi
-
 
1136
        or      ebx, -1
-
 
1137
        mov     eax, ERROR_ACCESS_DENIED
-
 
1138
        ret
-
 
1139
.found_dir:
-
 
1140
        movzx   eax, word [edi+26]
-
 
1141
        add     eax, 31
-
 
1142
        push    0
-
 
1143
        jmp     .doit
1050
@@:
1144
.root:
-
 
1145
        mov     eax, 19
-
 
1146
        push    14
-
 
1147
.doit:
1051
        push    esi edi ecx
1148
        push    esi ecx ebp
-
 
1149
        sub     esp, 262*2      ; reserve space for LFN
-
 
1150
        mov     ebp, esp
-
 
1151
        push    dword [ebx+4]   ; for fat_get_name: read ANSI/UNICODE names
-
 
1152
        mov     ebx, [ebx]
1052
; init header
1153
; init header
1053
        push    ecx
1154
        push    eax ecx
1054
        mov     edi, edx
1155
        mov     edi, edx
1055
        mov     ecx, 32/4
1156
        mov     ecx, 32/4
1056
        xor     eax, eax
1157
        xor     eax, eax
1057
        rep     stosd
1158
        rep     stosd
1058
        mov     byte [edx], 1   ; version
1159
        mov     byte [edx], 1   ; version
1059
        pop     ecx
1160
        pop     ecx eax
1060
        push    ebp
-
 
1061
        sub     esp, 262*2      ; allocate space for LFN
-
 
1062
        mov     ebp, esp
-
 
1063
        push    dword [ebx+4]   ; for fat_get_name: read ANSI/UNICODE name
-
 
1064
        mov     ebx, [ebx]
-
 
1065
; read root
-
 
1066
        mov     esi, edi        ; esi points to block of data of folder entry (BDFE)
1161
        mov     esi, edi        ; esi points to block of data of folder entry (BDFE)
-
 
1162
.main_loop:
-
 
1163
        mov     edi, eax
-
 
1164
        shl     edi, 9
1067
        mov     edi, 0x100000+512*19
1165
        add     edi, 0x100000
-
 
1166
        push    eax
1068
.l1:
1167
.l1:
1069
        call    fat_get_name
1168
        call    fat_get_name
1070
        jc      .l2
1169
        jc      .l2
1071
        cmp     byte [edi+11], 0xF
1170
        cmp     byte [edi+11], 0xF
1072
        jnz     @f
1171
        jnz     .do_bdfe
1073
        add     edi, 0x20
1172
        add     edi, 0x20
-
 
1173
        test    edi, 0x1FF
-
 
1174
        jnz     .do_bdfe
-
 
1175
        pop     eax
-
 
1176
        inc     eax
-
 
1177
        dec     byte [esp+262*2+16]
-
 
1178
        jz      .done
-
 
1179
        jns     @f
-
 
1180
; read next sector from FAT
-
 
1181
        mov     eax, [(eax-31-1)*2+0x280000]
-
 
1182
        and     eax, 0xFFF
-
 
1183
        cmp     eax, 0xFF8
-
 
1184
        jae     .done
-
 
1185
        add     eax, 31
-
 
1186
        mov     byte [esp+262*2+16], 0
1074
@@:
1187
@@:
-
 
1188
        mov     edi, eax
-
 
1189
        shl     edi, 9
-
 
1190
        add     edi, 0x100000
-
 
1191
        push    eax
-
 
1192
.do_bdfe:
1075
        inc     dword [edx+8]   ; new file found
1193
        inc     dword [edx+8]   ; new file found
1076
        dec     ebx
1194
        dec     ebx
1077
        jns     .l2
1195
        jns     .l2
1078
        dec     ecx
1196
        dec     ecx
1079
        js      .l2
1197
        js      .l2
1080
        inc     dword [edx+4]  ; new file block copied
1198
        inc     dword [edx+4]  ; new file block copied
1081
        call    fat_entry_to_bdfe
1199
        call    fat_entry_to_bdfe
1082
.l2:
1200
.l2:
1083
        add     edi, 0x20
1201
        add     edi, 0x20
1084
        cmp     edi, 0x100000+512*33
1202
        test    edi, 0x1FF
1085
        jb      .l1
1203
        jnz     .l1
-
 
1204
        pop     eax
-
 
1205
        inc     eax
-
 
1206
        dec     byte [esp+262*2+16]
-
 
1207
        jz      .done
-
 
1208
        jns     @f
-
 
1209
; read next sector from FAT
-
 
1210
        mov     eax, [(eax-31-1)*2+0x280000]
-
 
1211
        and     eax, 0xFFF
-
 
1212
        cmp     eax, 0xFF8
-
 
1213
        jae     .done
-
 
1214
        add     eax, 31
-
 
1215
        mov     byte [esp+262*2+16], 0
-
 
1216
@@:
-
 
1217
        jmp     .main_loop
-
 
1218
.done:
1086
        add     esp, 262*2+4
1219
        add     esp, 262*2+4
1087
        pop     ebp
1220
        pop     ebp
1088
        mov     ebx, [edx+4]
1221
        mov     ebx, [edx+4]
1089
        xor     eax, eax
1222
        xor     eax, eax
1090
        dec     ecx
1223
        dec     ecx
1091
        js      @f
1224
        js      @f
1092
        mov     al, ERROR_END_OF_FILE
1225
        mov     al, ERROR_END_OF_FILE
1093
@@:
1226
@@:
1094
        pop     ecx edi esi
1227
        pop     ecx esi edi edi
1095
        ret
1228
        ret
Line 1096... Line 1229...
1096
 
1229
 
1097
iglobal
1230
iglobal
1098
label fat_legal_chars byte
1231
label fat_legal_chars byte
Line 1344... Line 1477...
1344
        ret
1477
        ret
Line 1345... Line 1478...
1345
 
1478
 
1346
fs_RamdiskRewrite:
1479
fs_RamdiskRewrite:
1347
        cmp     byte [esi], 0
1480
        cmp     byte [esi], 0
-
 
1481
        jz      @b
1348
        jz      @b
1482
        pushad
1349
; ramdisk doesn't support folders
1483
        xor     ebp, ebp
1350
        push    esi
1484
        push    esi
1351
@@:
1485
@@:
1352
        lodsb
1486
        lodsb
1353
        test    al, al
1487
        test    al, al
1354
        jz      @f
1488
        jz      @f
1355
        cmp     al, '/'
1489
        cmp     al, '/'
1356
        jnz     @b
1490
        jnz     @b
1357
        pop     esi
-
 
1358
.err5:
-
 
1359
        mov     eax, 5  ; file not found
1491
        lea     ebp, [esi-1]
1360
        xor     ebx, ebx
-
 
1361
        ret
1492
        jmp     @b
1362
@@:
1493
@@:
-
 
1494
        pop     esi
-
 
1495
        test    ebp, ebp
-
 
1496
        jnz     .noroot
-
 
1497
        push    ramdisk_root_extend_dir
-
 
1498
        push    ramdisk_root_next_write
-
 
1499
        push    ebp
-
 
1500
        push    ramdisk_root_first
-
 
1501
        push    ramdisk_root_next
-
 
1502
        jmp     .common1
1363
        pop     esi
1503
.noroot:
1364
; check existence
1504
; check existence
1365
        push    edi
1505
        mov     byte [ebp], 0
-
 
1506
        call    rd_find_lfn
-
 
1507
        mov     byte [ebp], '/'
-
 
1508
        lea     esi, [ebp+1]
-
 
1509
        jnc     @f
-
 
1510
        mov     eax, ERROR_FILE_NOT_FOUND
-
 
1511
.ret1:
-
 
1512
        mov     [esp+28], eax
-
 
1513
        popad
-
 
1514
        xor     ebx, ebx
-
 
1515
        ret
-
 
1516
@@:
-
 
1517
        test    byte [edi+11], 0x10     ; must be directory
-
 
1518
        mov     eax, ERROR_ACCESS_DENIED
-
 
1519
        jz      .ret1
-
 
1520
        movzx   ebp, word [edi+26]      ; ebp=cluster
-
 
1521
        mov     eax, ERROR_FAT_TABLE
-
 
1522
        cmp     ebp, 2
-
 
1523
        jb      .ret1
-
 
1524
        cmp     ebp, 2849
-
 
1525
        jae     .ret1
-
 
1526
        push    ramdisk_notroot_extend_dir
-
 
1527
        push    ramdisk_notroot_next_write
-
 
1528
        push    ebp
-
 
1529
        push    ramdisk_notroot_first
-
 
1530
        push    ramdisk_notroot_next
-
 
1531
.common1:
1366
        call    rd_find_lfn
1532
        call    fat_find_lfn
-
 
1533
        jc      .notfound
-
 
1534
; found; must not be directory
-
 
1535
        test    byte [edi+11], 10h
-
 
1536
        jz      @f
-
 
1537
        add     esp, 20
-
 
1538
        popad
-
 
1539
        mov     eax, ERROR_ACCESS_DENIED
-
 
1540
        xor     ebx, ebx
-
 
1541
        ret
1367
        jc      .notfound
1542
@@:
1368
; found, delete FAT chain
1543
; delete FAT chain
1369
        push    edi
1544
        push    edi
1370
        xor     eax, eax
1545
        xor     eax, eax
1371
        mov     dword [edi+28], eax     ; zero size
1546
        mov     dword [edi+28], eax     ; zero size
1372
        xchg    ax, word [edi+26]       ; start cluster
1547
        xchg    ax, word [edi+26]       ; start cluster
Line 1390... Line 1565...
1390
        jmp     .doit
1565
        jmp     .doit
1391
.notfound:
1566
.notfound:
1392
; file is not found; generate short name
1567
; file is not found; generate short name
1393
        call    fat_name_is_legal
1568
        call    fat_name_is_legal
1394
        jc      @f
1569
        jc      @f
-
 
1570
        add     esp, 20
1395
        pop     edi
1571
        popad
-
 
1572
        mov     eax, ERROR_FILE_NOT_FOUND
1396
        jmp     .err5
1573
        xor     ebx, ebx
-
 
1574
        ret
1397
@@:
1575
@@:
1398
        sub     esp, 12
1576
        sub     esp, 12
1399
        mov     edi, esp
1577
        mov     edi, esp
1400
        call    fat_gen_short_name
1578
        call    fat_gen_short_name
1401
.test_short_name_loop:
1579
.test_short_name_loop:
1402
        push    esi ecx
1580
        push    esi edi ecx
-
 
1581
        mov     esi, edi
1403
        mov     esi, 0x100000+512*19
1582
        lea     eax, [esp+12+12+8]
-
 
1583
        mov     [eax], ebp
-
 
1584
        call    dword [eax-4]
-
 
1585
        jc      .found
1404
.test_short_name_entry:
1586
.test_short_name_entry:
1405
        cmp     byte [esi+11], 0xF
1587
        cmp     byte [edi+11], 0xF
1406
        jz      .test_short_name_cont
1588
        jz      .test_short_name_cont
1407
        mov     ecx, 11
1589
        mov     ecx, 11
1408
        push    esi edi
1590
        push    esi edi
1409
        repz    cmpsb
1591
        repz    cmpsb
1410
        pop     edi esi
1592
        pop     edi esi
1411
        jz      .short_name_found
1593
        jz      .short_name_found
1412
.test_short_name_cont:
1594
.test_short_name_cont:
1413
        add     esi, 20h
1595
        lea     eax, [esp+12+12+8]
1414
        cmp     esi, 0x100000+512*33
1596
        call    dword [eax-8]
1415
        jb      .test_short_name_entry
1597
        jnc     .test_short_name_entry
1416
        pop     ecx esi
-
 
1417
        jmp     .found
1598
        jmp     .found
1418
.short_name_found:
1599
.short_name_found:
-
 
1600
        pop     ecx edi esi
1419
        call    fat_next_short_name
1601
        call    fat_next_short_name
1420
        pop     ecx esi
-
 
1421
        jnc     .test_short_name_loop
1602
        jnc     .test_short_name_loop
1422
.disk_full:
1603
.disk_full:
1423
        add     esp, 12
1604
        add     esp, 12+20
1424
        pop     edi
1605
        popad
1425
        mov     eax, ERROR_DISK_FULL
1606
        mov     eax, ERROR_DISK_FULL
1426
        xor     ebx, ebx
1607
        xor     ebx, ebx
1427
        ret
1608
        ret
1428
.found:
1609
.found:
-
 
1610
        pop     ecx edi esi
1429
; now find space in directory
1611
; now find space in directory
1430
; we need to save LFN <=> LFN is not equal to short name <=> generated name contains '~'
1612
; we need to save LFN <=> LFN is not equal to short name <=> generated name contains '~'
1431
        mov     al, '~'
1613
        mov     al, '~'
1432
        push    ecx edi
1614
        push    ecx edi
1433
        mov     ecx, 8
1615
        mov     ecx, 8
Line 1450... Line 1632...
1450
        push    edx
1632
        push    edx
1451
        cdq
1633
        cdq
1452
        div     ecx
1634
        div     ecx
1453
        pop     edx
1635
        pop     edx
1454
.notilde:
1636
.notilde:
-
 
1637
        push    -1
-
 
1638
        push    -1
1455
; find  successive entries in directory
1639
; find  successive entries in directory
1456
        xor     ecx, ecx
1640
        xor     ecx, ecx
-
 
1641
        push    eax
1457
        mov     edi, 0x100000+512*19
1642
        lea     eax, [esp+12+8+12+8]
-
 
1643
        mov     [eax], ebp
-
 
1644
        call    dword [eax-4]
-
 
1645
        pop     eax
1458
.scan_dir:
1646
.scan_dir:
1459
        cmp     byte [edi], 0
1647
        cmp     byte [edi], 0
1460
        jz      .free
1648
        jz      .free
1461
        cmp     byte [edi], 0xE5
1649
        cmp     byte [edi], 0xE5
1462
        jz      .free
1650
        jz      .free
1463
        xor     ecx, ecx
1651
        xor     ecx, ecx
1464
.scan_cont:
1652
.scan_cont:
1465
        add     edi, 0x20
1653
        push    eax
1466
        cmp     edi, 0x100000+512*33
1654
        lea     eax, [esp+12+8+12+8]
-
 
1655
        call    dword [eax-8]
-
 
1656
        pop     eax
1467
        jb      .scan_dir
1657
        jnc     .scan_dir
-
 
1658
        push    eax
-
 
1659
        lea     eax, [esp+12+8+12+8]
-
 
1660
        call    dword [eax+8]           ; extend directory
1468
        pop     edi ecx
1661
        pop     eax
1469
        jmp     .disk_full
1662
        jnc     .scan_dir
-
 
1663
        add     esp, 8+8+12+20
-
 
1664
        popad
-
 
1665
        mov     eax, ERROR_DISK_FULL
-
 
1666
        xor     ebx, ebx
-
 
1667
        ret
1470
.free:
1668
.free:
-
 
1669
        test    ecx, ecx
-
 
1670
        jnz     @f
-
 
1671
        mov     [esp], edi
-
 
1672
        mov     ecx, [esp+8+8+12+8]
-
 
1673
        mov     [esp+4], ecx
-
 
1674
        xor     ecx, ecx
-
 
1675
@@:
1471
        inc     ecx
1676
        inc     ecx
1472
        cmp     ecx, eax
1677
        cmp     ecx, eax
1473
        jb      .scan_cont
1678
        jb      .scan_cont
1474
; found!
1679
; found!
1475
; calculate name checksum
1680
; calculate name checksum
1476
        push    esi ecx
1681
        push    esi ecx
1477
        mov     esi, [esp+8]
1682
        mov     esi, [esp+8+8]
1478
        mov     ecx, 11
1683
        mov     ecx, 11
1479
        xor     eax, eax
1684
        xor     eax, eax
1480
@@:
1685
@@:
1481
        ror     al, 1
1686
        ror     al, 1
1482
        add     al, [esi]
1687
        add     al, [esi]
1483
        inc     esi
1688
        inc     esi
1484
        loop    @b
1689
        loop    @b
1485
        pop     ecx esi
1690
        pop     ecx esi
-
 
1691
        pop     edi
-
 
1692
        pop     dword [esp+8+12+8]
1486
; edi points to last entry in free chunk
1693
; edi points to last entry in free chunk
1487
        dec     ecx
1694
        dec     ecx
1488
        jz      .nolfn
1695
        jz      .nolfn
1489
        push    esi
1696
        push    esi
1490
        push    edi
1697
        push    eax
-
 
1698
        mov     al, 40h
1491
.writelfn:
1699
.writelfn:
1492
        sub     edi, 20h
1700
        or      al, cl
1493
        push    ecx eax
-
 
1494
        mov     eax, [esp+8]
1701
        mov     esi, [esp+4]
1495
        sub     eax, edi
1702
        push    ecx
1496
        shr     eax, 5
1703
        dec     ecx
1497
        cmp     ecx, 1
1704
        imul    ecx, 13
1498
        jnz     @f
-
 
1499
        or      al, 40h
1705
        add     esi, ecx
1500
@@:
-
 
1501
        stosb
1706
        stosb
1502
        mov     cl, 5
1707
        mov     cl, 5
1503
        call    .read_symbols
1708
        call    .read_symbols
1504
        mov     ax, 0xF
1709
        mov     ax, 0xF
1505
        stosw
1710
        stosw
1506
        pop     eax
1711
        mov     al, [esp+4]
1507
        stosb
1712
        stosb
1508
        push    eax
-
 
1509
        mov     cl, 6
1713
        mov     cl, 6
1510
        call    .read_symbols
1714
        call    .read_symbols
1511
        xor     eax, eax
1715
        xor     eax, eax
1512
        stosw
1716
        stosw
1513
        mov     cl, 2
1717
        mov     cl, 2
1514
        call    .read_symbols
1718
        call    .read_symbols
1515
        pop     eax ecx
1719
        pop     ecx
-
 
1720
        lea     eax, [esp+8+8+12+8]
-
 
1721
        call    dword [eax+4]   ; next write
1516
        sub     edi, 0x20
1722
        xor     eax, eax
1517
        loop    .writelfn
1723
        loop    .writelfn
1518
        pop     edi
1724
        pop     eax
1519
        pop     esi
1725
        pop     esi
1520
.nolfn:
1726
.nolfn:
1521
        xchg    esi, [esp]
1727
        xchg    esi, [esp]
1522
        mov     ecx, 11
1728
        mov     ecx, 11
1523
        rep     movsb
1729
        rep     movsb
Line 1535... Line 1741...
1535
        mov     [edi+18], ax            ; last access date
1741
        mov     [edi+18], ax            ; last access date
1536
        and     word [edi+20], 0        ; high word of cluster
1742
        and     word [edi+20], 0        ; high word of cluster
1537
        and     word [edi+26], 0        ; low word of cluster - to be filled
1743
        and     word [edi+26], 0        ; low word of cluster - to be filled
1538
        and     dword [edi+28], 0       ; file size - to be filled
1744
        and     dword [edi+28], 0       ; file size - to be filled
1539
.doit:
1745
.doit:
1540
        push    ecx edx
1746
        push    edx
1541
        push    ecx
1747
        push    ecx
1542
        push    edi
1748
        push    edi
1543
        add     edi, 26         ; edi points to low word of cluster
1749
        add     edi, 26         ; edi points to low word of cluster
1544
        push    edi
1750
        push    edi
1545
        jecxz   .done
1751
        jecxz   .done
Line 1576... Line 1782...
1576
        sub     [esp+12], ecx
1782
        sub     [esp+12], ecx
1577
        pop     ecx
1783
        pop     ecx
1578
        jnz     .write_loop
1784
        jnz     .write_loop
1579
.done:
1785
.done:
1580
        mov     ebx, edx
1786
        mov     ebx, edx
1581
        pop     edi edi ecx edx ecx
1787
        pop     edi edi ecx edx
1582
        sub     ebx, edx
1788
        sub     ebx, edx
1583
        mov     [edi+28], ebx
1789
        mov     [edi+28], ebx
-
 
1790
        add     esp, 20
1584
        pop     edi
1791
        popad
1585
        xor     eax, eax
1792
        xor     eax, eax
1586
        ret
1793
        ret
1587
.disk_full2:
1794
.disk_full2:
1588
        mov     ebx, edx
1795
        mov     ebx, edx
1589
        pop     edi edi ecx edx ecx
1796
        pop     edi edi ecx edx
1590
        sub     ebx, edx
1797
        sub     ebx, edx
1591
        mov     [edi+28], ebx
1798
        mov     [edi+28], ebx
-
 
1799
        add     esp, 20
1592
        pop     edi
1800
        popad
1593
        push    ERROR_DISK_FULL
1801
        push    ERROR_DISK_FULL
1594
        pop     eax
1802
        pop     eax
1595
        ret
1803
        ret
Line 1596... Line 1804...
1596
 
1804
 
Line 1652... Line 1860...
1652
        call    bdfe_to_fat_entry
1860
        call    bdfe_to_fat_entry
1653
        pop     edi
1861
        pop     edi
1654
        xor     eax, eax
1862
        xor     eax, eax
1655
        ret
1863
        ret
Line -... Line 1864...
-
 
1864
 
-
 
1865
;----------------------------------------------------------------
-
 
1866
;
-
 
1867
;  fs_RamdiskExecute - LFN variant for executing on sys floppy
-
 
1868
;
-
 
1869
;  esi  points to ramdisk filename (e.g. 'launcher')
-
 
1870
;  ebp  points to full filename (e.g. '/rd/1/launcher')
-
 
1871
;  dword [ebx] = flags
-
 
1872
;  dword [ebx+4] = cmdline
-
 
1873
;
-
 
1874
;  ret ebx,edx destroyed
-
 
1875
;      eax > 0 - PID, < 0 - error
-
 
1876
;
-
 
1877
;--------------------------------------------------------------
-
 
1878
fs_RamdiskExecute:
-
 
1879
        mov     edx, [ebx]
-
 
1880
        mov     ebx, [ebx+4]
-
 
1881
        test    ebx, ebx
-
 
1882
        jz      @f
-
 
1883
        add     ebx, std_application_base_address
-
 
1884
@@:
-
 
1885
 
-
 
1886
;----------------------------------------------------------------
-
 
1887
;
-
 
1888
; fs_RamdiskExecute.flags - second entry
-
 
1889
;
-
 
1890
;  esi  points to ramdisk filename (kernel address)
-
 
1891
;  ebp  points to full filename
-
 
1892
;  edx  flags
-
 
1893
;  ebx  cmdline (kernel address)
-
 
1894
;
-
 
1895
;  ret  eax > 0 - PID, < 0 - error
-
 
1896
;
-
 
1897
;--------------------------------------------------------------
-
 
1898
 
-
 
1899
.flags:
-
 
1900
        cmp     byte [esi], 0
-
 
1901
        jnz     @f
-
 
1902
; cannot execute root!
-
 
1903
        mov     eax, -ERROR_ACCESS_DENIED
-
 
1904
        ret
-
 
1905
@@:
-
 
1906
        push    edi
-
 
1907
        call    rd_find_lfn
-
 
1908
        jnc     .found
-
 
1909
        pop     edi
-
 
1910
        mov     eax, -ERROR_FILE_NOT_FOUND
-
 
1911
        ret
-
 
1912
.found:
-
 
1913
        movzx   eax, word [edi+26]      ; cluster
-
 
1914
        push    eax
-
 
1915
        push    dword [edi+28]          ; size
-
 
1916
        push    .DoRead
-
 
1917
        call    fs_execute
-
 
1918
        add     esp, 12
-
 
1919
        pop     edi
-
 
1920
        ret
-
 
1921
 
-
 
1922
.DoRead:
-
 
1923
; read next block
-
 
1924
; in: eax->parameters, edi->buffer
-
 
1925
; out: eax = error code
-
 
1926
        pushad
-
 
1927
        cmp     dword [eax], 0  ; file size
-
 
1928
        jz      .eof
-
 
1929
        mov     edx, [eax+4]    ; cluster
-
 
1930
        lea     esi, [edx+31]
-
 
1931
        shl     esi, 9
-
 
1932
        add     esi, 0x100000
-
 
1933
        mov     ecx, 512/4
-
 
1934
        rep     movsd
-
 
1935
        mov     ecx, [eax]
-
 
1936
        sub     ecx, 512
-
 
1937
        jae     @f
-
 
1938
        add     edi, ecx
-
 
1939
        neg     ecx
-
 
1940
        push    eax
-
 
1941
        xor     eax, eax
-
 
1942
        rep     stosb
-
 
1943
        pop     eax
-
 
1944
@@:
-
 
1945
        mov     [eax], ecx
-
 
1946
        mov     dx, [edx*2+0x280000]
-
 
1947
        mov     [eax+4], dx     ; high word is already zero
-
 
1948
        popad
-
 
1949
        xor     eax, eax
-
 
1950
        ret
-
 
1951
.eof:
-
 
1952
        popad
-
 
1953
        mov     eax, 6
-
 
1954
        ret
1656
 
1955