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 807... Line 807...
807
        popa
807
        popa
808
        stc
808
        stc
809
        ret
809
        ret
Line 810... Line 810...
810
 
810
 
811
fd_find_lfn:
811
fd_find_lfn:
812
; in: esi->name
812
; in: esi+ebp -> name
813
; out: CF=1 - file not found
813
; out: CF=1 - file not found
814
;      else CF=0 and edi->direntry, eax=directory cluster (0 for root)
814
;      else CF=0 and edi->direntry, eax=directory cluster (0 for root)
815
        push    esi edi
815
        push    esi edi
816
        push    0
816
        push    0
Line 819... Line 819...
819
.loop:
819
.loop:
820
        call    fat_find_lfn
820
        call    fat_find_lfn
821
        jc      .notfound
821
        jc      .notfound
822
        cmp     byte [esi], 0
822
        cmp     byte [esi], 0
823
        jz      .found
823
        jz      .found
-
 
824
.continue:
824
        test    byte [edi+11], 10h
825
        test    byte [edi+11], 10h
825
        jz      .notfound
826
        jz      .notfound
826
        movzx   eax, word [edi+26]      ; cluster
827
        movzx   eax, word [edi+26]      ; cluster
827
        mov     [esp+8], eax
828
        mov     [esp+8], eax
828
        mov     dword [esp+4], flp_notroot_first
829
        mov     dword [esp+4], flp_notroot_first
Line 832... Line 833...
832
        add     esp, 12
833
        add     esp, 12
833
        pop     edi esi
834
        pop     edi esi
834
        stc
835
        stc
835
        ret
836
        ret
836
.found:
837
.found:
-
 
838
        test    ebp, ebp
-
 
839
        jz      @f
-
 
840
        mov     esi, ebp
-
 
841
        xor     ebp, ebp
-
 
842
        jmp     .continue
-
 
843
@@:
837
        mov     eax, [esp+8]
844
        mov     eax, [esp+8]
838
        add     eax, 31
845
        add     eax, 31
839
        cmp     dword [esp], flp_root_next
846
        cmp     dword [esp], flp_root_next
840
        jnz     @f
847
        jnz     @f
841
        add     eax, -31+19
848
        add     eax, -31+19
Line 1114... Line 1121...
1114
        jz      @b
1121
        jz      @b
1115
        call    read_flp_fat
1122
        call    read_flp_fat
1116
        cmp     [FDC_Status], 0
1123
        cmp     [FDC_Status], 0
1117
        jnz     fsfrfe
1124
        jnz     fsfrfe
1118
        pushad
1125
        pushad
1119
        xor     ebp, ebp
1126
        xor     edi, edi
1120
        push    esi
1127
        push    esi
-
 
1128
        test    ebp, ebp
-
 
1129
        jz      @f
-
 
1130
        mov     esi, ebp
1121
@@:
1131
@@:
1122
        lodsb
1132
        lodsb
1123
        test    al, al
1133
        test    al, al
1124
        jz      @f
1134
        jz      @f
1125
        cmp     al, '/'
1135
        cmp     al, '/'
1126
        jnz     @b
1136
        jnz     @b
1127
        lea     ebp, [esi-1]
1137
        lea     edi, [esi-1]
1128
        jmp     @b
1138
        jmp     @b
1129
@@:
1139
@@:
1130
        pop     esi
1140
        pop     esi
1131
        test    ebp, ebp
1141
        test    edi, edi
1132
        jnz     .noroot
1142
        jnz     .noroot
-
 
1143
        test    ebp, ebp
-
 
1144
        jnz     .hasebp
1133
        call    read_flp_root
1145
        call    read_flp_root
1134
        cmp     [FDC_Status], 0
1146
        cmp     [FDC_Status], 0
1135
        jnz     fsfrfe2
1147
        jnz     fsfrfe2
1136
        push    flp_rootmem_extend_dir
1148
        push    flp_rootmem_extend_dir
