Subversion Repositories Kolibri OS

Rev

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

Rev 837 Rev 846
Line 7... Line 7...
7
;; (C) 2004 Ville Turjanmaa, License: GPL                       ;;
7
;; (C) 2004 Ville Turjanmaa, License: GPL                       ;;
8
;; Addings by M.Lisovin                                         ;;
8
;; Addings by M.Lisovin                                         ;;
9
;; LFN support by diamond                                       ;;
9
;; LFN support by diamond                                       ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 11... Line 11...
11
 
11
 
Line 12... Line 12...
12
$Revision: 766 $
12
$Revision: 846 $
Line 13... Line 13...
13
 
13
 
Line 14... Line 14...
14
 
14
 
Line 15... Line 15...
15
; calculate fat chain
15
; calculate fat chain
16
 
16
 
Line 17... Line 17...
17
calculatefatchain:
17
calculatefatchain:
18
 
18
 
19
   pushad
19
   pushad
Line 54... Line 54...
54
restorefatchain:   ; restore fat chain
54
restorefatchain:   ; restore fat chain
Line 55... Line 55...
55
 
55
 
Line 56... Line 56...
56
   pushad
56
   pushad
57
 
57
 
Line 58... Line 58...
58
   mov	esi,RAMDISK_FAT
58
   mov	esi,RAMDISK_FAT
59
   mov	edi,RAMDISK+512
59
   mov  edi, [_rd_fat]
60
 
60
 
61
  fcnew2:
61
  fcnew2:
Line 70... Line 70...
70
   mov	dword [edi],eax
70
   mov	dword [edi],eax
71
   mov	word [edi+4],bx
71
   mov	word [edi+4],bx
72
   add	edi,6
72
   add	edi,6
73
   add	esi,8
73
   add	esi,8
Line 74... Line 74...
74
 
74
 
75
   cmp	edi,RAMDISK+512+4278	 ;4274 bytes - all used FAT
75
   cmp  edi, [_rd_fat_end]        ;4274 bytes - all used FAT
Line 76... Line 76...
76
   jb	fcnew2
76
   jb	fcnew2
77
 
77
 
78
   mov	esi,RAMDISK+512 	  ; duplicate fat chain
78
   mov  esi,[_rd_fat]             ; duplicate fat chain
79
   mov	edi,RAMDISK+512+0x1200
79
   lea  edi,[esi+0x1200]
80
   mov	ecx,1069	;4274/4
80
   mov	ecx,1069	;4274/4
Line 81... Line 81...
81
   cld
81
   cld
Line 206... Line 206...
206
	jbe    fr_do1
206
	jbe    fr_do1
207
	sub    edx,14
207
	sub    edx,14
208
	sub    ecx,edx
208
	sub    ecx,edx
209
      fr_do1:
209
      fr_do1:
210
	shl    ebx,9
210
	shl    ebx,9
211
	mov    esi,RAMDISK+512*19
211
        mov    esi, [_rd_root]
212
	add    esi,ebx
212
	add    esi,ebx
213
	shl    ecx,7
213
	shl    ecx,7
214
	cld
214
	cld
215
	rep    movsd
215
	rep    movsd
216
	popf
216
	popf
Line 250... Line 250...
250
 
250
 
Line 251... Line 251...
251
      frnew:
251
      frnew:
252
 
252
 
253
	add    eax,31			;bootsector+2*fat+filenames
253
	add    eax,31			;bootsector+2*fat+filenames
254
	shl    eax,9			;*512
254
	shl    eax,9			;*512
255
	add    eax,RAMDISK	       ;image base
255
        add    eax, [_rd_base]          ;image base
Line 256... Line 256...
256
	mov    ebx,[esp+8]
256
	mov    ebx,[esp+8]
257
	mov    ecx,512			;[esp+4]
257
	mov    ecx,512			;[esp+4]
Line 302... Line 302...
302
 
302
 
303
   rd_findfile:
303
   rd_findfile:
304
   ;by Mihasik
304
   ;by Mihasik
Line 305... Line 305...
305
   ;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx
305
   ;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx
306
 
306
 
307
	mov    edi,RAMDISK+512*18+512  ;Point at directory
307
        mov    edi, [_rd_root]      ;Point at directory
308
	cld
308
	cld
309
    rd_newsearch:
309
    rd_newsearch:
310
	mov    esi,eax
310
	mov    esi,eax
311
	mov    ecx,11
311
	mov    ecx,11
312
	rep    cmpsb
