Subversion Repositories Kolibri OS

Rev

Rev 71 | Rev 75 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
72 diamond 1
; System function 70 - files with long names (LFN)
71 diamond 2
; diamond, 2006
3
 
4
iglobal
5
; in this table names must be in lowercase
6
rootdirs:
7
	db	2,'rd'
8
	dd	fs_OnRamdisk
9
	db	7,'ramdisk'
10
	dd	fs_OnRamdisk
11
	db	2,'fd'
12
	dd	fs_OnFloppy
13
	db	10,'floppydisk'
14
	dd	fs_OnFloppy
15
	db	3,'hd0'
16
	dd	fs_OnHd0
17
	db	3,'hd1'
18
	dd	fs_OnHd1
19
	db	3,'hd2'
20
	dd	fs_OnHd2
21
	db	3,'hd3'
22
	dd	fs_OnHd3
23
	db	0
24
endg
25
 
26
file_system_lfn:
27
; in: eax->fileinfo block
28
; operation codes:
72 diamond 29
; 0 : read file
30
; 1 : rewrite file - not implemented yet
31
; 2 : delete file - not implemented yet
32
; 3 : write/append to file - not implemented yet
33
; 4 : create directory - not implemented yet
34
; 5 : rename file/directory - not implemented yet
35
; 6 : get file attributes structure - not implemented yet
36
; 7 : start application - not implemented yet
37
; 8 : find file with mask - not implemented yet
71 diamond 38
 
39
; parse file name
40
	xchg	ebx, eax
41
	lea	esi, [ebx+20]
42
	lodsb
43
	cmp	al, '/'
44
	jz	@f
45
.notfound:
46
	mov	dword [esp+36], 5	; file not found
47
	ret
48
@@:
49
	cmp	byte [esi], 0
50
	jz	.rootdir
51
	mov	edi, rootdirs-4
52
	xor	ecx, ecx
53
	push	esi
54
.scan1:
55
	pop	esi
56
	add	edi, ecx
57
	scasd
58
	mov	cl, byte [edi]
59
	jecxz	.notfound
60
	inc	edi
61
	push	esi
62
@@:
63
	lodsb
64
	or	al, 20h
65
	scasb
66
	loopz	@b
67
	jnz	.scan1
68
	pop	eax
69
	lodsb
70
	cmp	al, '/'
71
	jz	.found1
72
	test	al, al
73
	jnz	.scan1
74
; directory /xxx
75
.maindir:
76
; directory /
77
.rootdir:
78
	mov	dword [esp+36], 10	; access denied
79
	ret
80
 
81
.found1:
82
	cmp	byte [esi], 0
83
	jz	.maindir
84
	mov	ebp, dword [edi]	; handler for this device
85
; read partition number
86
	xor	ecx, ecx
87
	xor	eax, eax
88
@@:
89
	lodsb
90
	cmp	al, '/'
91
	jz	.done1
92
	test	al, al
93
	jz	.done1
94
	sub	al, '0'
95
	cmp	al, 9
96
	ja	.notfound
97
	imul	ecx, 10
98
	add	ecx, eax
99
	jmp	@b
100
.done1:
101
	test	ecx, ecx
102
	jz	.notfound
103
	test	al, al
104
	jnz	@f
105
	dec	esi
106
@@:
107
; now ebp contains handler address, ecx - partition number, esi points to ASCIIZ string - rest of name
108
	jmp	ebp
109
 
110
; handlers for devices
111
; in: ecx = partition number
112
;     esi -> relative (for device) name
113
;     ebx -> fileinfo
114
; out: [esp+36]=image of eax, [esp+24]=image of ebx
115
 
116
fs_OnRamdisk:
117
	cmp	ecx, 1
118
	jnz	file_system_lfn.notfound
119
	movzx	eax, byte [ebx]
120
	test	eax, eax
121
	jnz	.not_impl
122
	mov	ecx, [ebx+12]
123
	mov	edx, [ebx+16]
124
	add	edx, std_application_base_address
125
	add	ebx, 4
126
	call	dword [fs_RamdiskServices + eax*4]
127
	mov	[esp+36], eax
128
	mov	[esp+24], ebx
129
	ret
130
.not_impl:
131
	mov	dword [esp+36], 2	; not implemented
132
	ret
133
 
134
fs_RamdiskServices:
135
	dd	fs_RamdiskRead
136
 
137
fs_OnFloppy:
138
	cmp	ecx, 2
139
	ja	file_system_lfn.notfound
140
	movzx	eax, byte [ebx]
141
	test	eax, eax
142
	jnz	fs_OnRamdisk.not_impl
143
	call	reserve_flp
144
	mov	[flp_number], cl
145
	mov	ecx, [ebx+12]
146
	mov	edx, [ebx+16]
147
	add	edx, std_application_base_address
148
	add	ebx, 4
149
	call	dword [fs_FloppyServices + eax*4]
150
	and	[flp_status], 0
151
	mov	[esp+36], eax
152
	mov	[esp+24], ebx
153
	ret
154
 
155
fs_FloppyServices:
156
	dd	fs_FloppyRead
157
 
158
fs_OnHd0:
159
	call	reserve_hd1
160
	mov	[hdbase], 0x1F0
161
	mov	[hdid], 0
162
	push	1
163
	jmp	fs_OnHd
164
fs_OnHd1:
165
	call	reserve_hd1
166
	mov	[hdbase], 0x1F0
167
	mov	[hdid], 0x10
168
	push	2
169
	jmp	fs_OnHd
170
fs_OnHd2:
171
	call	reserve_hd1
172
	mov	[hdbase], 0x170
173
	mov	[hdid], 0
174
	push	3
175
	jmp	fs_OnHd
176
fs_OnHd3:
177
	call	reserve_hd1
178
	mov	[hdbase], 0x170
179
	mov	[hdid], 0x10
180
	push	4
181
fs_OnHd:
182
	pop	eax
183
	mov	[hdpos], eax
184
	cmp	ecx, [0x40001+eax]
185
	jbe	@f
186
	and	[hd1_status], 0
187
	mov	dword [esp+36], 5	; not found
188
	ret
189
@@:
190
	mov	[fat32part], ecx
191
	push	ebx esi
192
	call	choice_necessity_partition_1
193
	pop	esi ebx
194
	mov	ecx, [ebx+12]
195
	mov	edx, [ebx+16]
196
	add	edx, std_application_base_address
197
	movzx	eax, byte [ebx]
198
	add	ebx, 4
199
	call	dword [fs_HdServices + eax*4]
200
	and	[hd1_status], 0
201
	mov	[esp+36], eax
202
	mov	[esp+24], ebx
203
	ret
204
 
205
fs_HdServices:
206
	dd	fs_HdRead