Subversion Repositories Kolibri OS

Rev

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

Rev 593 Rev 709
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2008. 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: 593 $
8
$Revision: 709 $
9
 
9
 
Line 80... Line 80...
80
	db	'cd2',0
80
	db	'cd2',0
81
	dd	fs_HasCd3
81
	dd	fs_HasCd3
82
	db	'cd3',0
82
	db	'cd3',0
83
;**********************************************
83
;**********************************************
84
	dd	0
84
	dd	0
-
 
85
 
-
 
86
fs_additional_handlers:
-
 
87
        dd      biosdisk_handler, biosdisk_enum_root
-
 
88
; add new handlers here
-
 
89
        dd      0
-
 
90
 
85
endg
91
endg
Line 86... Line 92...
86
 
92
 
87
file_system_lfn:
93
file_system_lfn:
88
; in: eax->fileinfo block
94
; in: eax->fileinfo block
Line 139... Line 145...
139
	add	edi, ecx
145
	add	edi, ecx
140
	scasd
146
	scasd
141
	scasd
147
	scasd
142
	mov	cl, byte [edi]
148
	mov	cl, byte [edi]
143
	test	cl, cl
149
	test	cl, cl
144
	jz	.notfound
150
	jz	.notfound_try
145
	inc	edi
151
	inc	edi
146
	push	esi
152
	push	esi
147
@@:
153
@@:
148
	lodsb
154
	lodsb
149
	or	al, 20h
155
	or	al, 20h
Line 156... Line 162...
156
	test	al, al
162
	test	al, al
157
	jnz	.scan1
163
	jnz	.scan1
158
	pop	eax
164
	pop	eax
159
; directory /xxx
165
; directory /xxx
160
.maindir:
166
.maindir:
-
 
167
	mov	esi, [edi+4]
-
 
168
.maindir_noesi:
161
	cmp	dword [ebx], 1
169
	cmp	dword [ebx], 1
162
	jnz	.access_denied
170
	jnz	.access_denied
163
	xor	eax, eax
171
	xor	eax, eax
164
	mov	ebp, [ebx+12]
172
	mov	ebp, [ebx+12]
165
	mov	edx, [ebx+16]
173
	mov	edx, [ebx+16]
166
    ;    add     edx, std_application_base_address
174
    ;    add     edx, std_application_base_address
167
	push	dword [ebx+4]	; first block
175
	push	dword [ebx+4]	; first block
168
	mov	ebx, [ebx+8]	; flags
176
	mov	ebx, [ebx+8]	; flags
169
	mov	esi, [edi+4]
-
 
170
; ebx=flags, [esp]=first block, ebp=number of blocks, edx=return area, esi='Next' handler
177
; ebx=flags, [esp]=first block, ebp=number of blocks, edx=return area, esi='Next' handler
171
	mov	edi, edx
178
	mov	edi, edx
-
 
179
	push    ecx
172
	mov	ecx, 32/4
180
	mov	ecx, 32/4
173
	rep	stosd
181
	rep	stosd
-
 
182
	pop     ecx
174
	mov	byte [edx], 1	; version
183
	mov	byte [edx], 1	; version
175
.maindir_loop:
184
.maindir_loop:
176
	call	esi
185
	call	esi
177
	jc	.maindir_done
186
	jc	.maindir_done
178
	inc	dword [edx+8]
187
	inc	dword [edx+8]
Line 184... Line 193...
184
	mov	dword [edi], 0x10	; attributes: folder
193
	mov	dword [edi], 0x10	; attributes: folder
185
	mov	dword [edi+4], 1	; name type: UNICODE
194
	mov	dword [edi+4], 1	; name type: UNICODE
186
	push	eax
195
	push	eax
187
	xor	eax, eax
196
	xor	eax, eax
188
	add	edi, 8
197
	add	edi, 8
-
 
198
	push    ecx
189
	mov	ecx, 40/4-2
