Rev 466 | Rev 527 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 466 | Rev 521 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | $Revision: 466 $ |
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 993... | Line 993... | ||
993 | popa |
993 | popa |
994 | stc |
994 | stc |
995 | ret |
995 | ret |
Line 996... | Line 996... | ||
996 | 996 | ||
997 | rd_find_lfn: |
997 | rd_find_lfn: |
998 | ; in: esi->name |
998 | ; in: esi+ebp -> name |
999 | ; out: CF=1 - file not found |
999 | ; out: CF=1 - file not found |
1000 | ; else CF=0 and edi->direntry |
1000 | ; else CF=0 and edi->direntry |
1001 | push esi edi |
1001 | push esi edi |
1002 | push 0 |
1002 | push 0 |
Line 1005... | Line 1005... | ||
1005 | .loop: |
1005 | .loop: |
1006 | call fat_find_lfn |
1006 | call fat_find_lfn |
1007 | jc .notfound |
1007 | jc .notfound |
1008 | cmp byte [esi], 0 |
1008 | cmp byte [esi], 0 |
1009 | jz .found |
1009 | jz .found |
- | 1010 | .continue: |
|
1010 | test byte [edi+11], 10h |
1011 | test byte [edi+11], 10h |
1011 | jz .notfound |
1012 | jz .notfound |
1012 | movzx eax, word [edi+26] |
1013 | movzx eax, word [edi+26] |
1013 | mov [esp+8], eax |
1014 | mov [esp+8], eax |
1014 | mov dword [esp+4], ramdisk_notroot_first |
1015 | mov dword [esp+4], ramdisk_notroot_first |
Line 1018... | Line 1019... | ||
1018 | add esp, 12 |
1019 | add esp, 12 |
1019 | pop edi esi |
1020 | pop edi esi |
1020 | stc |
1021 | stc |
1021 | ret |
1022 | ret |
1022 | .found: |
1023 | .found: |
- | 1024 | test ebp, ebp |
|
- | 1025 | jz @f |
|
- | 1026 | mov esi, ebp |
|
- | 1027 | xor ebp, ebp |
|
- | 1028 | jmp .continue |
|
- | 1029 | @@: |
|
1023 | mov eax, [esp+8] |
1030 | mov eax, [esp+8] |
1024 | add esp, 16 ; CF=0 |
1031 | add esp, 16 ; CF=0 |
1025 | pop esi |
1032 | pop esi |
1026 | ret |
1033 | ret |
Line 1499... | Line 1506... | ||
1499 | xor eax, eax ; create file |
1506 | xor eax, eax ; create file |
1500 | .common: |
1507 | .common: |
1501 | cmp byte [esi], 0 |
1508 | cmp byte [esi], 0 |
1502 | jz @b |
1509 | jz @b |
1503 | pushad |
1510 | pushad |
1504 | xor ebp, ebp |
1511 | xor edi, edi |
1505 | push esi |
1512 | push esi |
- | 1513 | test ebp, ebp |
|
- | 1514 | jz @f |
|
- | 1515 | mov esi, ebp |
|
1506 | @@: |
1516 | @@: |
1507 | lodsb |
1517 | lodsb |
1508 | test al, al |
1518 | test al, al |
1509 | jz @f |
1519 | jz @f |
1510 | cmp al, '/' |
1520 | cmp al, '/' |
1511 | jnz @b |
1521 | jnz @b |
1512 | lea ebp, [esi-1] |
1522 | lea edi, [esi-1] |
1513 | jmp @b |
1523 | jmp @b |
1514 | @@: |
1524 | @@: |
1515 | pop esi |
1525 | pop esi |
1516 | test ebp, ebp |
1526 | test edi, edi |
1517 | jnz .noroot |
1527 | jnz .noroot |
- | 1528 | test ebp, ebp |
|
- | 1529 | jnz .hasebp |
|
1518 | push ramdisk_root_extend_dir |
1530 | push ramdisk_root_extend_dir |
1519 | push ramdisk_root_next_write |
1531 | push ramdisk_root_next_write |
1520 | push ebp |
1532 | push edi |
1521 | push ramdisk_root_first |
1533 | push ramdisk_root_first |
1522 | push ramdisk_root_next |
1534 | push ramdisk_root_next |
1523 | jmp .common1 |
1535 | jmp .common1 |
- | 1536 | .hasebp: |
|
- | 1537 | mov eax, ERROR_ACCESS_DENIED |
|
- | 1538 | cmp byte [ebp], 0 |
|
- | 1539 | jz .ret1 |
|
- | 1540 | push ebp |
|
- | 1541 | xor ebp, ebp |
|
- | 1542 | call rd_find_lfn |
|
- | 1543 | pop esi |
|
- | 1544 | jc .notfound0 |
|
- | 1545 | jmp .common0 |
|
1524 | .noroot: |
1546 | .noroot: |
1525 | mov eax, ERROR_ACCESS_DENIED |
1547 | mov eax, ERROR_ACCESS_DENIED |
1526 | cmp byte [ebp+1], 0 |
1548 | cmp byte [edi+1], 0 |
1527 | jz .ret1 |
1549 | jz .ret1 |
1528 | ; check existence |
1550 | ; check existence |
1529 | mov byte [ebp], 0 |
1551 | mov byte [edi], 0 |
- | 1552 | push edi |
|
1530 | call rd_find_lfn |
1553 | call rd_find_lfn |
1531 | mov byte [ebp], '/' |
1554 | pop esi |
1532 | lea esi, [ebp+1] |
1555 | mov byte [esi], '/' |
1533 | jnc @f |
1556 | jnc @f |
- | 1557 | .notfound0: |
|
1534 | mov eax, ERROR_FILE_NOT_FOUND |
1558 | mov eax, ERROR_FILE_NOT_FOUND |
1535 | .ret1: |
1559 | .ret1: |
1536 | mov [esp+28], eax |
1560 | mov [esp+28], eax |
1537 | popad |
1561 | popad |
1538 | xor ebx, ebx |
1562 | xor ebx, ebx |
1539 | ret |
1563 | ret |
1540 | @@: |
1564 | @@: |
- | 1565 | inc esi |
|
- | 1566 | .common0: |
|
1541 | test byte [edi+11], 0x10 ; must be directory |
1567 | test byte [edi+11], 0x10 ; must be directory |
1542 | mov eax, ERROR_ACCESS_DENIED |
1568 | mov eax, ERROR_ACCESS_DENIED |
1543 | jz .ret1 |
1569 | jz .ret1 |
1544 | movzx ebp, word [edi+26] ; ebp=cluster |
1570 | movzx ebp, word [edi+26] ; ebp=cluster |
1545 | mov eax, ERROR_FAT_TABLE |
1571 | mov eax, ERROR_FAT_TABLE |
Line 2283... | Line 2309... | ||
2283 | xor eax, eax |
2309 | xor eax, eax |
2284 | ret |
2310 | ret |
Line 2285... | Line 2311... | ||
2285 | 2311 | ||
2286 | ;---------------------------------------------------------------- |
2312 | ;---------------------------------------------------------------- |
2287 | ; |
- | |
2288 | ; fs_RamdiskExecute - LFN variant for executing on sys floppy |
- | |
2289 | ; |
- | |
2290 | ; esi points to ramdisk filename (e.g. 'launcher') |
- | |
2291 | ; ebp points to full filename (e.g. '/rd/1/launcher') |
- | |
2292 | ; dword [ebx] = flags |
- | |
2293 | ; dword [ebx+4] = cmdline |
- | |
2294 | ; |
- | |
2295 | ; ret ebx,edx destroyed |
- | |
2296 | ; eax > 0 - PID, < 0 - error |
- | |
2297 | ; |
- | |
2298 | ;-------------------------------------------------------------- |
- | |
2299 | fs_RamdiskExecute: |
- | |
2300 | mov edx, [ebx] |
- | |
2301 | mov ebx, [ebx+4] |
- | |
2302 | test ebx, ebx |
- | |
2303 | jz @f |
- | |
2304 | ; add ebx, std_application_base_address |
- | |
2305 | @@: |
- | |
2306 | - | ||
2307 | ;---------------------------------------------------------------- |
- | |
2308 | ; |
- | |
2309 | ; fs_RamdiskExecute.flags - second entry |
- | |
2310 | ; |
- | |
2311 | ; esi points to ramdisk filename (kernel address) |
- | |
2312 | ; ebp points to full filename |
- | |
2313 | ; edx flags |
- | |
2314 | ; ebx cmdline (kernel address) |
- | |
2315 | ; |
- | |
2316 | ; ret eax > 0 - PID, < 0 - error |
- | |
2317 | ; |
- | |
2318 | ;-------------------------------------------------------------- |
- | |
2319 | - | ||
2320 | .flags: |
- | |
2321 | cmp byte [esi], 0 |
- | |
2322 | jnz @f |
- | |
2323 | ; cannot execute root! |
- | |
2324 | mov eax, -ERROR_ACCESS_DENIED |
- | |
2325 | ret |
- | |
2326 | @@: |
- | |
2327 | push edi |
- | |
2328 | call rd_find_lfn |
- | |
2329 | jnc .found |
- | |
2330 | pop edi |
- | |
2331 | mov eax, -ERROR_FILE_NOT_FOUND |
- | |
2332 | ret |
- | |
2333 | .found: |
- | |
2334 | movzx eax, word [edi+26] ; cluster |
- | |
2335 | push eax |
- | |
2336 | push dword [edi+28] ; size |
- | |
2337 | push .DoRead |
- | |
2338 | call fs_execute |
- | |
2339 | add esp, 12 |
- | |
2340 | pop edi |
- | |
2341 | ret |
- | |
2342 | - | ||
2343 | .DoRead: |
- | |
2344 | ; read next block |
- | |
2345 | ; in: eax->parameters, edi->buffer |
- | |
2346 | ; out: eax = error code |
- | |
2347 | pushad |
- | |
2348 | cmp dword [eax], 0 ; file size |
- | |
2349 | jz .eof |
- | |
2350 | mov edx, [eax+4] ; cluster |
- | |
2351 | lea esi, [edx+31] |
- | |
2352 | shl esi, 9 |
- | |
2353 | add esi, RAMDISK |
- | |
2354 | mov ecx, 512/4 |
- | |
2355 | rep movsd |
- | |
2356 | mov ecx, [eax] |
- | |
2357 | sub ecx, 512 |
- | |
2358 | jae @f |
- | |
2359 | add edi, ecx |
- | |
2360 | neg ecx |
- | |
2361 | push eax |
- | |
2362 | xor eax, eax |
- | |
2363 | rep stosb |
- | |
2364 | pop eax |
- | |
2365 | @@: |
- | |
2366 | mov [eax], ecx |
- | |
2367 | mov dx, [edx*2+RAMDISK_FAT] |
- | |
2368 | mov [eax+4], dx ; high word is already zero |
- | |
2369 | popad |
- | |
2370 | xor eax, eax |
- | |
2371 | ret |
- | |
2372 | .eof: |
- | |
2373 | popad |
- | |
2374 | mov eax, 6 |
- | |
2375 | ret |
- | |
2376 | - | ||
2377 | ;---------------------------------------------------------------- |
- | |
2378 | ; |
2313 | ; |
2379 | ; fs_RamdiskDelete - delete file or empty folder from ramdisk |
2314 | ; fs_RamdiskDelete - delete file or empty folder from ramdisk |
2380 | ; |
2315 | ; |
2381 | ; esi points to filename |
2316 | ; esi points to filename |
2382 | ; |
2317 | ; |