Subversion Repositories Kolibri OS

Rev

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

Rev 6798 Rev 6845
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: 6798 $
8
$Revision: 6845 $
9
 
9
 
10
; FAT external functions
10
; FAT external functions
11
;   in:
11
;   in:
Line 1523... Line 1523...
1523
 
1523
 
1524
;----------------------------------------------------------------
1524
;----------------------------------------------------------------
1525
fat_Read:
1525
fat_Read:
1526
        call    fat_lock
1526
        call    fat_lock
1527
        push    edi
-
 
1528
        cmp     byte [esi], 0
-
 
1529
        jnz     @f
-
 
1530
.noaccess:
-
 
1531
        pop     edi
-
 
1532
        call    fat_unlock
-
 
1533
        or      ebx, -1
-
 
1534
        mov     eax, ERROR_ACCESS_DENIED
-
 
1535
        ret
-
 
1536
@@:
1527
        push    edi
1537
        call    hd_find_lfn
1528
        call    hd_find_lfn
1538
        jnc     .found
-
 
1539
        pop     edi
-
 
1540
        push    eax
-
 
1541
        call    fat_unlock
-
 
1542
        pop     eax
-
 
1543
        or      ebx, -1
-
 
1544
        ret
-
 
1545
.found:
1529
        jc      .notFound
1546
        test    byte [edi+11], 0x10     ; do not allow read directories
1530
        test    byte [edi+11], 0x10     ; do not allow read directories
1547
        jnz     .noaccess
1531
        jnz     .noaccess
1548
        cmp     dword [ebx+8], 0
-
 
1549
        jz      @f
-
 
1550
        xor     ebx, ebx
-
 
1551
        call    fat_unlock
-
 
1552
        mov     eax, ERROR_END_OF_FILE
1532
        cmp     dword [ebx+8], 0
1553
        pop     edi
-
 
1554
        ret
-
 
1555
@@:
1533
        jnz     .endOfFile
1556
        mov     edx, [ebx+4]    ; file offset
1534
        mov     edx, [ebx+4]    ; file offset
1557
        mov     ecx, [ebx+12]   ; size
1535
        mov     ecx, [ebx+12]   ; size
1558
        mov     ebx, [ebx+16]   ; buffer
1536
        mov     ebx, [ebx+16]   ; buffer
1559
        push    ebx
1537
        push    ebx
Line 1581... Line 1559...
1581
        sub     edx, edi
1559
        sub     edx, edi
1582
        jc      @f
1560
        jc      @f
1583
        call    get_FAT
1561
        call    get_FAT
1584
        jc      .noaccess2
1562
        jc      .noaccess2
1585
        jmp     @b
1563
        jmp     @b
-
 
1564
 
-
 
1565
.notFound:
-
 
1566
        push    eax
-
 
1567
        jmp     .ret
-
 
1568
 
-
 
1569
.noaccess:
-
 
1570
        push    ERROR_ACCESS_DENIED
-
 
1571
        jmp     .ret
-
 
1572
 
-
 
1573
.endOfFile:
-
 
1574
        push    ERROR_END_OF_FILE
-
 
1575
.ret:
-
 
1576
        call    fat_unlock
-
 
1577
        pop     eax edi
-
 
1578
        xor     ebx, ebx
-
 
1579
        ret
-
 
1580
 
1586
@@:
1581
@@:
1587
        mov     esi, eax
1582
        mov     esi, eax
1588
        dec     eax
1583
        dec     eax
1589
        dec     eax
1584
        dec     eax
1590
        imul    eax, [ebp+FAT.SECTORS_PER_CLUSTER]
1585
        imul    eax, [ebp+FAT.SECTORS_PER_CLUSTER]
Line 1672... Line 1667...
1672
        jnz     .noaccess3
1667
        jnz     .noaccess3
1673
        pop     ecx
1668
        pop     ecx
1674
        xor     edx, edx
1669
        xor     edx, edx
1675
        jecxz   .done
1670
        jecxz   .done
1676
        jmp     .alignedCluster
1671
        jmp     .alignedCluster
-
 
1672
 
1677
.readEnd:
1673
.readEnd:
1678
        add     ecx, edi
1674
        add     ecx, edi
1679
        mov     edi, ecx
1675
        mov     edi, ecx
1680
        and     ecx, 511
