Subversion Repositories Kolibri OS

Rev

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

Rev 65 Rev 71
Line 6... Line 6...
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
;;                                                                 ;;
10
;;                                                                 ;;
-
 
11
;;  23.04.2006 LFN read - diamond                                  ;;
11
;;  28.01.2006 find all Fat16/32 partition in all input point      ;;
12
;;  28.01.2006 find all Fat16/32 partition in all input point      ;;
12
;;             to MBR, see file part_set.inc - Mario79             ;;
13
;;             to MBR, see file part_set.inc - Mario79             ;;
13
;;  15.01.2005 get file size/attr/date, file_append - ATV          ;;
14
;;  15.01.2005 get file size/attr/date, file_append - ATV          ;;
14
;;  04.12.2004 skip volume label, file delete bug fixed - ATV      ;;
15
;;  04.12.2004 skip volume label, file delete bug fixed - ATV      ;;
15
;;  29.11.2004 get_free_FAT changed, append dir bug fixed - ATV    ;;
16
;;  29.11.2004 get_free_FAT changed, append dir bug fixed - ATV    ;;
Line 2575... Line 2576...
2575
    lea   eax,[eax+edx-12+1]
2576
    lea   eax,[eax+edx-12+1]
2576
    call  file_read
2577
    call  file_read
Line 2577... Line 2578...
2577
 
2578
 
Line -... Line 2579...
-
 
2579
    ret
-
 
2580
 
-
 
2581
; \begin{diamond}
-
 
2582
hd_find_lfn:
-
 
2583
; in: esi->name
-
 
2584
; out: CF=1 - file not found
-
 
2585
;      else CF=0 and edi->direntry
-
 
2586
	pusha
-
 
2587
	sub	esp, 262*2	; allocate space for LFN
-
 
2588
	mov	ebp, esp
-
 
2589
	mov	eax, [ROOT_CLUSTER]	; start from root
-
 
2590
.mainloop:
-
 
2591
.new_cluster:
-
 
2592
	mov	[cluster_tmp], eax
-
 
2593
	mov	[fat16_root], 0
-
 
2594
	cmp	eax, [LAST_CLUSTER]
-
 
2595
	ja	.notfound
-
 
2596
	cmp	eax, 2
-
 
2597
	jae	.data_cluster
-
 
2598
	cmp	[fat_type], 16
-
 
2599
	jnz	.notfound
-
 
2600
	mov	eax, [ROOT_START]
-
 
2601
	mov	ecx, [ROOT_SECTORS]
-
 
2602
	mov	[fat16_root], 1
-
 
2603
	jmp	.new_sector
-
 
2604
.data_cluster:
-
 
2605
	dec	eax
-
 
2606
	dec	eax
-
 
2607
	mov	ecx, [SECTORS_PER_CLUSTER]
-
 
2608
	mul	ecx
-
 
2609
	add	eax, [DATA_START]
-
 
2610
.new_sector:
-
 
2611
	mov	ebx, buffer
-
 
2612
	call	hd_read
-
 
2613
	mov	edi, ebx
-
 
2614
	add	ebx, 512
-
 
2615
	push	eax
-
 
2616
.l1:
-
 
2617
	call	fat_get_name
-
 
2618
	jc	.l2
-
 
2619
	call	fat_compare_name
-
 
2620
	jz	.found
-
 
2621
.l2:
-
 
2622
	add	edi, 0x20
-
 
2623
	cmp	edi, ebx
-
 
2624
	jb	.l1
-
 
2625
	pop	eax
-
 
2626
	inc	eax
-
 
2627
	loop	.new_sector
-
 
2628
	cmp	[fat16_root], 0
-
 
2629
	jnz	.notfound
-
 
2630
	mov	eax, [cluster_tmp]
-
 
2631
	call	get_FAT
-
 
2632
	cmp	eax, 2
-
 
2633
	jb	.notfound
-
 
2634
	cmp	eax, [fatRESERVED]
-
 
2635
	jb	.new_cluster