199
	mov	ecx, 40/4-2
190
	rep	stosd
200
	rep	stosd
-
 
201
	pop     ecx
191
	pop	eax
202
	pop	eax
192
	push	eax edx
203
	push	eax edx
193
; convert number in eax to decimal UNICODE string
204
; convert number in eax to decimal UNICODE string
194
	push	edi
205
	push	edi
-
 
206
	push    ecx
195
	push	-'0'
207
	push	-'0'
196
	mov	cl, 10
208
	mov	ecx, 10
197
@@:
209
@@:
198
	xor	edx, edx
210
	xor	edx, edx
199
	div	ecx
211
	div	ecx
200
	push	edx
212
	push	edx
201
	test	eax, eax
213
	test	eax, eax
Line 210... Line 222...
210
	inc	edi
222
	inc	edi
211
.ansi2:
223
.ansi2:
212
	test	al, al
224
	test	al, al
213
	jnz	@b
225
	jnz	@b
214
	mov	byte [edi-1], 0
226
	mov	byte [edi-1], 0
-
 
227
	pop     ecx
215
	pop	edi
228
	pop	edi
216
; UNICODE name length is 520 bytes, ANSI - 264
229
; UNICODE name length is 520 bytes, ANSI - 264
217
	add	edi, 520
230
	add	edi, 520
218
	test	bl, 1
231
	test	bl, 1
219
	jnz	@f
232
	jnz	@f
Line 254... Line 267...
254
	mov	ecx, 32/4
267
	mov	ecx, 32/4
255
	rep	stosd
268
	rep	stosd
256
	mov	byte [edx], 1	; version
269
	mov	byte [edx], 1	; version
257
.readroot_loop:
270
.readroot_loop:
258
	cmp	dword [esi], eax
271
	cmp	dword [esi], eax
259
	jz	.readroot_done
272
	jz	.readroot_done_static
260
	call	dword [esi]
273
	call	dword [esi]
261
	add	esi, 4
274
	add	esi, 4
262
	test	eax, eax
275
	test	eax, eax
263
	jnz	@f
276
	jnz	@f
264
.readroot_next:
277
.readroot_next:
Line 274... Line 287...
274
	jns	.readroot_next
287
	jns	.readroot_next
275
	dec	ebp
288
	dec	ebp
276
	js	.readroot_next
289
	js	.readroot_next
277
	inc	dword [edx+4]
290
	inc	dword [edx+4]
278
	mov	dword [edi], 0x10	; attributes: folder
291
	mov	dword [edi], 0x10	; attributes: folder
279
	mov	dword [edi+4], 1	; name type: UNICODE
292
	mov	dword [edi+4], ebx	; name type: UNICODE
280
	add	edi, 8
293
	add	edi, 8
281
	mov	ecx, 40/4-2
294
	mov	ecx, 40/4-2
282
	rep	stosd
295
	rep	stosd
283
	push	edi
296
	push	edi
284
@@:
297
@@:
Line 295... Line 308...
295
	add	edi, 520
308
	add	edi, 520
296
	test	bl, 1
309
	test	bl, 1
297
	jnz	.readroot_loop
310
	jnz	.readroot_loop
298
	sub	edi, 520-264
311
	sub	edi, 520-264
299
	jmp	.readroot_loop
312
	jmp	.readroot_loop
-
 
313
.readroot_done_static:
-
 
314
        mov     esi, fs_additional_handlers-8
-
 
315
        sub     esp, 16
-
 
316
.readroot_ah_loop:
-
 
317
        add     esi, 8
-
 
318
        cmp     dword [esi], 0
-
 
319
        jz      .readroot_done
-
 
320
        xor     eax, eax
-
 
321
.readroot_ah_loop2:
-
 
322
        push    edi
-
 
323
        lea     edi, [esp+4]
-
 
324
        call    dword [esi+4]
-
 