312
	rep    cmpsb
313
	je     rd_ff
313
	je     rd_ff
314
	add    cl,21
314
	add    cl,21
315
	add    edi,ecx
315
	add    edi,ecx
316
	cmp    edi,RAMDISK+512*33
316
        cmp    edi, [_rd_root_end]
317
	jb     rd_newsearch
317
	jb     rd_newsearch
318
	mov    eax,5	  ;if file not found - eax=5
318
	mov    eax,5	  ;if file not found - eax=5
319
	xor    ebx,ebx
319
	xor    ebx,ebx
Line 748... Line 748...
748
	call	bdfe_to_fat_date
748
	call	bdfe_to_fat_date
749
	mov	[edi+24], ax		; last write date
749
	mov	[edi+24], ax		; last write date
750
	ret
750
	ret
Line 751... Line 751...
751
 
751
 
752
ramdisk_root_first:
752
ramdisk_root_first:
753
	mov	edi, RAMDISK+512*19
753
        mov     edi, [_rd_root]
754
	clc
754
	clc
755
	ret
755
	ret
756
ramdisk_root_next:
756
ramdisk_root_next:
757
	add	edi, 0x20
757
	add	edi, 0x20
758
	cmp	edi, RAMDISK+512*33
758
        cmp     edi, [_rd_root_end]
759
	cmc
759
	cmc
Line 760... Line 760...
760
	ret
760
	ret
761
 
761
 
Line 791... Line 791...
791
	cmp	eax, 2
791
	cmp	eax, 2
792
	jb	.err
792
	jb	.err
793
	cmp	eax, 2849
793
	cmp	eax, 2849
794
	jae	.err
794
	jae	.err
795
	shl	eax, 9
795
	shl	eax, 9
796
	lea	edi, [eax+(31 shl 9)+RAMDISK]
796
        lea     edi, [eax+(31 shl 9)]
-
 
797
        add     edi, [_rd_base]
797
	clc
798
	clc
798
	ret
799
	ret
799
.err2:
800
.err2:
800
	pop	ecx
801
	pop	ecx
801
.err:
802
.err:
Line 821... Line 822...
821
	mov	eax, [esp+28]
822
	mov	eax, [esp+28]
822
	mov	ecx, [eax]
823
	mov	ecx, [eax]
823
	mov	[RAMDISK_FAT+ecx*2], di
824
	mov	[RAMDISK_FAT+ecx*2], di
824
	mov	[eax], edi
825
	mov	[eax], edi
825
	shl	edi, 9
826
	shl	edi, 9
826
	add	edi, (31 shl 9)+RAMDISK
827
        add     edi, (31 shl 9)
-
 
828
        add     edi, [_rd_base]
827
	mov	[esp], edi
829
	mov	[esp], edi
828
	xor	eax, eax
830
	xor	eax, eax
829
	mov	ecx, 128
831
	mov	ecx, 128
830
	rep	stosd
832
	rep	stosd
831
	popa
833
	popa
Line 932... Line 934...
932
	jz	.eof
934
	jz	.eof
933
	cmp	edi, 0xFF8
935
	cmp	edi, 0xFF8
934
	jae	.eof
936
	jae	.eof
935
	lea	eax, [edi+31]		; bootsector+2*fat+filenames
937
	lea	eax, [edi+31]		; bootsector+2*fat+filenames
936
	shl	eax, 9			; *512
938
	shl	eax, 9			; *512
937
	add	eax, RAMDISK	       ; image base
939
        add     eax, [_rd_base]         ; image base
938
; now eax points to data of cluster
940
; now eax points to data of cluster
939
	sub	ebx, 512
941
	sub	ebx, 512
940
	jae	.skip
942
	jae	.skip
941
	lea	eax, [eax+ebx+512]
943
	lea	eax, [eax+ebx+512]
942
	neg	ebx
944
	neg	ebx
Line 1021... Line 1023...
1021
	pop	ecx eax
1023
	pop	ecx eax
1022
	mov	esi, edi	; esi points to block of data of folder entry (BDFE)
1024
	mov	esi, edi	; esi points to block of data of folder entry (BDFE)
1023
.main_loop:
1025
.main_loop:
1024
	mov	edi, eax
1026
	mov	edi, eax
1025
	shl	edi, 9
1027
	shl	edi, 9
1026
	add	edi, RAMDISK
1028
        add     edi, [_rd_base]
1027
	push	eax
1029
	push	eax