-
 
2636
.notfound:
-
 
2637
	add	esp, 262*2
-
 
2638
	popa
-
 
2639
	stc
-
 
2640
	ret
-
 
2641
.found:
-
 
2642
	pop	eax
-
 
2643
; if this is LFN entry, advance to true entry
-
 
2644
	cmp	byte [edi+11], 0xF
-
 
2645
	jnz	.entryfound
-
 
2646
	add	edi, 0x20
-
 
2647
	cmp	edi, ebx
-
 
2648
	jb	.entryfound
-
 
2649
	inc	eax
-
 
2650
	dec	ecx
-
 
2651
	jnz	.read_entry
-
 
2652
	cmp	[fat16_root], 0
-
 
2653
	jnz	.notfound
-
 
2654
	mov	eax, [cluster_tmp]
-
 
2655
	call	get_FAT
-
 
2656
	cmp	eax, 2
-
 
2657
	jb	.notfound
-
 
2658
	cmp	eax, [fatRESERVED]
-
 
2659
	jae	.notfound
-
 
2660
	dec	eax
-
 
2661
	dec	eax
-
 
2662
	mul	[SECTORS_PER_CLUSTER]
-
 
2663
	add	eax, [DATA_START]
-
 
2664
.read_entry:
-
 
2665
	mov	ebx, [buffer]
-
 
2666
	call	hd_read
-
 
2667
	mov	edi, ebx
-
 
2668
.entryfound:
-
 
2669
	cmp	byte [esi], 0
-
 
2670
	jz	.done
-
 
2671
	test	byte [edi+11], 10h	; is a directory?
-
 
2672
	jz	.notfound
-
 
2673
	mov	eax, [edi+20-2]
-
 
2674
	mov	ax, [edi+26]
-
 
2675
	jmp	.mainloop
-
 
2676
.done:
-
 
2677
	add	esp, 262*2+4	; CF=0
-
 
2678
	push	edi
-
 
2679
	popad
-
 
2680
	ret
-
 
2681
 
-
 
2682
;----------------------------------------------------------------
-
 
2683
;
-
 
2684
;  fs_HdRead - LFN variant for reading hard disk
-
 
2685
;
-
 
2686
;  esi  points to filename
-
 
2687
;  ebx  pointer to 64-bit number = first wanted byte, 0+
-
 
2688
;       may be ebx=0 - start from first byte
-
 
2689
;  ecx  number of bytes to read, 0+
-
 
2690
;  edx  mem location to return data
-
 
2691
;
-
 
2692
;  ret ebx = size or 0xffffffff file not found
-
 
2693
;      eax = 0 ok read or other = errormsg
-
 
2694
;
-
 
2695
;--------------------------------------------------------------
-
 
2696
fs_HdRead:
-
 
2697
	cmp	[fat_type], 0
-
 
2698
	jnz	@f
-
 
2699
	or	ebx, -1
-
 
2700
	mov	eax, ERROR_UNKNOWN_FS
-
 
2701
	ret
-
 
2702
@@:
-
 
2703
	push	edi
-
 
2704
	cmp	byte [esi], 0
-
 
2705
	jnz	@f
-
 
2706
.noaccess:
-
 
2707
	pop	edi
-
 
2708
	or	ebx, -1
-
 
2709
	mov	eax, ERROR_ACCESS_DENIED
-
 
2710
	ret
-
 
2711
@@:
-
 
2712
	call	hd_find_lfn
-
 
2713
	jnc	.found
-
 
2714
	pop	edi
-
 
2715
	or	ebx, -1
-
 
2716
	mov	eax, ERROR_FILE_NOT_FOUND
-
 
2717
	ret
-
 
2718
.found:
-
 
2719
	test	byte [edi+11], 0x10	; do not allow read directories
-
 
2720
	jnz	.noaccess
-
 
2721
	test	ebx, ebx
-
 
2722
	jz	.l1
-
 
2723
	cmp	dword [ebx+4], 0
-
 