325
        pop     edi
-
 
326
        test    eax, eax
-
 
327
        jz      .readroot_ah_loop
-
 
328
        inc     dword [edx+8]
-
 
329
        dec     dword [esp+16]
-
 
330
        jns     .readroot_ah_loop2
-
 
331
        dec     ebp
-
 
332
        js      .readroot_ah_loop2
-
 
333
        push    eax
-
 
334
        xor     eax, eax
-
 
335
        inc     dword [edx+4]
-
 
336
        mov     dword [edi], 0x10       ; attributes: folder
-
 
337
        mov     dword [edi+4], ebx
-
 
338
        add     edi, 8
-
 
339
        mov     ecx, 40/4-2
-
 
340
        rep     stosd
-
 
341
        push    esi edi
-
 
342
        lea     esi, [esp+12]
-
 
343
@@:
-
 
344
        lodsb
-
 
345
        stosb
-
 
346
        test    bl, 1
-
 
347
        jz      .ansi3
-
 
348
        mov     byte [edi], 0
-
 
349
        inc     edi
-
 
350
.ansi3:
-
 
351
        test    al, al
-
 
352
        jnz     @b
-
 
353
        pop     edi esi eax
-
 
354
        add     edi, 520
-
 
355
        test    bl, 1
-
 
356
        jnz     .readroot_ah_loop2
-
 
357
        sub     edi, 520-264
-
 
358
        jmp     .readroot_ah_loop2
300
.readroot_done:
359
.readroot_done:
-
 
360
        add     esp, 16
301
	pop	eax
361
	pop	eax
302
	mov	ebx, [edx+4]
362
	mov	ebx, [edx+4]
303
	xor	eax, eax
363
	xor	eax, eax
304
	dec	ebp
364
	dec	ebp
305
	js	@f
365
	js	@f
306
	mov	al, ERROR_END_OF_FILE
366
	mov	al, ERROR_END_OF_FILE
307
@@:
367
@@:
308
	mov	[image_of_eax], eax
368
	mov	[image_of_eax], eax
309
	mov	[image_of_ebx], ebx
369
	mov	[image_of_ebx], ebx
310
	ret
370
	ret
-
 
371
.notfound_try:
-
 
372
        mov     edi, fs_additional_handlers
-
 
373
@@:
-
 
374
        cmp     dword [edi], 0
-
 
375
        jz      @f
-
 
376
        call    dword [edi]
-
 
377
        scasd
-
 
378
        scasd
-
 
379
        jmp     @b
311
.notfound:
380
.notfound:
312
	mov	dword [image_of_eax], ERROR_FILE_NOT_FOUND
381
	mov	dword [image_of_eax], ERROR_FILE_NOT_FOUND
313
	and	dword [image_of_ebx], 0
382
	and	dword [image_of_ebx], 0
314
	ret
383
	ret
Line -... Line 384...
-
 
384
 
-
 
385
.notfounda:
-
 
386
        cmp     edi, esp
-
 
387
        jnz     .notfound
-
 
388
        add     esp, 8
-
 
389
        jmp     .notfound
315
 
390
 
316
.found1:
391
.found1:
317
	pop	eax
392
	pop	eax
318
	cmp	byte [esi], 0
393
	cmp	byte [esi], 0
-
 
394
	jz	.maindir
319
	jz	.maindir
395
.found2:
320
; read partition number
396
; read partition number
321
	xor	ecx, ecx
397
	xor	ecx, ecx
322
	xor	eax, eax
398
	xor	eax, eax
323
@@:
399
@@:
Line 326... Line 402...
326
	jz	.done1
402
	jz	.done1
327
	test	al, al
403
	test	al, al
328
	jz	.done1
404
	jz	.done1
329
	sub	al, '0'
405
	sub	al, '0'
330
	cmp	al, 9
406
	cmp	al, 9
331
	ja	.notfound