1676
        and     ecx, 511
1681
        shr     edi, 9
1677
        shr     edi, 9
Line 1686... Line 1682...
1686
        add     eax, edi
1682
        add     eax, edi
1687
        push    ecx
1683
        push    ecx
1688
        push    eax
1684
        push    eax
1689
        mov     ecx, eax
1685
        mov     ecx, eax
1690
        jmp     .readFragment
1686
        jmp     .readFragment
-
 
1687
 
1691
.noaccess3:
1688
.noaccess3:
1692
        pop     eax
1689
        pop     eax
1693
.noaccess2:
1690
.noaccess2:
1694
        mov     byte [esp], ERROR_DEVICE
1691
        mov     byte [esp], ERROR_DEVICE
1695
.done:
1692
.done:
1696
        call    fat_unlock
1693
        call    fat_unlock
1697
        pop     eax edx edi
1694
        pop     eax edx edi
1698
        sub     ebx, edx
1695
        sub     ebx, edx
1699
        ret
1696
        ret
-
 
1697
 
1700
.fileEnd:
1698
.fileEnd:
1701
        mov     byte [esp], ERROR_END_OF_FILE
1699
        mov     byte [esp], ERROR_END_OF_FILE
1702
        jmp     .done
1700
        jmp     .done
-
 
1701
 
1703
.noaccess4:
1702
.noaccess4:
1704
        mov     byte [esp], ERROR_DEVICE
1703
        mov     byte [esp], ERROR_DEVICE
1705
        jmp     @f
1704
        jmp     @f
-
 
1705
 
1706
.fileEnd2:
1706
.fileEnd2:
1707
        mov     byte [esp], ERROR_END_OF_FILE
1707
        mov     byte [esp], ERROR_END_OF_FILE
1708
@@:
1708
@@:
1709
        inc     esi
1709
        inc     esi
1710
        xor     ecx, ecx
1710
        xor     ecx, ecx
Line 2099... Line 2099...
2099
        add     ecx, [eax+4]
2099
        add     ecx, [eax+4]
2100
        mov     eax, ecx
2100
        mov     eax, ecx
2101
        pop     ecx
2101
        pop     ecx
2102
        ret
2102
        ret
Line 2103... Line -...
2103
 
-
 
2104
fshrad:
-
 
2105
        call    fat_unlock
-
 
2106
        mov     eax, ERROR_ACCESS_DENIED
-
 
2107
        xor     ebx, ebx
-
 
2108
        ret
-
 
2109
 
2103
 
2110
;----------------------------------------------------------------
2104
;----------------------------------------------------------------
2111
fat_CreateFolder:
2105
fat_CreateFolder:
2112
        push    1
2106
        push    1
Line 2113... Line 2107...
2113
        jmp     @f
2107
        jmp     @f
2114
 
2108
 
2115
fat_CreateFile:
2109
fat_CreateFile:
2116
        push    0
2110
        push    0
2117
@@:
2111
@@:
2118
        call    fat_lock
-
 
2119
        pop     eax
-
 
2120
        cmp     byte [esi], 0
2112
        call    fat_lock
2121
        jz      fshrad
2113
        pop     eax
2122
        mov     ecx, [ebx+12]
2114
        mov     ecx, [ebx+12]
2123
        mov     edx, [ebx+16]
2115
        mov     edx, [ebx+16]
2124
        pushad
2116
        pushad
Line 2659... Line 2651...
2659
        loop    fat_read_symbols
2651
        loop    fat_read_symbols
2660
        ret
2652
        ret
Line 2661... Line 2653...
2661
 
2653
 
2662
;----------------------------------------------------------------
2654
;----------------------------------------------------------------
2663
fat_Write:
-
 
2664
        cmp     byte [esi], 0
-
 
2665
        jz      .access_denied
2655
fat_Write:
2666
        call    fat_lock
2656
        call    fat_lock
2667
        push    edi
2657
        push    edi
2668
        call    hd_find_lfn
-
 
2669
        jnc     .found
-
 
2670
        pop     edi
-
 
2671
        push    eax
-
 
2672
        call    fat_unlock
-
 
2673
.ret0:
-
 
2674
        pop     eax
-
 
2675
        xor     ebx, ebx
-
 
2676
        ret
-
 
2677
 
-
 
2678
.access_denied:
-
 
