Subversion Repositories Kolibri OS

Rev

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

Rev 495 Rev 521
Line 1... Line 1...
1
$Revision: 495 $
1
$Revision: 521 $
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;                                                                 ;;
3
;;                                                                 ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.    ;;
4
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved.    ;;
5
;; Distributed under terms of the GNU General Public License       ;;
5
;; Distributed under terms of the GNU General Public License       ;;
6
;;                                                                 ;;
6
;;                                                                 ;;
Line 954... Line 954...
954
    ret
954
    ret
Line 955... Line 955...
955
 
955
 
956
 
956
 
957
; \begin{diamond}
957
; \begin{diamond}
958
hd_find_lfn:
958
hd_find_lfn:
959
; in: esi->name
959
; in: esi+ebp -> name
960
; out: CF=1 - file not found
960
; out: CF=1 - file not found
961
;      else CF=0 and edi->direntry, eax=sector
961
;      else CF=0 and edi->direntry, eax=sector
962
; destroys eax
962
; destroys eax
Line 971... Line 971...
971
.loop:
971
.loop:
972
        call    fat_find_lfn
972
        call    fat_find_lfn
973
        jc      .notfound
973
        jc      .notfound
974
        cmp     byte [esi], 0
974
        cmp     byte [esi], 0
975
        jz      .found
975
        jz      .found
-
 
976
.continue:
976
        test    byte [edi+11], 10h
977
        test    byte [edi+11], 10h
977
        jz      .notfound
978
        jz      .notfound
978
        and     dword [esp+12], 0
979
        and     dword [esp+12], 0
979
        mov     eax, [edi+20-2]
980
        mov     eax, [edi+20-2]
980
        mov     ax, [edi+26]    ; cluster
981
        mov     ax, [edi+26]    ; cluster
Line 987... Line 988...
987
        add     esp, 16
988
        add     esp, 16
988
        pop     edi esi
989
        pop     edi esi
989
        stc
990
        stc
990
        ret
991
        ret
991
.found:
992
.found:
-
 
993
        test    ebp, ebp
-
 
994
        jz      @f
-
 
995
        mov     esi, ebp
-
 
996
        xor     ebp, ebp
-
 
997
        jmp     .continue
-
 
998
@@:
992
        lea     eax, [esp+8]
999
        lea     eax, [esp+8]
993
        cmp     dword [eax], 0
1000
        cmp     dword [eax], 0
994
        jz      .root
1001
        jz      .root
995
        call    fat_get_sector
1002
        call    fat_get_sector
996
        jmp     .cmn
1003
        jmp     .cmn
Line 1571... Line 1578...
1571
        jnz     fshrfs
1578
        jnz     fshrfs
1572
@@:
1579
@@:
1573
        cmp     byte [esi], 0
1580
        cmp     byte [esi], 0
1574
        jz      fshrad
1581
        jz      fshrad
1575
        pushad
1582
        pushad
1576
        xor     ebp, ebp
1583
        xor     edi, edi
1577
        push    esi
1584
        push    esi
-
 
1585
        test    ebp, ebp
-
 
1586
        jz      @f
-
 
1587
        mov     esi, ebp
1578
@@:
1588
@@:
1579
        lodsb
1589
        lodsb
1580
        test    al, al
1590
        test    al, al
1581
        jz      @f
1591
        jz      @f
1582
        cmp     al, '/'
1592
        cmp     al, '/'
1583
        jnz     @b
1593
        jnz     @b
1584
        lea     ebp, [esi-1]
1594
        lea     edi, [esi-1]
1585
        jmp     @b
1595
        jmp     @b
1586
@@:
1596
@@:
1587
        pop     esi
1597
        pop     esi
1588
        test    ebp, ebp
1598
        test    edi, edi
1589
        jnz     .noroot
1599
        jnz     .noroot
-
 
1600
        test    ebp, ebp
-
 
1601
        jnz     .hasebp
1590
        mov     ebp, [ROOT_CLUSTER]
1602
        mov     ebp, [ROOT_CLUSTER]
1591
        cmp     [fs_type], 32
1603
        cmp     [fs_type], 32
1592
        jz      .pushnotroot
1604
        jz      .pushnotroot
1593
        push    fat16_root_extend_dir
1605
        push    fat16_root_extend_dir
1594
        push    fat16_root_end_write