1137
        push    flp_rootmem_end_write
1149
        push    flp_rootmem_end_write
Line 1140... Line 1152...
1140
        xor     ebp, ebp
1152
        xor     ebp, ebp
1141
        push    ebp
1153
        push    ebp
1142
        push    flp_rootmem_first
1154
        push    flp_rootmem_first
1143
        push    flp_rootmem_next
1155
        push    flp_rootmem_next
1144
        jmp     .common1
1156
        jmp     .common1
-
 
1157
.hasebp:
-
 
1158
        mov     eax, ERROR_ACCESS_DENIED
-
 
1159
        cmp     byte [ebp], 0
-
 
1160
        jz      .ret1
-
 
1161
        push    ebp
-
 
1162
        xor     ebp, ebp
-
 
1163
        call    fd_find_lfn
-
 
1164
        pop     esi
-
 
1165
        jc      .notfound0
-
 
1166
        jmp     .common0
1145
.noroot:
1167
.noroot:
1146
        mov     eax, ERROR_ACCESS_DENIED
1168
        mov     eax, ERROR_ACCESS_DENIED
1147
        cmp     byte [ebp+1], 0
1169
        cmp     byte [edi+1], 0
1148
        jz      .ret1
1170
        jz      .ret1
1149
; check existence
1171
; check existence
1150
        mov     byte [ebp], 0
1172
        mov     byte [edi], 0
-
 
1173
        push    edi
1151
        call    fd_find_lfn
1174
        call    fd_find_lfn
1152
        mov     byte [ebp], '/'
1175
        pop     esi
1153
        lea     esi, [ebp+1]
1176
        mov     byte [esi], '/'
1154
        jnc     @f
1177
        jnc     @f
-
 
1178
.notfound0:
1155
        mov     eax, ERROR_FILE_NOT_FOUND
1179
        mov     eax, ERROR_FILE_NOT_FOUND
1156
.ret1:
1180
.ret1:
1157
        mov     [esp+28], eax
1181
        mov     [esp+28], eax
1158
        popad
1182
        popad
1159
        xor     ebx, ebx
1183
        xor     ebx, ebx
1160
        ret
1184
        ret
1161
@@:
1185
@@:
-
 
1186
        inc     esi
-
 
1187
.common0:
1162
        test    byte [edi+11], 0x10     ; must be directory
1188
        test    byte [edi+11], 0x10     ; must be directory
1163
        mov     eax, ERROR_ACCESS_DENIED
1189
        mov     eax, ERROR_ACCESS_DENIED
1164
        jz      .ret1
1190
        jz      .ret1
1165
        movzx   ebp, word [edi+26]      ; ebp=cluster
1191
        movzx   ebp, word [edi+26]      ; ebp=cluster
1166
        mov     eax, ERROR_FAT_TABLE
1192
        mov     eax, ERROR_FAT_TABLE
Line 2107... Line 2133...
2107
        jz      @f
2133
        jz      @f
2108
        mov     al, 11
2134
        mov     al, 11
2109
@@:
2135
@@:
2110
        ret
2136
        ret
Line 2111... Line -...
2111
 
-
 
2112
if 0
-
 
2113
;----------------------------------------------------------------
-
 
2114
;
-
 
2115
;  fs_FloppyExecute - LFN variant for executing from floppy
-
 
2116
;
-
 
2117
;  esi  points to floppy filename (e.g. 'dir1/name')
-
 
2118
;  ebp  points to full filename (e.g. '/fd/1/dir1/name')
-
 
2119
;  dword [ebx] = flags
-
 
2120
;  dword [ebx+4] = cmdline
-
 
2121
;
-
 
2122
;  ret ebx,edx destroyed
-
 
2123
;      eax > 0 - PID, < 0 - error
-
 
2124
;
-
 
2125
;--------------------------------------------------------------
-
 
2126
fs_FloppyExecute:
-
 
2127
        mov     edx, [ebx]
-
 