2679
        push    ERROR_ACCESS_DENIED
2658
        call    hd_find_lfn
2680
        jmp     .ret0
-
 
2681
 
-
 
2682
.found:     ; FAT does not support files larger than 4GB
2659
        jc      .error
2683
        cmp     dword [ebx+8], 0
-
 
2684
        jz      @f
-
 
2685
.eof:
-
 
2686
        pop     edi
-
 
2687
        push    ERROR_END_OF_FILE
2660
        cmp     dword [ebx+8], 0
2688
        call    fat_unlock
-
 
2689
        jmp     .ret0
-
 
2690
@@:
2661
        jnz     .eof    ; FAT does not support files larger than 4GB
2691
        mov     ecx, [ebx+12]
2662
        mov     ecx, [ebx+12]
2692
        mov     edx, [ebx+16]
2663
        mov     edx, [ebx+16]
2693
        mov     ebx, [ebx+4]
2664
        mov     ebx, [ebx+4]
2694
; now edi points to direntry, ebx=start byte to write,
2665
; now edi points to direntry, ebx=start byte to write,
Line 2713... Line 2684...
2713
        jnc     .length_ok
2684
        jnc     .length_ok
2714
        mov     [esp+4], eax
2685
        mov     [esp+4], eax
2715
; hd_extend_file can return three error codes: FAT table error, device error or disk full.
2686
; hd_extend_file can return three error codes: FAT table error, device error or disk full.
2716
; First two cases are fatal errors, in third case we may write some data
2687
; First two cases are fatal errors, in third case we may write some data
2717
        cmp     al, ERROR_DISK_FULL
2688
        cmp     al, ERROR_DISK_FULL
2718
        jz      .disk_full
-
 
2719
        call    fat_unlock
-
 
2720
        pop     eax
-
 
2721
        pop     eax
2689
        jnz     @f
2722
        pop     ecx
-
 
2723
        pop     edx
-
 
2724
        pop     edi
-
 
2725
        xor     ebx, ebx
-
 
2726
        ret
-
 
2727
.disk_full:
-
 
2728
; correct number of bytes to write
2690
; correct number of bytes to write
2729
        mov     ecx, [edi+28]
2691
        mov     ecx, [edi+28]
2730
        cmp     ecx, ebx
2692
        cmp     ecx, ebx
2731
        ja      .length_ok
2693
        ja      .length_ok
2732
        push    0
2694
        push    0
Line 2737... Line 2699...
2737
        call    update_disk
2699
        call    update_disk
2738
        test    eax, eax
2700
        test    eax, eax
2739
        jz      @f
2701
        jz      @f
2740
        mov     byte [esp+4], ERROR_DEVICE
2702
        mov     byte [esp+4], ERROR_DEVICE
2741
@@:
2703
@@:
-
 
2704
        pop     eax eax ecx edx
-
 
2705
.error:
-
 
2706
        push    eax
-
 
2707
@@:
2742
        call    fat_unlock
2708
        call    fat_unlock
2743
        pop     eax
-
 
2744
        pop     eax
2709
        pop     eax edi
2745
        pop     ecx
-
 
2746
        pop     edx
2710
        xor     ebx, ebx
2747
        pop     edi
-
 
2748
        ret
2711
        ret
-
 
2712
 
-
 
2713
.eof:
-
 
2714
        push    ERROR_END_OF_FILE
-
 
2715
        jmp     @b
-
 
2716
 
-
 
2717
.device_err2:
-
 
2718
        pop     ecx
-
 
2719
.device_err:
-
 
2720
        mov     byte [esp+8], ERROR_DEVICE
-
 
2721
        jmp     .ret
-
 
2722
 
-
 
2723
.fat_err:
-
 
2724
        mov     byte [esp+8], ERROR_FS_FAIL
-
 
2725
        jmp     .ret
-
 
2726
 
2749
.length_ok:
2727
.length_ok:
2750
        mov     esi, [edi+28]
2728
        mov     esi, [edi+28]
2751
        mov     eax, [edi+20-2]
2729
        mov     eax, [edi+20-2]
2752
        mov     ax, [edi+26]
2730
        mov     ax, [edi+26]
2753
        mov     edi, eax        ; edi=current cluster
2731
        mov     edi, eax        ; edi=current cluster
