Subversion Repositories Kolibri OS

Rev

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

Rev 88 Rev 91
Line 5... Line 5...
5
;;  FAT16/32 functions for MenuetOS                                ;;
5
;;  FAT16/32 functions for MenuetOS                                ;;
6
;;                                                                 ;;
6
;;                                                                 ;;
7
;;  Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it          ;;
7
;;  Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it          ;;
8
;;                                                                 ;;
8
;;                                                                 ;;
9
;;  See file COPYING for details                                   ;;
9
;;  See file COPYING for details                                   ;;
-
 
10
;;  23.06.2006 LFN start application - diamond                     ;;
10
;;  15.06.2006 LFN get/set file/folder info - diamond              ;;
11
;;  15.06.2006 LFN get/set file/folder info - diamond              ;;
11
;;  27.05.2006 LFN create/rewrite file - diamond                   ;;
12
;;  27.05.2006 LFN create/rewrite file - diamond                   ;;
12
;;  04.05.2006 LFN read folder - diamond                           ;;
13
;;  04.05.2006 LFN read folder - diamond                           ;;
13
;;  29.04.2006 Elimination of hangup after the                     ;;
14
;;  29.04.2006 Elimination of hangup after the                     ;;
14
;;             expiration hd_wait_timeout -  Mario79               ;;           
15
;;             expiration hd_wait_timeout -  Mario79               ;;           
Line 3394... Line 3395...
3394
        push    fat_notroot_first
3395
        push    fat_notroot_first
3395
        push    fat_notroot_next
3396
        push    fat_notroot_next
3396
.common1:
3397
.common1:
3397
        call    fat_find_lfn
3398
        call    fat_find_lfn
3398
        jc      .notfound
3399
        jc      .notfound
-
 
3400
; found; must not be directory
-
 
3401
        test    byte [edi+11], 10h
-
 
3402
        jz      @f
-
 
3403
        add     esp, 32
-
 
3404
        popad
-
 
3405
        mov     eax, ERROR_ACCESS_DENIED
-
 
3406
        xor     ebx, ebx
-
 
3407
        ret
-
 
3408
@@:
3399
; found, delete FAT chain
3409
; delete FAT chain
3400
        push    edi
3410
        push    edi
3401
        xor     eax, eax
3411
        xor     eax, eax
3402
        mov     dword [edi+28], eax     ; zero size
3412
        mov     dword [edi+28], eax     ; zero size
3403
        xor     ecx, ecx
3413
        xor     ecx, ecx
3404
        mov     eax, [edi+20-2]
3414
        mov     eax, [edi+20-2]
Line 3799... Line 3809...
3799
        call    update_disk
3809
        call    update_disk
3800
        pop     edi
3810
        pop     edi
3801
        xor     eax, eax
3811
        xor     eax, eax
3802
        ret
3812
        ret
Line -... Line 3813...
-
 
3813
 
-
 
3814
;----------------------------------------------------------------
-
 
3815
;
-
 
3816
;  fs_HdExecute - LFN variant for executing from harddisk
-
 
3817
;
-
 
3818
;  esi  points to hd filename (e.g. 'dir1/name')
-
 
3819
;  ebp  points to full filename (e.g. '/hd0/1/dir1/name')
-
 
3820
;  dword [ebx] = flags
-
 
3821
;  dword [ebx+4] = cmdline
-
 
3822
;
-
 
3823
;  ret ebx,edx destroyed
-
 
3824
;      eax > 0 - PID, < 0 - error
-
 
3825
;
-
 
3826
;--------------------------------------------------------------
-
 
3827
fs_HdExecute:
-
 
3828
        mov     edx, [ebx]
-
 
3829
        mov     ebx, [ebx+4]
-
 
3830
        test    ebx, ebx
-
 
3831
        jz      @f
-
 
3832
        add     ebx, std_application_base_address
-
 
3833
@@:
-
 
3834
 
-
 
3835
;----------------------------------------------------------------
-
 
3836
;
-
 