407
	ja	.notfounda
332
	lea	ecx, [ecx*5]
408
	lea	ecx, [ecx*5]
333
	lea	ecx, [ecx*2+eax]
409
	lea	ecx, [ecx*2+eax]
334
	jmp	@b
410
	jmp	@b
335
.done1:
411
.done1:
336
	jecxz	.notfound
412
	jecxz	.notfounda
337
	test	al, al
413
	test	al, al
338
	jnz	@f
414
	jnz	@f
339
	dec	esi
415
	dec	esi
340
@@:
416
@@:
341
	cmp	byte [esi], 0
417
	cmp	byte [esi], 0
Line 449... Line 525...
449
fs_OnHd:
525
fs_OnHd:
450
	call	reserve_hd_channel
526
	call	reserve_hd_channel
451
	pop	eax
527
	pop	eax
452
	mov	[hdpos], eax
528
	mov	[hdpos], eax
453
	cmp	ecx, 0x100
529
	cmp	ecx, 0x100
454
	jae	.nf
530
	jae	fs_OnHdAndBd.nf
455
	cmp	cl, [DRIVE_DATA+1+eax]
531
	cmp	cl, [DRIVE_DATA+1+eax]
-
 
532
fs_OnHdAndBd:
456
	jbe	@f
533
	jbe	@f
457
.nf:
534
.nf:
458
	call	free_hd_channel
535
	call	free_hd_channel
459
	and	[hd1_status], 0
536
	and	[hd1_status], 0
460
	mov	dword [image_of_eax], 5       ; not found
537
	mov	dword [image_of_eax], 5       ; not found
Line 706... Line 783...
706
	clc
783
	clc
707
@@:
784
@@:
708
	ret
785
	ret
709
;*******************************************************
786
;*******************************************************
Line -... Line 787...
-
 
787
 
-
 
788
; Additional FS handlers.
-
 
789
; This handler gets the control each time when fn 70 is called
-
 
790
; with unknown item of root subdirectory.
-
 
791
; in: esi -> name
-
 
792
;     ebp = 0 or rest of name relative to esi
-
 
793
; out: if the handler processes path, he must not return in file_system_lfn,
-
 
794
;      but instead pop return address and return directly to the caller
-
 
795
;      otherwise simply return
-
 
796
 
-
 
797
; here we test for /bd/... - BIOS disks
-
 
798
biosdisk_handler:
-
 
799
        cmp     [NumBiosDisks], 0
-
 
800
        jz      .ret
-
 
801
        mov     al, [esi]
-
 
802
        or      al, 20h
-
 
803
        cmp     al, 'b'
-
 
804
        jnz     .ret
-
 
805
        mov     al, [esi+1]
-
 
806
        or      al, 20h
-
 
807
        cmp     al, 'd'
-
 
808
        jnz     .ret
-
 
809
        push    esi
-
 
810
        inc     esi
-
 
811
        inc     esi
-
 
812
        cmp     byte [esi], '0'
-
 
813
        jb      .ret2
-
 
814
        cmp     byte [esi], '9'
-
 
815
        ja      .ret2
-
 
816
        xor     edx, edx
-
 
817
@@:
-
 
818
        lodsb
-
 
819
        test    al, al
-
 
820
        jz      .ok
-
 
821
        cmp     al, '/'
-
 
822
        jz      .ok
-
 
823
        sub     al, '0'
-
 
824
        cmp     al, 9
-
 
825
        ja      .ret2
-
 
826
        lea     edx, [edx*5]
-
 
827
        lea     edx, [edx*2+eax]
-
 
828
        jmp     @b
-
 
829
.ret2:
-
 
830
        pop     esi
-
 
831
.ret:
-
 
832
        ret
-
 
833
.ok:
-
 
834
        cmp     al, '/'
-
 
835
        jz      @f
-
 
836
        dec     esi
-
 
837
@@:
-
 