1028
.l1:
1030
.l1:
1029
	call	fat_get_name
1031
	call	fat_get_name
1030
	jc	.l2
1032
	jc	.l2
1031
	cmp	byte [edi+11], 0xF
1033
	cmp	byte [edi+11], 0xF
Line 1046... Line 1048...
1046
	add	eax, 31
1048
	add	eax, 31
1047
	mov	byte [esp+262*2+16], 0
1049
	mov	byte [esp+262*2+16], 0
1048
@@:
1050
@@:
1049
	mov	edi, eax
1051
	mov	edi, eax
1050
	shl	edi, 9
1052
	shl	edi, 9
1051
	add	edi, RAMDISK
1053
        add     edi, [_rd_base]
1052
	push	eax
1054
	push	eax
1053
.do_bdfe:
1055
.do_bdfe:
1054
	inc	dword [edx+8]	; new file found
1056
	inc	dword [edx+8]	; new file found
1055
	dec	ebx
1057
	dec	ebx
1056
	jns	.l2
1058
	jns	.l2
Line 1692... Line 1694...
1692
	inc	ecx
1694
	inc	ecx
1693
; write data
1695
; write data
1694
	cmp	byte [esp+16+20+28], 0
1696
	cmp	byte [esp+16+20+28], 0
1695
	jnz	.writedir
1697
	jnz	.writedir
1696
	shl	eax, 9
1698
	shl	eax, 9
1697
	add	eax, RAMDISK+31*512
1699
        add     eax, 31*512
-
 
1700
        add     eax, [_rd_base]
1698
.writefile:
1701
.writefile:
1699
	mov	ebx, edx
1702
	mov	ebx, edx
1700
	xchg	eax, ebx
1703
	xchg	eax, ebx
1701
	push	ecx
1704
	push	ecx
1702
	mov	ecx, 512
1705
	mov	ecx, 512
Line 1731... Line 1734...
1731
	pop	eax
1734
	pop	eax
1732
	ret
1735
	ret
1733
.writedir:
1736
.writedir:
1734
	mov	edi, eax
1737
	mov	edi, eax
1735
	shl	edi, 9
1738
	shl	edi, 9
-
 
1739
        add     edi, [_rd_base]
1736
	add	edi, RAMDISK+31*512
1740
        add     edi, 31*512
1737
	mov	esi, edx
1741
	mov	esi, edx
1738
	mov	ecx, 32/4
1742
	mov	ecx, 32/4
1739
	push	ecx
1743
	push	ecx
1740
	rep	movsd
1744
	rep	movsd
1741
	mov	dword [edi-32], '.   '
1745
	mov	dword [edi-32], '.   '
Line 1880... Line 1884...
1880
	jbe	@f
1884
	jbe	@f
1881
	mov	ecx, ebx
1885
	mov	ecx, ebx
1882
@@:
1886
@@:
1883
	mov	eax, edi
1887
	mov	eax, edi
1884
	shl	eax, 9
1888
	shl	eax, 9
-
 
1889
        add     eax, [_rd_base]
1885
	add	eax, RAMDISK+31*512+0x200
1890
        add     eax, 31*512+0x200
1886
	sub	eax, ebx
1891
	sub	eax, ebx
1887
	mov	ebx, eax
1892
	mov	ebx, eax
1888
	mov	eax, edx
1893
	mov	eax, edx
1889
	call	memmove
1894
	call	memmove
1890
	xor	ebx, ebx
1895
	xor	ebx, ebx
Line 1934... Line 1939...
1934
; set length to full number of sectors and make sure that last sector is zero-padded
1939
; set length to full number of sectors and make sure that last sector is zero-padded
1935
	sub	[edi+28], ecx
1940
	sub	[edi+28], ecx
1936
	push	eax edi
1941
	push	eax edi
1937
	mov	edi, eax
1942
	mov	edi, eax
1938
	shl	edi, 9
1943
	shl	edi, 9
-
 
1944
        add edi, [_rd_base]
1939
	lea	edi, [edi+RAMDISK+31*512+0x200+ecx]
1945
        lea     edi, [edi+31*512+0x200+ecx]
1940
	neg	ecx
1946
	neg	ecx
1941
	xor	eax, eax
1947
	xor	eax, eax
1942
	rep	stosb
1948
	rep	stosb
1943
	pop	edi eax
1949
	pop	edi eax
1944
.start_extend:
1950
.start_extend:
Line 1976... Line 1982...
1976
	push	eax
1982
	push	eax