3837
; fs_HdExecute.flags - second entry
-
 
3838
;
-
 
3839
;  esi  points to floppy filename (kernel address)
-
 
3840
;  ebp  points to full filename
-
 
3841
;  edx  flags
-
 
3842
;  ebx  cmdline (kernel address)
-
 
3843
;
-
 
3844
;  ret  eax > 0 - PID, < 0 - error
-
 
3845
;
-
 
3846
;--------------------------------------------------------------
-
 
3847
 
-
 
3848
.flags:
-
 
3849
        cmp     [fat_type], 0
-
 
3850
        jnz     @f
-
 
3851
        mov     eax, ERROR_UNKNOWN_FS
-
 
3852
        ret
-
 
3853
@@:
-
 
3854
        cmp     byte [esi], 0
-
 
3855
        jnz     @f
-
 
3856
; cannot execute root!
-
 
3857
        mov     eax, -ERROR_ACCESS_DENIED
-
 
3858
        ret
-
 
3859
@@:
-
 
3860
        push    edi
-
 
3861
        call    hd_find_lfn
-
 
3862
        jnc     .found
-
 
3863
        pop     edi
-
 
3864
        mov     eax, -ERROR_FILE_NOT_FOUND
-
 
3865
        cmp     [hd_error], 0
-
 
3866
        jz      @f
-
 
3867
        mov     al, -11
-
 
3868
@@:
-
 
3869
        ret
-
 
3870
.found:
-
 
3871
        mov     eax, [edi+20-2]
-
 
3872
        mov     ax, [edi+26]
-
 
3873
        push    0
-
 
3874
        push    eax
-
 
3875
        push    dword [edi+28]          ; size
-
 
3876
        push    .DoRead
-
 
3877
        call    fs_execute
-
 
3878
        add     esp, 16
-
 
3879
        pop     edi
-
 
3880
        ret
-
 
3881
 
-
 
3882
.DoRead:
-
 
3883
; read next block
-
 
3884
; in: eax->parameters, edi->buffer
-
 
3885
; out: eax = error code
-
 
3886
        pushad
-
 
3887
        cmp     dword [eax], 0  ; file size
-
 
3888
        jz      .eof
-
 
3889
        add     eax, 4
-
 
3890
        call    fat_get_sector
-
 
3891
        mov     ebx, edi
-
 
3892
        call    hd_read
-
 
3893
        cmp     [hd_error], 0
-
 
3894
        jnz     .err
-
 
3895
        mov     eax, [esp+28]
-
 
3896
        mov     ecx, [eax]
-
 
3897
        sub     ecx, 512
-
 
3898
        jae     @f
-
 
3899
        lea     edi, [edi+ecx+512]
-
 
3900
        neg     ecx
-
 
3901
        push    eax
-
 
3902
        xor     eax, eax
-
 
3903
        rep     stosb
-
 
3904
        pop     eax
-
 
3905
@@:
-
 
3906
        mov     [eax], ecx
-
 
3907
        mov     edx, [eax+8]
-
 
3908
        inc     edx
-
 
3909
        cmp     edx, [SECTORS_PER_CLUSTER]
-
 
3910
        jb      @f
-
 
3911
        push    eax
-
 
3912
        mov     eax, [eax+4]
-
 
3913
        call    get_FAT
-
 
3914
        cmp     [hd_error], 0
-
 
3915
        jnz     .err
-
 
3916
        mov     ecx, eax
-
 
3917
        pop     eax
-
 
3918
        mov     [eax+4], ecx
-
 
3919
        xor     edx, edx
-
 
3920
@@:
-
 
3921
        mov     [eax+8], edx
-
 
3922
        popad
-
 
3923
        xor     eax, eax
-
 
3924
        ret
-
 
3925
.eof:
-
 
3926
        popad
-
 
3927
        mov     eax, 6
-
 
3928
        ret
-
 
3929
.err:
-
 
3930
        popad
-
 
3931
        mov     eax, 11
-
 
3932
        ret
3803
 
3933