2724
	jz	@f
-
 
2725
	mov	ebx, [edi+28]
-
 
2726
.reteof:
-
 
2727
	mov	eax, 6
-
 
2728
	pop	edi
-
 
2729
	ret
-
 
2730
@@:
-
 
2731
	mov	ebx, [ebx]
-
 
2732
.l1:
-
 
2733
	push	dword [edi+28]		; file size
-
 
2734
	mov	eax, [edi+20-2]
-
 
2735
	mov	ax, [edi+26]
-
 
2736
	push	ecx edx
-
 
2737
	push	dword [edi+28]
-
 
2738
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
-
 
2739
.new_cluster:
-
 
2740
	jecxz	.new_sector
-
 
2741
	test	eax, eax
-
 
2742
	jz	.eof
-
 
2743
	cmp	eax, [fatRESERVED]
-
 
2744
	jae	.eof
-
 
2745
	mov	[cluster_tmp], eax
-
 
2746
	dec	eax
-
 
2747
	dec	eax
-
 
2748
	mov	edi, [SECTORS_PER_CLUSTER]
-
 
2749
	imul	eax, edi
-
 
2750
	add	eax, [DATA_START]
-
 
2751
.new_sector:
-
 
2752
	test	ecx, ecx
-
 
2753
	jz	.done
-
 
2754
	sub	ebx, 512
-
 
2755
	jae	.skip
-
 
2756
	add	ebx, 512
-
 
2757
	jnz	.force_buf
-
 
2758
	cmp	ecx, 512
-
 
2759
	jb	.force_buf
-
 
2760
	cmp	dword [esp], 512
-
 
2761
	jb	.force_buf
-
 
2762
; we may read directly to given buffer
-
 
2763
	push	ebx
-
 
2764
	mov	ebx, edx
-
 
2765
	call	hd_read
-
 
2766
	pop	ebx
-
 
2767
	add	edx, 512
-
 
2768
	sub	ecx, 512
-
 
2769
	sub	dword [esp], 512
-
 
2770
	jmp	.skip
-
 
2771
.force_buf:
-
 
2772
; we must read sector to temporary buffer and then copy it to destination
-
 
2773
	push	eax ebx
-
 
2774
	mov	ebx, buffer
-
 
2775
	call	hd_read
-
 
2776
	mov	eax, ebx
-
 
2777
	pop	ebx
-
 
2778
	add	eax, ebx
-
 
2779
	push	ecx
-
 
2780
	add	ecx, ebx
-
 
2781
	cmp	ecx, 512
-
 
2782
	jbe	@f
-
 
2783
	mov	ecx, 512
-
 
2784
@@:
-
 
2785
	sub	ecx, ebx
-
 
2786
	cmp	ecx, [esp+8]
-
 
2787
	jbe	@f
-
 
2788
	mov	ecx, [esp+8]
-
 
2789
@@:
-
 
2790
	mov	ebx, edx
-
 
2791
	call	memmove
-
 
2792
	add	edx, ecx
-
 
2793
	sub	[esp], ecx
-
 
2794
	sub	[esp+8], ecx
-
 
2795
	pop	ecx
-
 
2796
	pop	eax
-
 
2797
	xor	ebx, ebx
-
 
2798
	cmp	[esp], ebx
-
 
2799
	jnz	.skip
-
 
2800
	jecxz	.done
-
 
2801
	jmp	.eof
-
 
2802
.skip:
-
 
2803
	inc	eax
-
 
2804
	dec	edi
-
 
2805
	jnz	.new_sector
-
 
2806
	mov	eax, [cluster_tmp]
-
 
2807
	call	get_FAT
-
 
2808
	jmp	.new_cluster
-
 
2809
.done:
-
 
2810
	pop	ebx edx ecx ebx edi
-
 
2811
	xor	eax, eax
-
 
2812
	ret
-
 
2813
.eof:
-
 
2814
	pop	ebx edx ecx ebx
2578
    ret
2815
	jmp	.reteof