1606
        push    fat16_root_end_write
Line 1598... Line 1610...
1598
        push    ebp
1610
        push    ebp
1599
        push    ebp
1611
        push    ebp
1600
        push    fat16_root_first
1612
        push    fat16_root_first
1601
        push    fat16_root_next
1613
        push    fat16_root_next
1602
        jmp     .common1
1614
        jmp     .common1
-
 
1615
.hasebp:
-
 
1616
        mov     eax, ERROR_ACCESS_DENIED
-
 
1617
        cmp     byte [ebp], 0
-
 
1618
        jz      .ret1
-
 
1619
        push    ebp
-
 
1620
        xor     ebp, ebp
-
 
1621
        call    hd_find_lfn
-
 
1622
        pop     esi
-
 
1623
        jc      .notfound0
-
 
1624
        jmp     .common0
1603
.noroot:
1625
.noroot:
1604
        mov     eax, ERROR_ACCESS_DENIED
1626
        mov     eax, ERROR_ACCESS_DENIED
1605
        cmp     byte [ebp+1], 0
1627
        cmp     byte [edi+1], 0
1606
        jz      .ret1
1628
        jz      .ret1
1607
; check existence
1629
; check existence
1608
        mov     byte [ebp], 0
1630
        mov     byte [edi], 0
-
 
1631
        push    edi
1609
        call    hd_find_lfn
1632
        call    hd_find_lfn
1610
        mov     byte [ebp], '/'
1633
        pop     esi
1611
        lea     esi, [ebp+1]
1634
        mov     byte [esi], '/'
1612
        jnc     @f
1635
        jnc     @f
-
 
1636
.notfound0:
1613
        mov     eax, ERROR_FILE_NOT_FOUND
1637
        mov     eax, ERROR_FILE_NOT_FOUND
1614
.ret1:
1638
.ret1:
1615
        mov     [esp+28], eax
1639
        mov     [esp+28], eax
1616
        popad
1640
        popad
1617
        xor     ebx, ebx
1641
        xor     ebx, ebx
1618
        ret
1642
        ret
1619
@@:
1643
@@:
-
 
1644
        inc     esi
-
 
1645
.common0:
1620
        test    byte [edi+11], 0x10     ; must be directory
1646
        test    byte [edi+11], 0x10     ; must be directory
1621
        mov     eax, ERROR_ACCESS_DENIED
1647
        mov     eax, ERROR_ACCESS_DENIED
1622
        jz      .ret1
1648
        jz      .ret1
1623
        mov     ebp, [edi+20-2]
1649
        mov     ebp, [edi+20-2]
1624
        mov     bp, [edi+26]            ; ebp=cluster
1650
        mov     bp, [edi+26]            ; ebp=cluster
Line 2721... Line 2747...
2721
        call    update_disk
2747
        call    update_disk
2722
        pop     edi
2748
        pop     edi
2723
        xor     eax, eax
2749
        xor     eax, eax
2724
        ret
2750
        ret
Line 2725... Line -...
2725
 
-
 
2726
if 0    ; starting from revision 237 execute is implemented in taskman.inc
-
 
2727
        ; through fs_XxxGetFileInfo and fs_XxxRead
-
 
2728
;----------------------------------------------------------------
-
 
2729
;
-
 
2730
;  fs_HdExecute - LFN variant for executing from harddisk
-
 
2731
;
-
 
2732
;  esi  points to hd filename (e.g. 'dir1/name')
-
 
2733
;  ebp  points to full filename (e.g. '/hd0/1/dir1/name')
-
 
2734
;  dword [ebx] = flags
-
 
2735
;  dword [ebx+4] = cmdline
-
 
2736
;
-
 
2737
;  ret ebx,edx destroyed
-
 
2738
;      eax > 0 - PID, < 0 - error
-
 
2739
;
-
 
2740
;--------------------------------------------------------------
-
 
2741
fs_HdExecute:
-
 
2742
        mov     edx, [ebx]
-
 
2743
        mov     ebx, [ebx+4]
-
 
2744
        test    ebx, ebx
-
 
2745
        jz      @f
-
 
2746
   ;     add     ebx, std_application_base_address
-
 
2747
@@:
-
 
2748
 
-
 
2749
;----------------------------------------------------------------
-
 
2750
;
-
 