2128
        mov     ebx, [ebx+4]
-
 
2129
        test    ebx, ebx
-
 
2130
        jz      @f
-
 
2131
    ;    add     ebx, std_application_base_address
-
 
2132
@@:
-
 
2133
 
-
 
2134
;----------------------------------------------------------------
-
 
2135
;
-
 
2136
; fs_FloppyExecute.flags - second entry
-
 
2137
;
-
 
2138
;  esi  points to floppy filename (kernel address)
-
 
2139
;  ebp  points to full filename
-
 
2140
;  edx  flags
-
 
2141
;  ebx  cmdline (kernel address)
-
 
2142
;
-
 
2143
;  ret  eax > 0 - PID, < 0 - error
-
 
2144
;
-
 
2145
;--------------------------------------------------------------
-
 
2146
 
-
 
2147
.flags:
-
 
2148
        call    read_flp_fat
-
 
2149
        cmp     byte [esi], 0
-
 
2150
        jnz     @f
-
 
2151
; cannot execute root!
-
 
2152
        mov     eax, -ERROR_ACCESS_DENIED
-
 
2153
        ret
-
 
2154
@@:
-
 
2155
        push    edi
-
 
2156
        call    fd_find_lfn
-
 
2157
        jnc     .found
-
 
2158
        pop     edi
-
 
2159
        mov     eax, -ERROR_FILE_NOT_FOUND
-
 
2160
        ret
-
 
2161
.found:
-
 
2162
        movzx   eax, word [edi+26]      ; cluster
-
 
2163
        push    eax
-
 
2164
        push    dword [edi+28]          ; size
-
 
2165
        push    .DoRead
-
 
2166
        call    fs_execute
-
 
2167
        add     esp, 12
-
 
2168
        pop     edi
-
 
2169
        ret
-
 
2170
 
-
 
2171
.DoRead:
-
 
2172
; read next block
-
 
2173
; in: eax->parameters, edi->buffer
-
 
2174
; out: eax = error code
-
 
2175
        pushad
-
 
2176
        cmp     dword [eax], 0  ; file size
-
 
2177
        jz      .eof
-
 
2178
        mov     eax, [eax+4]    ; cluster
-
 
2179
        add     eax, 31
-
 
2180
        call    read_chs_sector
-
 
2181
        cmp     [FDC_Status], 0
-
 
2182
        jnz     .err
-
 
2183
        pop     edi
-
 
2184
        mov     esi, FDD_BUFF
-
 
2185
        push    edi
-
 
2186
        mov     ecx, 512/4
-
 
2187
        rep     movsd
-
 
2188
        mov     eax, [esp+28]
-
 
2189
        mov     ecx, [eax]
-
 
2190
        sub     ecx, 512
-
 
2191
        jae     @f
-
 
2192
        add     edi, ecx
-
 
2193
        neg     ecx
-
 
2194
        push    eax
-
 
2195
        xor     eax, eax
-
 
2196
        rep     stosb
-
 
2197
        pop     eax
-
 
2198
@@:
-
 
2199
        mov     [eax], ecx
-
 
2200
        mov     edx, [eax+4]
-
 
2201
        mov     dx, [edx*2+FLOPPY_FAT]
-
 
2202
        mov     [eax+4], dx     ; high word is already zero
-
 
2203
        popad
-
 
2204
        xor     eax, eax
-
 
2205
        ret
-
 
2206
.eof:
-
 
2207
        popad
-
 
2208
        mov     eax, 6
-
 
2209
        ret
-
 
2210
.err:
-
 
2211
        popad
-
 
2212
        mov     eax, 11
-
 
2213
        ret
-
 
2214
end if
-
 
2215
 
2137
 
2216
;----------------------------------------------------------------
2138
;----------------------------------------------------------------
2217
;
2139
;
2218
;  fs_FloppyDelete - delete file or empty folder from floppy
2140
;  fs_FloppyDelete - delete file or empty folder from floppy
2219
;
2141
;