Line 2757... Line 2735...
2757
        push    ebx
2735
        push    ebx
2758
        lea     ebx, [ebp+FAT.buffer]
2736
        lea     ebx, [ebp+FAT.buffer]
2759
        call    fs_write32_sys
2737
        call    fs_write32_sys
2760
        pop     ebx
2738
        pop     ebx
2761
        test    eax, eax
2739
        test    eax, eax
2762
        jz      @f
-
 
2763
.device_err:
-
 
2764
        mov     byte [esp+8], ERROR_DEVICE
-
 
2765
        jmp     .ret
2740
        jnz     .device_err
2766
.fat_err:
-
 
2767
        mov     byte [esp+8], ERROR_FS_FAIL
-
 
2768
        jmp     .ret
-
 
2769
@@:
-
 
2770
 
-
 
2771
; now ebx=start pos, ecx=end pos, both lie inside file
2741
; now ebx=start pos, ecx=end pos, both lie inside file
2772
        sub     ecx, ebx
2742
        sub     ecx, ebx
2773
        jz      .ret
2743
        jz      .ret
2774
.write_loop:
2744
.write_loop:
2775
; skip unmodified sectors
2745
; skip unmodified sectors
Line 2809... Line 2779...
2809
        push    eax ebx
2779
        push    eax ebx
2810
        lea     ebx, [ebp+FAT.buffer]
2780
        lea     ebx, [ebp+FAT.buffer]
2811
        call    fs_read32_app
2781
        call    fs_read32_app
2812
        test    eax, eax
2782
        test    eax, eax
2813
        pop     ebx eax
2783
        pop     ebx eax
2814
        jz      @f
-
 
2815
.device_err2:
-
 
2816
        pop     ecx
-
 
2817
        jmp     .device_err
2784
        jnz     .device_err2
2818
@@:
-
 
2819
.noread:
2785
.noread:
2820
; zero uninitialized data if file was extended (because hd_extend_file does not this)
2786
; zero uninitialized data if file was extended (because hd_extend_file does not this)
2821
        push    eax ecx edi
2787
        push    eax ecx edi
2822
        xor     eax, eax
2788
        xor     eax, eax
2823
        mov     ecx, 0x200
2789
        mov     ecx, 0x200
Line 2994... Line 2960...
2994
 
2960
 
2995
;----------------------------------------------------------------
2961
;----------------------------------------------------------------
2996
fat_SetFileEnd:
2962
fat_SetFileEnd:
2997
        call    fat_lock
2963
        call    fat_lock
2998
        push    edi
-
 
2999
        cmp     byte [esi], 0
-
 
3000
        jnz     @f
-
 
3001
.access_denied:
-
 
3002
        push    ERROR_ACCESS_DENIED
-
 
3003
.ret:
-
 
3004
        call    fat_unlock
-
 
3005
        pop     eax
-
 
3006
        pop     edi
-
 
3007
        ret
-
 
3008
@@:
2964
        push    edi
3009
        call    hd_find_lfn
-
 
3010
        jnc     @f
-
 
3011
.reteax:
-
 
3012
        push    eax
2965
        call    hd_find_lfn
3013
        jmp     .ret
-
 
3014
@@:
2966
        jc      .reteax
3015
; must not be directory
2967
; must not be directory
3016
        test    byte [edi+11], 10h
2968
        test    byte [edi+11], 10h
3017
        jnz     .access_denied
2969
        jnz     .access_denied
3018
; file size must not exceed 4 Gb
2970
; file size must not exceed 4 Gb
3019
        cmp     dword [ebx+8], 0
2971
        cmp     dword [ebx+8], 0
3020
        jz      @f
-
 
3021
        push    ERROR_END_OF_FILE
-
 
3022
        jmp     .ret
-
 
3023
@@:
2972
        jnz     .endOfFile
3024
        push    eax     ; save directory sector
2973
        push    eax     ; save directory sector
3025
; set file modification date/time to current
2974
; set file modification date/time to current
3026
        call    fat_update_datetime
2975
        call    fat_update_datetime
3027
        mov     eax, [ebx+4]
2976
        mov     eax, [ebx+4]
Line 3030... Line 2979...
3030
        ja      .expand
2979
        ja      .expand
3031
        pop     eax
2980
        pop     eax
3032
        lea     ebx, [ebp+FAT.buffer]