838
        add     dl, 80h
-
 
839
        xor     ecx, ecx
-
 
840
@@:
-
 
841
        cmp     dl, [BiosDisksData+ecx*4]
-
 
842
        jz      .ok2
-
 
843
        inc     ecx
-
 
844
        cmp     ecx, [NumBiosDisks]
-
 
845
        jb      @b
-
 
846
        jmp     .ret2
-
 
847
.ok2:
-
 
848
        add     esp, 8
-
 
849
        test    al, al
-
 
850
        jnz     @f
-
 
851
        mov     esi, fs_BdNext
-
 
852
        jmp     file_system_lfn.maindir_noesi
-
 
853
@@:
-
 
854
        push    ecx
-
 
855
        push    fs_OnBd
-
 
856
        mov     edi, esp
-
 
857
        jmp     file_system_lfn.found2
-
 
858
 
-
 
859
fs_BdNext:
-
 
860
        cmp     eax, [BiosDiskPartitions+ecx*4]
-
 
861
	inc	eax
-
 
862
	cmc
-
 
863
	ret
-
 
864
 
-
 
865
fs_OnBd:
-
 
866
        pop     edx edx
-
 
867
; edx = disk number, ecx = partition number
-
 
868
; esi+ebp = name
-
 
869
	call	reserve_hd1
-
 
870
	add     edx, 0x80
-
 
871
	mov     [hdpos], edx
-
 
872
	cmp     ecx, [BiosDiskPartitions+(edx-0x80)*4]
-
 
873
	jmp     fs_OnHdAndBd
-
 
874
 
-
 
875
; This handler is called when virtual root is enumerated
-
 
876
; and must return all items which can be handled by this.
-
 
877
; It is called several times, first time with eax=0
-
 
878
; in: eax = 0 for first call, previously returned value for subsequent calls
-
 
879
; out: eax = 0 => no more items
-
 
880
;      eax != 0 => buffer pointed to by edi contains name of item
-
 
881
 
-
 
882
; here we enumerate existing BIOS disks /bd
-
 
883
biosdisk_enum_root:
-
 
884
        cmp     eax, [NumBiosDisks]
-
 
885
        jae     .end
-
 
886
        push    eax
-
 
887
        movzx   eax, byte [BiosDisksData+eax*4]
-
 
888
        sub     al, 80h
-
 
889
        push    eax
-
 
890
        mov     al, 'b'
-
 
891
        stosb
-
 
892
        mov     al, 'd'
-
 
893
        stosb
-
 
894
        pop     eax
-
 
895
        cmp     al, 10
-
 
896
        jae     .big
-
 
897
        add     al, '0'
-
 
898
        stosb
-
 
899
        mov     byte [edi], 0
-
 
900
        pop     eax
-
 
901
        inc     eax
-
 
902
        ret
-
 
903
.end:
-
 
904
        xor     eax, eax
-
 
905
        ret
-
 
906
.big:
-
 
907
        push    ecx
-
 
908
        push    -'0'
-
 
909
        mov     ecx, 10
-
 
910
@@:
-
 
911
        xor     edx, edx
-
 
912
        div     ecx
-
 
913
        push    edx
-
 
914
        test    eax, eax
-
 
915
        jnz     @b
-
 
916
        xchg    eax, edx
-
 
917
@@:
-
 
918
        pop     eax
-
 
919
        add     al, '0'
-
 
920
        stosb
-
 
921
        jnz     @b
-
 
922
        pop     ecx
-
 
923
        pop     eax
-
 
924
        inc     eax
-
 
925
        ret
710
 
926
 
711
process_replace_file_name:
927
process_replace_file_name:
712
	mov	ebp, [full_file_name_table]
928
	mov	ebp, [full_file_name_table]
713
	mov	edi, [full_file_name_table.size]
929
	mov	edi, [full_file_name_table.size]
714
	dec	edi
930
	dec	edi