1977
	mov	[eax+26], di
1983
	mov	[eax+26], di
1978
@@:
1984
@@:
1979
	push	edi
1985
	push	edi
1980
	shl	edi, 9
1986
	shl	edi, 9
-
 
1987
        add edi, [_rd_base]
1981
	add	edi, RAMDISK+31*512
1988
        add     edi, 31*512
1982
	xor	eax, eax
1989
	xor	eax, eax
1983
	mov	ecx, 512/4
1990
	mov	ecx, 512/4
1984
	rep	stosd
1991
	rep	stosd
1985
	pop	eax	; eax=new cluster
1992
	pop	eax	; eax=new cluster
1986
	pop	edi	; edi->direntry
1993
	pop	edi	; edi->direntry
Line 2080... Line 2087...
2080
@@:
2087
@@:
2081
; zero data at the end of last sector
2088
; zero data at the end of last sector
2082
	push	ecx
2089
	push	ecx
2083
	mov	edi, ecx
2090
	mov	edi, ecx
2084
	shl	edi, 9
2091
	shl	edi, 9
-
 
2092
        add edi, [_rd_base]
2085
	lea	edi, [edi+RAMDISK+31*512+eax+0x200]
2093
        lea     edi, [edi+31*512+eax+0x200]
2086
	mov	ecx, eax
2094
	mov	ecx, eax
2087
	neg	ecx
2095
	neg	ecx
2088
	xor	eax, eax
2096
	xor	eax, eax
2089
	rep	stosb
2097
	rep	stosb
2090
	pop	ecx
2098
	pop	ecx
Line 2193... Line 2201...
2193
; we can delete only empty folders!
2201
; we can delete only empty folders!
2194
	movzx	eax, word [edi+26]
2202
	movzx	eax, word [edi+26]
2195
	push	ebx
2203
	push	ebx
2196
	mov	ebx, eax
2204
	mov	ebx, eax
2197
	shl	ebx, 9
2205
	shl	ebx, 9
-
 
2206
        add ebx, [_rd_base]
2198
	add	ebx, RAMDISK + 31*0x200 + 2*0x20
2207
        add     ebx, 31*0x200 + 2*0x20
2199
.checkempty:
2208
.checkempty:
2200
	cmp	byte [ebx], 0
2209
	cmp	byte [ebx], 0
2201
	jz	.empty
2210
	jz	.empty
2202
	cmp	byte [ebx], 0xE5
2211
	cmp	byte [ebx], 0xE5
2203
	jnz	.notempty
2212
	jnz	.notempty
Line 2207... Line 2216...
2207
	movzx	eax, word [RAMDISK_FAT + eax*2]
2216
	movzx	eax, word [RAMDISK_FAT + eax*2]
2208
	test	eax, eax
2217
	test	eax, eax
2209
	jz	.empty
2218
	jz	.empty
2210
	mov	ebx, eax
2219
	mov	ebx, eax
2211
	shl	ebx, 9
2220
	shl	ebx, 9
-
 
2221
        add ebx, [_rd_base]
2212
	add	ebx, RAMDISK + 31*0x200
2222
        add     ebx, 31*0x200
2213
	jmp	.checkempty
2223
	jmp	.checkempty
2214
.notempty:
2224
.notempty:
2215
	pop	ebx
2225
	pop	ebx
2216
.access_denied2:
2226
.access_denied2:
2217
	pop	edi
2227
	pop	edi
Line 2233... Line 2243...
2233
	mov	edi, [rd_prev_sector]
2243
	mov	edi, [rd_prev_sector]
2234
	push	[rd_prev_prev_sector]
2244
	push	[rd_prev_prev_sector]
2235
	pop	[rd_prev_sector]
2245
	pop	[rd_prev_sector]
2236
	or	[rd_prev_prev_sector], -1
2246
	or	[rd_prev_prev_sector], -1
2237
	shl	edi, 9
2247
	shl	edi, 9
-
 
2248
        add edi, [_rd_base]
2238
	add	edi, RAMDISK + 31*0x200 + 0x200
2249
        add     edi, 31*0x200 + 0x200
2239
@@:
2250
@@:
2240
	sub	edi, 0x20
2251
	sub	edi, 0x20
2241
	cmp	byte [edi], 0xE5
2252
	cmp	byte [edi], 0xE5
2242
	jz	.lfndone
2253
	jz	.lfndone
2243
	cmp	byte [edi+11], 0xF
2254
	cmp	byte [edi+11], 0xF