2981
        lea     ebx, [ebp+FAT.buffer]
3033
        call    fs_write32_sys
2982
        call    fs_write32_sys
3034
        test    eax, eax
2983
        test    eax, eax
3035
        jz      @f
-
 
3036
        push    ERROR_DEVICE
-
 
3037
        jmp     .ret
2984
        jnz     .errorDevice
3038
@@:
-
 
3039
        push    0
2985
        push    0
3040
        jmp     .ret
2986
        jmp     .ret
-
 
2987
 
-
 
2988
.access_denied:
-
 
2989
        push    ERROR_ACCESS_DENIED
-
 
2990
        jmp     .ret
-
 
2991
 
-
 
2992
.endOfFile:
-
 
2993
        push    ERROR_END_OF_FILE
-
 
2994
        jmp     .ret
-
 
2995
 
-
 
2996
.errorDevice:
-
 
2997
        push    ERROR_DEVICE
-
 
2998
        jmp     .ret
-
 
2999
 
3041
.expand:
3000
.expand:
3042
        push    ebx ebp ecx
3001
        push    ebx ebp ecx
3043
        push    dword [edi+28]  ; save old size
3002
        push    dword [edi+28]  ; save old size
3044
        mov     ecx, eax
3003
        mov     ecx, eax
3045
        call    hd_extend_file
3004
        call    hd_extend_file
3046
        push    eax             ; return code
3005
        push    eax             ; return code
3047
        jnc     .expand_ok
3006
        jnc     .expand_ok
3048
        cmp     al, ERROR_DISK_FULL
3007
        cmp     al, ERROR_DISK_FULL
3049
        jz      .disk_full
-
 
3050
.pop_ret:
-
 
3051
        call    update_disk
-
 
3052
        pop     eax ecx ecx ebp ebx ecx
-
 
3053
        jmp     .reteax
3008
        jnz     .pop_ret
3054
.expand_ok:
-
 
3055
.disk_full:
-
 
3056
; save directory
3009
.expand_ok: ; save directory
3057
        mov     eax, [edi+28]
3010
        mov     eax, [edi+28]
3058
        xchg    eax, [esp+20]
3011
        xchg    eax, [esp+20]
3059
        lea     ebx, [ebp+FAT.buffer]
3012
        lea     ebx, [ebp+FAT.buffer]
3060
        call    fs_write32_sys
3013
        call    fs_write32_sys
3061
        test    eax, eax
3014
        test    eax, eax
3062
        mov     eax, [edi+20-2]
3015
        mov     eax, [edi+20-2]
3063
        mov     ax, [edi+26]
3016
        mov     ax, [edi+26]
3064
        mov     edi, eax
3017
        mov     edi, eax
3065
        jz      @f
-
 
3066
.pop_ret11:
-
 
3067
        mov     byte [esp], ERROR_DEVICE
-
 
3068
        jmp     .pop_ret
3018
        jnz     .pop_ret11
3069
@@:
-
 
3070
        test    edi, edi
3019
        test    edi, edi
3071
        jz      .pop_ret
3020
        jz      .pop_ret
3072
; now zero new data
3021
; now zero new data
3073
        push    0
3022
        push    0
3074
; edi=current cluster, [esp]=sector in cluster
3023
; edi=current cluster, [esp]=sector in cluster
Line 3121... Line 3070...
3121
        mov     eax, edi
3070
        mov     eax, edi
3122
        call    get_FAT
3071
        call    get_FAT
3123
        mov     edi, eax
3072
        mov     edi, eax
3124
        jnc     .zero_loop
3073
        jnc     .zero_loop
3125
        pop     eax
3074
        pop     eax
-
 
3075
.pop_ret11:
-
 
3076
        mov     byte [esp], ERROR_DEVICE
-
 
3077
.pop_ret:
-
 
3078
        call    update_disk
-
 
3079
        pop     eax ecx ecx ebp ebx ecx
-
 
3080
.reteax:
-
 
3081
        push    eax
-
 
3082
.ret:
-
 
3083
        call    fat_unlock
-
 
3084
        pop     eax edi
-
 
3085
        ret
-
 
3086
 
-
 
3087
.error_fat:
-
 
3088
        pop     eax
-
 
3089
        mov     byte [esp], ERROR_FS_FAIL