2751
; fs_HdExecute.flags - second entry
-
 
2752
;
-
 
2753
;  esi  points to floppy filename (kernel address)
-
 
2754
;  ebp  points to full filename
-
 
2755
;  edx  flags
-
 
2756
;  ebx  cmdline (kernel address)
-
 
2757
;
-
 
2758
;  ret  eax > 0 - PID, < 0 - error
-
 
2759
;
-
 
2760
;--------------------------------------------------------------
-
 
2761
 
-
 
2762
.flags:
-
 
2763
        cmp     [fat_type], 0
-
 
2764
        jnz     @f
-
 
2765
        mov     eax, -ERROR_UNKNOWN_FS
-
 
2766
        ret
-
 
2767
@@:
-
 
2768
        cmp     byte [esi], 0
-
 
2769
        jnz     @f
-
 
2770
; cannot execute root!
-
 
2771
        mov     eax, -ERROR_ACCESS_DENIED
-
 
2772
        ret
-
 
2773
@@:
-
 
2774
        push    edi
-
 
2775
        call    hd_find_lfn
-
 
2776
        jnc     .found
-
 
2777
        pop     edi
-
 
2778
        mov     eax, -ERROR_FILE_NOT_FOUND
-
 
2779
        cmp     [hd_error], 0
-
 
2780
        jz      @f
-
 
2781
        mov     al, -11
-
 
2782
@@:
-
 
2783
        ret
-
 
2784
.found:
-
 
2785
        mov     eax, [edi+20-2]
-
 
2786
        mov     ax, [edi+26]
-
 
2787
        push    0
-
 
2788
        push    eax
-
 
2789
        push    dword [edi+28]          ; size
-
 
2790
        push    .DoRead
-
 
2791
        call    fs_execute
-
 
2792
        add     esp, 16
-
 
2793
        pop     edi
-
 
2794
        ret
-
 
2795
 
-
 
2796
.DoRead:
-
 
2797
; read next block
-
 
2798
; in: eax->parameters, edi->buffer
-
 
2799
; out: eax = error code
-
 
2800
        pushad
-
 
2801
        cmp     dword [eax], 0  ; file size
-
 
2802
        jz      .eof
-
 
2803
        add     eax, 4
-
 
2804
        call    fat_get_sector
-
 
2805
        mov     ebx, edi
-
 
2806
        call    hd_read
-
 
2807
        cmp     [hd_error], 0
-
 
2808
        jnz     .err
-
 
2809
        mov     eax, [esp+28]
-
 
2810
        mov     ecx, [eax]
-
 
2811
        sub     ecx, 512
-
 
2812
        jae     @f
-
 
2813
        lea     edi, [edi+ecx+512]
-
 
2814
        neg     ecx
-
 
2815
        push    eax
-
 
2816
        xor     eax, eax
-
 
2817
        rep     stosb
-
 
2818
        pop     eax
-
 
2819
@@:
-
 
2820
        mov     [eax], ecx
-
 
2821
        mov     edx, [eax+8]
-
 
2822
        inc     edx
-
 
2823
        cmp     edx, [SECTORS_PER_CLUSTER]
-
 
2824
        jb      @f
-
 
2825
        push    eax
-
 
2826
        mov     eax, [eax+4]
-
 
2827
        call    get_FAT
-
 
2828
        cmp     [hd_error], 0
-
 
2829
        jnz     .err
-
 
2830
        mov     ecx, eax
-
 
2831
        pop     eax
-
 
2832
        mov     [eax+4], ecx
-
 
2833
        xor     edx, edx
-
 
2834
@@:
-
 
2835
        mov     [eax+8], edx
-
 
2836
        popad
-
 
2837
        xor     eax, eax
-
 
2838
        ret
-
 
2839
.eof:
-
 
2840
        popad
-
 
2841
        mov     eax, 6
-
 
2842
        ret
-
 
2843
.err:
-
 
2844
        popad
-
 
2845
        mov     eax, 11
-
 
2846
        ret
-
 
2847
end if
-
 
2848
 
2751
 
2849
;----------------------------------------------------------------
2752
;----------------------------------------------------------------
2850
;
2753
;
2851
;  fs_HdDelete - delete file or empty folder from hard disk
2754
;  fs_HdDelete - delete file or empty folder from hard disk
2852
;
2755
;