3126
        jmp     .pop_ret11
3090
        jmp     .pop_ret
-
 
3091
 
-
 
3092
.error_fat2:
-
 
3093
        pop     eax ecx eax
-
 
3094
        call    update_disk
-
 
3095
        push    ERROR_FS_FAIL
-
 
3096
        jmp     .ret
-
 
3097
 
3127
.truncate:
3098
.truncate:
3128
        mov     [edi+28], eax
3099
        mov     [edi+28], eax
3129
        push    ecx
3100
        push    ecx
3130
        mov     ecx, [edi+20-2]
3101
        mov     ecx, [edi+20-2]
3131
        mov     cx, [edi+26]
3102
        mov     cx, [edi+26]
3132
        push    eax
3103
        push    eax
3133
        test    eax, eax
3104
        test    eax, eax
3134
        jz      .zero_size
3105
        jz      .zero_size
3135
; find new last cluster
3106
@@: ; find new last cluster
3136
@@:
-
 
3137
        cmp     ecx, 2
3107
        cmp     ecx, 2
3138
        jb      .error_fat2
3108
        jb      .error_fat2
3139
        cmp     ecx, [ebp+FAT.fatRESERVED]
3109
        cmp     ecx, [ebp+FAT.fatRESERVED]
3140
        jae     .error_fat2
3110
        jae     .error_fat2
3141
        mov     eax, [ebp+FAT.SECTORS_PER_CLUSTER]
3111
        mov     eax, [ebp+FAT.SECTORS_PER_CLUSTER]
Line 3145... Line 3115...
3145
        mov     eax, ecx
3115
        mov     eax, ecx
3146
        call    get_FAT
3116
        call    get_FAT
3147
        mov     ecx, eax
3117
        mov     ecx, eax
3148
        jnc     @b
3118
        jnc     @b
3149
.device_err3:
3119
.device_err3:
3150
        pop     eax ecx eax edi
3120
        pop     eax ecx eax
3151
        call    update_disk
3121
        call    update_disk
3152
        call    fat_unlock
-
 
3153
        movi    eax, ERROR_DEVICE
3122
        push    ERROR_DEVICE
3154
        ret
3123
        jmp     .ret
-
 
3124
 
3155
@@:
3125
@@:
3156
; we will zero data at the end of last sector - remember it
3126
; we will zero data at the end of last sector - remember it
3157
        push    ecx
3127
        push    ecx
3158
; terminate FAT chain
3128
; terminate FAT chain
3159
        push    edx
3129
        push    edx
Line 3164... Line 3134...
3164
        pop     edx
3134
        pop     edx
3165
        jnc     @f
3135
        jnc     @f
3166
.device_err4:
3136
.device_err4:
3167
        pop     ecx
3137
        pop     ecx
3168
        jmp     .device_err3
3138
        jmp     .device_err3
-
 
3139
 
3169
.zero_size:
3140
.zero_size:
3170
        and     word [edi+20], 0
3141
        and     word [edi+20], 0
3171
        and     word [edi+26], 0
3142
        and     word [edi+26], 0
3172
        push    0
3143
        push    0
3173
        mov     eax, ecx
3144
        mov     eax, ecx
Line 3213... Line 3184...
3213
        pop     ecx eax edi
3184
        pop     ecx eax edi
3214
        call    update_disk
3185
        call    update_disk
3215
        call    fat_unlock
3186
        call    fat_unlock
3216
        xor     eax, eax
3187
        xor     eax, eax
3217
        ret
3188
        ret
3218
.error_fat:
-
 
3219
        pop     eax
-
 
3220
        mov     byte [esp], ERROR_FS_FAIL
-
 
3221
        jmp     .pop_ret
-
 
3222
.error_fat2:
-
 
3223
        pop     eax ecx eax edi
-
 
3224
        call    update_disk
-
 
3225
        call    fat_unlock
-
 
3226
        movi    eax, ERROR_FS_FAIL
-
 
3227
        ret
-
 
Line 3228... Line 3189...
3228
 
3189
 
3229
;----------------------------------------------------------------
3190
;----------------------------------------------------------------
3230
fat_GetFileInfo:
3191
fat_GetFileInfo:
3231
        cmp     byte [esi], 0
3192
        cmp     byte [esi], 0
Line 3254... Line 3215...
3254
        pop     edi
3215
        pop     edi
3255
        ret
3216
        ret
Line 3256... Line 3217...
3256
 
3217
 
3257
;----------------------------------------------------------------
3218
;----------------------------------------------------------------
3258
fat_SetFileInfo:
-
 
3259
        cmp     byte [esi], 0
-
 
3260
        jnz     @f
-
 
3261
        mov     eax, 2
-
 
3262
        ret
-
 
3263
@@:
3219
fat_SetFileInfo:
3264
        push    edi
3220
        push    edi
3265
        call    fat_lock
3221
        call    fat_lock
3266
        call    hd_find_lfn
3222
        call    hd_find_lfn
3267
        jc      .error
3223
        jc      .error
Line 3284... Line 3240...
3284
        ret
3240
        ret
Line 3285... Line 3241...
3285
 
3241
 
3286
;----------------------------------------------------------------
3242
;----------------------------------------------------------------
3287
fat_Delete:
3243
fat_Delete:
3288
        call    fat_lock
-
 
3289
        cmp     byte [esi], 0
-
 
3290
        jnz     @f
-
 
3291
; cannot delete root!
-
 
3292
.access_denied:
-
 
3293
        push    ERROR_ACCESS_DENIED
-
 
3294
.pop_ret:
-
 
3295
        call    fat_unlock
-
 
3296
        pop     eax
-
 
3297
        xor     ebx, ebx
-
 
3298
        ret
-
 
3299
@@:
3244
        call    fat_lock
3300
        and     [ebp+FAT.longname_sec1], 0
3245
        and     [ebp+FAT.longname_sec1], 0
3301
        and     [ebp+FAT.longname_sec2], 0
3246
        and     [ebp+FAT.longname_sec2], 0
3302
        push    edi
3247
        push    edi
3303
        call    hd_find_lfn
3248
        call    hd_find_lfn
3304
        jnc     .found
-
 
3305
        pop     edi
-
 
3306
        push    ERROR_FILE_NOT_FOUND
-
 
3307
        jmp     .pop_ret
-
 
3308
.found:
3249
        jc      .notFound
3309
        cmp     dword [edi], '.   '
3250
        cmp     dword [edi], '.   '
3310
        jz      .access_denied2
3251
        jz      .access_denied2
3311
        cmp     dword [edi], '..  '
3252
        cmp     dword [edi], '..  '
3312
        jz      .access_denied2
3253
        jz      .access_denied2
Line 3357... Line 3298...
3357
        lea     eax, [ebx+0x200]
3298
        lea     eax, [ebx+0x200]
3358
        jz      .checkempty
3299
        jz      .checkempty
3359
.err1:
3300
.err1:
3360
        popad
3301
        popad
3361
.err2:
3302
.err2:
3362
        pop     edi
3303
        push    ERROR_DEVICE
-
 
3304
.ret:
3363
        call    fat_unlock
3305
        call    fat_unlock
3364
        movi    eax, ERROR_DEVICE
3306
        pop     eax edi
3365
        ret
3307
        ret
-
 
3308
 
-
 
3309
.notFound:
-
 
3310
        push    ERROR_FILE_NOT_FOUND
-
 
3311
        jmp     .ret
-
 
3312
 
3366
.error_fat:
3313
.error_fat:
3367
        popad
3314
        popad
3368
        pop     edi
-
 
3369
        call    fat_unlock
-
 
3370
        movi    eax, ERROR_FS_FAIL
3315
        push    ERROR_FS_FAIL
3371
        ret
3316
        jmp     .ret
-
 
3317
 
3372
.notempty:
3318
.notempty:
3373
        popad
3319
        popad
3374
.access_denied2:
3320
.access_denied2:
3375
        pop     edi
-
 
3376
        call    fat_unlock
-
 
3377
        movi    eax, ERROR_ACCESS_DENIED
3321
        push    ERROR_ACCESS_DENIED
3378
        ret
3322
        jmp     .ret
-
 
3323
 
3379
.empty:
3324
.empty:
3380
        popad
3325
        popad
3381
        push    eax ebx
3326
        push    eax ebx
3382
        lea     ebx, [ebp+FAT.buffer]
3327
        lea     ebx, [ebp+FAT.buffer]
3383
        call    fs_read32_sys
3328
        call    fs_read32_sys