Rev 6643 | Rev 6756 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6643 | Rev 6726 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2013-2016. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2013-2016. 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: 6643 $ |
8 | $Revision: 6726 $ |
9 | 9 | ||
10 | ; EXT external functions |
10 | ; EXT external functions |
11 | ; in: |
11 | ; in: |
Line 623... | Line 623... | ||
623 | pop eax eax |
623 | pop eax eax |
624 | movi eax, ERROR_DISK_FULL |
624 | movi eax, ERROR_DISK_FULL |
625 | xor ecx, ecx |
625 | xor ecx, ecx |
626 | jmp .ret |
626 | jmp .ret |
Line 627... | Line 627... | ||
627 | 627 | ||
628 | extfsGetFileBlock: |
628 | extfsGetExtent: |
629 | ; in: esi -> inode, ecx = file block number |
629 | ; in: ecx = starting file block |
- | 630 | ; out: eax = first block number, ecx = extent size |
|
- | 631 | push ebx edx esi |
|
630 | ; out: ecx = block number |
632 | lea esi, [ebp+EXTFS.inodeBuffer] |
631 | test [esi+INODE.featureFlags], EXTENTS_USED |
633 | test [esi+INODE.featureFlags], EXTENTS_USED |
632 | jz .listTreeSearch |
- | |
633 | pushad |
634 | jz .listTreeSearch |
634 | add esi, INODE.blockNumbers |
635 | add esi, INODE.blockNumbers |
635 | .extentTreeSearch: |
636 | .extentTreeSearch: |
636 | cmp word [esi+NODEHEADER.magic], 0xF30A |
637 | cmp word [esi+NODEHEADER.magic], 0xF30A |
637 | jne .fail |
638 | jne .fail |
638 | movzx ebx, [esi+NODEHEADER.entriesFolow] |
639 | movzx ebx, [esi+NODEHEADER.entriesFolow] |
- | 640 | add esi, sizeof.NODEHEADER |
|
- | 641 | test ebx, ebx |
|
639 | add esi, sizeof.NODEHEADER |
642 | jz .noBlock |
640 | cmp word [esi-sizeof.NODEHEADER+NODEHEADER.currentDepth], 0 |
643 | cmp word [esi-sizeof.NODEHEADER+NODEHEADER.currentDepth], 0 |
641 | je .leaf_block |
644 | je .leaf_block |
642 | test ebx, ebx |
645 | dec ebx |
643 | jz .fail ; empty |
646 | jz .end_search_index |
644 | @@: |
- | |
645 | cmp ebx, 1 |
- | |
646 | je .end_search_index |
- | |
647 | cmp ecx, [esi+INDEX.fileBlock] |
- | |
648 | jb .fail |
647 | @@: |
649 | cmp ecx, [esi+sizeof.INDEX+INDEX.fileBlock] |
648 | cmp ecx, [esi+sizeof.INDEX+INDEX.fileBlock] |
650 | jb .end_search_index |
649 | jb .end_search_index |
651 | add esi, sizeof.INDEX |
650 | add esi, sizeof.INDEX |
652 | dec ebx |
651 | dec ebx |
653 | jmp @b |
- | |
654 | 652 | jnz @b |
|
655 | .end_search_index: |
653 | .end_search_index: |
656 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
654 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
657 | mov eax, [esi+INDEX.nodeBlock] |
655 | mov eax, [esi+INDEX.nodeBlock] |
658 | call extfsReadBlock |
656 | call extfsReadBlock |
659 | jc .fail |
657 | jc .fail2 |
660 | mov esi, ebx |
658 | mov esi, ebx |
Line -... | Line 659... | ||
- | 659 | jmp .extentTreeSearch |
|
- | 660 | ||
- | 661 | .fail: |
|
- | 662 | movi eax, ERROR_FS_FAIL |
|
661 | jmp .extentTreeSearch |
663 | jmp .fail2 |
662 | - | ||
663 | .leaf_block: |
- | |
664 | test ebx, ebx |
- | |
665 | jz .fail |
- | |
666 | mov edx, [esi+EXTENT.fileBlock] |
- | |
667 | cmp ecx, edx |
664 | |
668 | jb .fail |
665 | .leaf_block: |
669 | movzx edi, [esi+EXTENT.blocksCount] |
666 | movzx edx, [esi+EXTENT.blocksCount] |
670 | add edx, edi |
667 | add edx, [esi+EXTENT.fileBlock] |
671 | cmp ecx, edx |
668 | sub edx, ecx |
672 | jb .end_search_extent |
669 | ja .end_search_extent |
673 | add esi, sizeof.EXTENT |
670 | add esi, sizeof.EXTENT |
- | 671 | dec ebx |
|
- | 672 | jnz .leaf_block |
|
- | 673 | .noBlock: |
|
- | 674 | movi eax, ERROR_END_OF_FILE |
|
- | 675 | .fail2: |
|
- | 676 | pop esi edx ebx |
|
Line 674... | Line 677... | ||
674 | dec ebx |
677 | stc |
675 | jmp .leaf_block |
678 | ret |
- | 679 | ||
676 | 680 | .end_search_extent: |
|
677 | .end_search_extent: |
- | |
678 | sub ecx, [esi+EXTENT.fileBlock] |
- | |
679 | add ecx, [esi+EXTENT.fsBlock] |
681 | sub ecx, [esi+EXTENT.fileBlock] |
680 | mov PUSHAD_ECX, ecx |
- | |
681 | popad |
- | |
682 | xor eax, eax |
- | |
683 | ret |
- | |
684 | - | ||
685 | .fail: |
- | |
686 | popad |
- | |
687 | movi eax, ERROR_FS_FAIL |
- | |
688 | stc |
- | |
689 | ret |
- | |
690 | 682 | jc .fail |
|
691 | .get_indirect_block: |
- | |
692 | mov eax, [esi+INODE.addressBlock] |
- | |
693 | test eax, eax |
- | |
694 | jz .noBlock |
- | |
695 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
- | |
696 | call extfsReadBlock |
683 | add ecx, [esi+EXTENT.fsBlock] |
697 | jc .fail2 |
- | |
698 | mov ecx, [ebx+ecx*4] |
- | |
699 | pop ebx edx |
- | |
700 | ret |
- | |
701 | - | ||
702 | .get_direct_block: |
684 | mov eax, ecx |
Line 703... | Line 685... | ||
703 | mov ecx, [esi+INODE.blockNumbers+ecx*4] |
685 | mov ecx, edx |
704 | xor eax, eax |
686 | pop esi edx ebx |
705 | ret |
687 | ret |
706 | - | ||
707 | .listTreeSearch: |
688 | |
708 | cmp ecx, 12 |
689 | .listTreeSearch: |
709 | jb .get_direct_block |
690 | cmp ecx, 12 |
710 | push edx ebx |
691 | jb .get_direct_block |
711 | sub ecx, 12 |
692 | sub ecx, 12 |
Line 732... | Line 713... | ||
732 | call extfsReadBlock |
713 | call extfsReadBlock |
733 | jc .fail2 |
714 | jc .fail2 |
734 | mov eax, edx |
715 | mov eax, edx |
735 | jmp @f |
716 | jmp @f |
Line 736... | Line 717... | ||
736 | 717 | ||
737 | .noBlock: |
718 | .get_direct_block: |
- | 719 | mov edx, ecx |
|
- | 720 | mov cl, 12 |
|
- | 721 | lea ebx, [esi+INODE.blockNumbers] |
|
- | 722 | jmp .calculateExtent |
|
738 | xor ecx, ecx |
723 | |
- | 724 | .get_indirect_block: |
|
739 | .fail2: |
725 | mov eax, [esi+INODE.addressBlock] |
- | 726 | test eax, eax |
|
- | 727 | jz .noBlock |
|
- | 728 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
|
740 | pop ebx edx |
729 | call extfsReadBlock |
- | 730 | jc .fail2 |
|
- | 731 | mov edx, ecx |
|
- | 732 | mov ecx, [ebp+EXTFS.dwordsPerBlock] |
|
Line 741... | Line 733... | ||
741 | ret |
733 | jmp .calculateExtent |
742 | 734 | ||
743 | .get_double_indirect_block: |
735 | .get_double_indirect_block: |
744 | mov eax, [esi+INODE.doubleAddress] |
736 | mov eax, [esi+INODE.doubleAddress] |
Line 748... | Line 740... | ||
748 | call extfsReadBlock |
740 | call extfsReadBlock |
749 | jc .fail2 |
741 | jc .fail2 |
750 | mov eax, ecx |
742 | mov eax, ecx |
751 | @@: |
743 | @@: |
752 | xor edx, edx |
744 | xor edx, edx |
753 | div [ebp+EXTFS.dwordsPerBlock] |
745 | mov ecx, [ebp+EXTFS.dwordsPerBlock] |
- | 746 | div ecx |
|
754 | ; eax = number in doubly-indirect block, edx = number in indirect block |
747 | ; eax = number in doubly-indirect block, edx = number in indirect block |
755 | mov eax, [ebx+eax*4] |
748 | mov eax, [ebx+eax*4] |
756 | test eax, eax |
749 | test eax, eax |
757 | jz .noBlock |
750 | jz .noBlock |
758 | call extfsReadBlock |
751 | call extfsReadBlock |
759 | jc .fail2 |
752 | jc .fail2 |
760 | mov ecx, [ebx+edx*4] |
753 | .calculateExtent: |
761 | pop ebx edx |
754 | lea esi, [ebx+edx*4] |
762 | ret |
755 | lodsd |
763 | - | ||
764 | extfsReadFileBlock: |
- | |
765 | ; in: |
- | |
766 | ; eax = file block number |
- | |
767 | ; [ebp+EXTFS.inodeBuffer] = inode |
- | |
768 | ; out: |
- | |
769 | ; [ebp+EXTFS.mainBlockBuffer] -> block |
- | |
770 | push ebx ecx edx esi |
- | |
771 | mov ecx, eax |
756 | mov ebx, eax |
772 | lea esi, [ebp+EXTFS.inodeBuffer] |
- | |
773 | call extfsGetFileBlock |
- | |
774 | jc .ret |
- | |
775 | test ecx, ecx |
757 | sub ecx, edx |
776 | jz @f |
- | |
777 | mov eax, ecx |
758 | xor edx, edx |
778 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
- | |
779 | call extfsReadBlock |
- | |
780 | .ret: |
- | |
781 | pop esi edx ecx ebx |
- | |
782 | ret |
- | |
783 | - | ||
784 | @@: |
759 | @@: |
785 | movi eax, ERROR_FS_FAIL |
760 | inc edx |
786 | stc |
761 | dec ecx |
787 | jmp .ret |
762 | jz @f |
788 | - | ||
789 | extfsWriteFileBlock: |
- | |
790 | ; in: |
- | |
791 | ; eax = file block number |
- | |
792 | ; ebx -> data |
763 | lodsd |
793 | ; [ebp+EXTFS.inodeBuffer] = inode |
- | |
794 | push ecx edx esi |
- | |
795 | mov ecx, eax |
764 | sub eax, ebx |
796 | lea esi, [ebp+EXTFS.inodeBuffer] |
- | |
797 | call extfsGetFileBlock |
- | |
798 | jc @f |
- | |
799 | test ecx, ecx |
765 | sub eax, edx |
800 | jz @b |
766 | jz @b |
801 | mov eax, ecx |
- | |
802 | call extfsWriteBlock |
- | |
803 | @@: |
767 | @@: |
- | 768 | mov eax, ebx |
|
- | 769 | mov ecx, edx |
|
804 | pop esi edx ecx |
770 | pop esi edx ebx |
- | 771 | clc |
|
805 | ret |
772 | ret |
Line 806... | Line 773... | ||
806 | 773 | ||
807 | getInodeLocation: |
774 | getInodeLocation: |
808 | ; in: eax = inode number |
775 | ; in: eax = inode number |
Line 1441... | Line 1408... | ||
1441 | .searchBlock: |
1408 | .searchBlock: |
1442 | push eax ; blocks total |
1409 | push eax ; blocks total |
1443 | push ecx ; current file block number |
1410 | push ecx ; current file block number |
1444 | cmp eax, ecx |
1411 | cmp eax, ecx |
1445 | jz .alloc_block |
1412 | jz .alloc_block |
1446 | call extfsGetFileBlock |
1413 | call extfsGetExtent |
1447 | jc .error_get_inode_block |
1414 | jc .error_get_inode_block |
1448 | test ecx, ecx |
- | |
1449 | jz .alloc_block |
- | |
1450 | push ecx |
1415 | push eax |
1451 | mov eax, ecx |
- | |
1452 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1416 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1453 | call extfsReadBlock |
1417 | call extfsReadBlock |
1454 | jc .error_block_read |
1418 | jc .error_block_read |
1455 | mov ecx, [esp+12] |
1419 | mov ecx, [esp+12] |
1456 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
1420 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
Line 1484... | Line 1448... | ||
1484 | jb .searchSpace |
1448 | jb .searchSpace |
1485 | pop ecx ecx eax |
1449 | pop ecx ecx eax |
1486 | inc ecx |
1450 | inc ecx |
1487 | jmp .searchBlock |
1451 | jmp .searchBlock |
Line 1488... | Line -... | ||
1488 | - | ||
1489 | .alloc_block: |
- | |
1490 | mov ecx, [esi+INODE.fileSize] |
- | |
1491 | add ecx, [ebp+EXTFS.bytesPerBlock] |
- | |
1492 | mov eax, [esp+24] |
- | |
1493 | call extfsExtendFile |
- | |
1494 | jc .error_get_inode_block |
- | |
1495 | mov eax, [esp+24] |
- | |
1496 | mov ebx, esi |
- | |
1497 | call writeInode |
- | |
1498 | jc .error_get_inode_block |
- | |
1499 | jmp @f |
- | |
1500 | 1452 | ||
1501 | .zeroLength: |
1453 | .zeroLength: |
1502 | mov [edi+DIRENTRY.entryLength], cx |
1454 | mov [edi+DIRENTRY.entryLength], cx |
1503 | mov eax, edx |
1455 | mov eax, edx |
1504 | sub eax, edi |
1456 | sub eax, edi |
Line 1509... | Line 1461... | ||
1509 | ; this block wasn't linking to the next one, so write it, and use the next block |
1461 | ; this block wasn't linking to the next one, so write it, and use the next block |
1510 | pop eax |
1462 | pop eax |
1511 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1463 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1512 | call extfsWriteBlock |
1464 | call extfsWriteBlock |
1513 | jc .error_get_inode_block |
1465 | jc .error_get_inode_block |
- | 1466 | pop ecx |
|
- | 1467 | inc ecx |
|
1514 | inc dword[esp] |
1468 | cmp ecx, [esp] |
- | 1469 | push ecx |
|
- | 1470 | jnz @f |
|
1515 | @@: |
1471 | .alloc_block: |
- | 1472 | mov ecx, [esi+INODE.fileSize] |
|
- | 1473 | add ecx, [ebp+EXTFS.bytesPerBlock] |
|
- | 1474 | mov eax, [esp+24] |
|
- | 1475 | call extfsExtendFile |
|
- | 1476 | jc .error_get_inode_block |
|
- | 1477 | mov eax, [esp+24] |
|
- | 1478 | mov ebx, esi |
|
- | 1479 | call writeInode |
|
- | 1480 | jc .error_get_inode_block |
|
1516 | mov ecx, [esp] |
1481 | mov ecx, [esp] |
- | 1482 | @@: |
|
1517 | call extfsGetFileBlock |
1483 | call extfsGetExtent |
1518 | jc .error_get_inode_block |
1484 | jc .error_get_inode_block |
1519 | test ecx, ecx |
- | |
1520 | jz .alloc_block |
- | |
1521 | push ecx |
1485 | push eax |
1522 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
1486 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
1523 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1487 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1524 | mov [edi+DIRENTRY.entryLength], ax |
1488 | mov [edi+DIRENTRY.entryLength], ax |
1525 | .found: |
1489 | .found: |
1526 | pop edx ecx ecx ecx ebx esi |
1490 | pop edx ecx ecx ecx ebx esi |
Line 1571... | Line 1535... | ||
1571 | push edx ebx |
1535 | push edx ebx |
1572 | lea ebx, [ebp+EXTFS.inodeBuffer] |
1536 | lea ebx, [ebp+EXTFS.inodeBuffer] |
1573 | call readInode |
1537 | call readInode |
1574 | jc .fail |
1538 | jc .fail |
1575 | push eax |
1539 | push eax |
1576 | lea esi, [ebp+EXTFS.inodeBuffer] |
- | |
1577 | .loop: |
1540 | .loop: |
1578 | mov ecx, [esp] |
1541 | mov ecx, [esp] |
1579 | call extfsGetFileBlock |
1542 | call extfsGetExtent |
1580 | jc .fail_loop |
1543 | jc .fail_loop |
1581 | test ecx, ecx |
- | |
1582 | jz .fail_loop |
- | |
1583 | mov eax, ecx |
- | |
1584 | mov edi, ecx |
1544 | mov edi, eax |
1585 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1545 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1586 | call extfsReadBlock |
1546 | call extfsReadBlock |
1587 | jc .fail_loop |
1547 | jc .fail_loop |
1588 | .first_dir_entry: ; edi -> block |
1548 | .first_dir_entry: ; edi -> block |
1589 | mov eax, [esp+4] |
1549 | mov eax, [esp+4] |
Line 1683... | Line 1643... | ||
1683 | .next_path_part: |
1643 | .next_path_part: |
1684 | push [edx+INODE.sectorsUsed] |
1644 | push [edx+INODE.sectorsUsed] |
1685 | xor ecx, ecx |
1645 | xor ecx, ecx |
1686 | .folder_block_cycle: |
1646 | .folder_block_cycle: |
1687 | push ecx |
1647 | push ecx |
1688 | xchg esi, edx |
- | |
1689 | call extfsGetFileBlock |
1648 | call extfsGetExtent |
1690 | jc @b |
1649 | jc @b |
1691 | xchg esi, edx |
- | |
1692 | mov eax, ecx |
- | |
1693 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
1650 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
1694 | call extfsReadBlock |
1651 | call extfsReadBlock |
1695 | jc @b |
1652 | jc @b |
1696 | push esi edx |
1653 | push esi edx |
1697 | mov edx, ebx |
1654 | mov edx, ebx |
Line 1827... | Line 1784... | ||
1827 | push 0 ; [edi+4] files in folder |
1784 | push 0 ; [edi+4] files in folder |
1828 | push 0 ; [edi] current block index |
1785 | push 0 ; [edi] current block index |
1829 | mov edi, esp ; edi -> local variables |
1786 | mov edi, esp ; edi -> local variables |
1830 | add edx, 32 |
1787 | add edx, 32 |
1831 | xor ecx, ecx |
1788 | xor ecx, ecx |
1832 | call extfsGetFileBlock |
1789 | call extfsGetExtent |
1833 | jc .error_get_block |
1790 | jc .error_get_block |
1834 | mov eax, ecx |
- | |
1835 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
1791 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
1836 | call extfsReadBlock |
1792 | call extfsReadBlock |
1837 | jc .error_get_block |
1793 | jc .error_get_block |
1838 | mov eax, ebx |
1794 | mov eax, ebx |
1839 | add eax, [ebp+EXTFS.bytesPerBlock] |
1795 | add eax, [ebp+EXTFS.bytesPerBlock] |
Line 1861... | Line 1817... | ||
1861 | cmp [esi+INODE.fileSize], 0 |
1817 | cmp [esi+INODE.fileSize], 0 |
1862 | jle .end_dir |
1818 | jle .end_dir |
1863 | inc dword [edi] |
1819 | inc dword [edi] |
1864 | push ecx |
1820 | push ecx |
1865 | mov ecx, [edi] |
1821 | mov ecx, [edi] |
1866 | call extfsGetFileBlock |
1822 | call extfsGetExtent |
1867 | jc .error_get_block |
1823 | jc .error_get_block |
1868 | mov eax, ecx |
- | |
1869 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
1824 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
1870 | call extfsReadBlock |
1825 | call extfsReadBlock |
1871 | jc .error_get_block |
1826 | jc .error_get_block |
1872 | pop ecx |
1827 | pop ecx |
1873 | mov eax, ebx |
1828 | mov eax, ebx |
Line 1999... | Line 1954... | ||
1999 | jmp .error_ret |
1954 | jmp .error_ret |
Line 2000... | Line 1955... | ||
2000 | 1955 | ||
2001 | ;---------------------------------------------------------------- |
1956 | ;---------------------------------------------------------------- |
2002 | ext_ReadFile: |
1957 | ext_ReadFile: |
2003 | call ext_lock |
1958 | call ext_lock |
2004 | push ERROR_ACCESS_DENIED |
1959 | pushd 0 ERROR_ACCESS_DENIED |
2005 | cmp byte [esi], 0 |
1960 | cmp byte [esi], 0 |
2006 | jz .error ; root |
1961 | jz .ret ; root |
2007 | mov [esp], ebx |
1962 | mov [esp], ebx |
2008 | call findInode |
1963 | call findInode |
2009 | pop ebx |
1964 | pop ebx |
2010 | jc .error_eax |
1965 | push eax |
2011 | push ERROR_ACCESS_DENIED |
1966 | jc .ret |
- | 1967 | lea esi, [ebp+EXTFS.inodeBuffer] |
|
2012 | lea esi, [ebp+EXTFS.inodeBuffer] |
1968 | mov byte [esp], ERROR_ACCESS_DENIED |
2013 | mov ax, [esi+INODE.accessMode] |
1969 | test [esi+INODE.accessMode], FLAG_FILE |
2014 | and ax, TYPE_MASK |
1970 | jz .ret ; not a file |
2015 | cmp ax, FLAG_FILE |
1971 | mov byte [esp], ERROR_END_OF_FILE |
- | 1972 | mov eax, [esi+INODE.fileSize] |
|
2016 | jnz .error ; not a file |
1973 | mov edx, [esi+INODE.fileSizeHigh] |
2017 | pop eax |
1974 | sub eax, [ebx+4] |
- | 1975 | sbb edx, [ebx+8] |
|
2018 | mov edi, [ebx+16] |
1976 | jc .ret |
2019 | mov ecx, [ebx+12] |
1977 | mov ecx, [ebx+12] |
2020 | mov eax, [ebx+4] |
1978 | sub eax, ecx |
2021 | mov edx, [ebx+8] |
- | |
2022 | push ERROR_END_OF_FILE |
- | |
2023 | cmp [esi+INODE.fileSizeHigh], edx |
1979 | sbb edx, 0 |
2024 | ja @f |
1980 | jc @f |
2025 | jb .error |
- | |
2026 | cmp [esi+INODE.fileSize], eax |
1981 | xor eax, eax |
2027 | jna .error |
1982 | mov [esp], eax |
2028 | @@: |
- | |
2029 | add esp, 4 |
1983 | @@: |
2030 | add eax, ecx |
- | |
2031 | adc edx, 0 |
- | |
2032 | cmp [esi+INODE.fileSizeHigh], edx |
- | |
2033 | ja .read_till_requested |
- | |
2034 | jb .read_whole_file |
- | |
2035 | cmp [esi+INODE.fileSize], eax |
- | |
2036 | jae .read_till_requested |
- | |
2037 | .read_whole_file: |
- | |
2038 | push 1 ; read till the end of file |
- | |
2039 | mov ecx, [esi+INODE.fileSize] |
- | |
2040 | sub ecx, [ebx+4] |
- | |
2041 | jmp @f |
- | |
2042 | - | ||
2043 | .read_till_requested: |
- | |
2044 | push 0 ; read as much as requested |
- | |
2045 | @@: ; ecx = bytes to read, edi -> buffer |
- | |
2046 | push ecx |
- | |
2047 | ; read part of the first block |
- | |
2048 | mov edx, [ebx+8] |
1984 | add ecx, eax |
- | 1985 | mov eax, [ebx+4] |
|
- | 1986 | mov edx, [ebx+8] |
|
2049 | mov eax, [ebx+4] |
1987 | mov edi, [ebx+16] |
2050 | div [ebp+EXTFS.bytesPerBlock] |
1988 | div [ebp+EXTFS.bytesPerBlock] |
- | 1989 | test edx, edx |
|
- | 1990 | jz .aligned |
|
2051 | push eax |
1991 | .piece: |
- | 1992 | push eax ecx |
|
2052 | push ecx |
1993 | mov esi, edx |
2053 | mov ecx, eax |
1994 | mov ecx, eax |
2054 | call extfsGetFileBlock |
1995 | call extfsGetExtent |
- | 1996 | jc .errorGet |
|
- | 1997 | mov ecx, [ebp+EXTFS.sectorsPerBlock] |
|
2055 | jc .error_at_first_block |
1998 | mul ecx |
2056 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
- | |
2057 | mov eax, ecx |
1999 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
2058 | call extfsReadBlock |
- | |
2059 | jc .error_at_first_block |
2000 | call fs_read64_sys |
2060 | pop ecx |
2001 | test eax, eax |
2061 | add ebx, edx |
2002 | jnz .errorRead |
2062 | neg edx |
2003 | pop eax |
2063 | add edx, [ebp+EXTFS.bytesPerBlock] |
2004 | mov ecx, [ebp+EXTFS.bytesPerBlock] |
2064 | cmp ecx, edx |
2005 | sub ecx, esi |
2065 | jbe .only_one_block |
2006 | sub eax, ecx |
2066 | mov eax, ecx |
2007 | jnc @f |
2067 | sub eax, edx ; bytes to read |
2008 | add ecx, eax |
- | 2009 | xor eax, eax |
|
2068 | mov ecx, edx |
2010 | @@: |
2069 | push esi |
2011 | add esi, ebx |
2070 | mov esi, ebx |
2012 | add [esp+8], ecx |
- | 2013 | rep movsb |
|
2071 | rep movsb |
2014 | mov ecx, eax |
2072 | pop esi |
2015 | pop eax |
2073 | mov ebx, edi |
2016 | inc eax |
- | 2017 | xor edx, edx |
|
- | 2018 | jecxz .ret |
|
- | 2019 | .aligned: |
|
2074 | xor edx, edx |
2020 | xchg eax, ecx |
- | 2021 | div [ebp+EXTFS.bytesPerBlock] |
|
2075 | div [ebp+EXTFS.bytesPerBlock] |
2022 | push edx |
- | 2023 | mov edx, eax |
|
- | 2024 | .writeExtent: |
|
- | 2025 | test edx, edx |
|
- | 2026 | jz .end |
|
- | 2027 | push ecx |
|
- | 2028 | call extfsGetExtent |
|
- | 2029 | jc .errorGet |
|
- | 2030 | sub edx, ecx |
|
- | 2031 | jnc @f |
|
- | 2032 | add ecx, edx |
|
2076 | mov edi, eax |
2033 | xor edx, edx |
2077 | @@: |
2034 | @@: |
2078 | test edi, edi |
2035 | add [esp], ecx |
2079 | jz .finish_block |
2036 | imul ecx, [ebp+EXTFS.sectorsPerBlock] |
2080 | inc dword [esp] |
2037 | mov ebx, edi |
2081 | mov ecx, [esp] |
2038 | push edx ecx |
2082 | call extfsGetFileBlock |
2039 | mul [ebp+EXTFS.sectorsPerBlock] |
2083 | jc .error_at_read_cycle |
2040 | call fs_read64_sys |
2084 | mov eax, ecx |
2041 | pop ecx edx |
2085 | call extfsReadBlock |
2042 | test eax, eax |
- | 2043 | jnz .errorRead |
|
- | 2044 | shl ecx, 9 |
|
2086 | jc .error_at_read_cycle |
2045 | add edi, ecx |
2087 | add ebx, [ebp+EXTFS.bytesPerBlock] |
2046 | add [esp+12], ecx |
2088 | dec edi |
2047 | pop ecx |
Line 2089... | Line -... | ||
2089 | jmp @b |
- | |
2090 | - | ||
2091 | .finish_block: ; edx = number of bytes in the last block |
2048 | jmp .writeExtent |
2092 | test edx, edx |
- | |
2093 | jz .end_read |
- | |
2094 | pop ecx ; block counter |
- | |
2095 | inc ecx |
- | |
2096 | call extfsGetFileBlock |
- | |
2097 | jc .error_at_finish_block |
2049 | |
2098 | mov edi, ebx |
- | |
2099 | mov eax, ecx |
- | |
2100 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
- | |
2101 | call extfsReadBlock |
2050 | .end: |
2102 | jc .error_at_finish_block |
- | |
2103 | push eax |
- | |
2104 | mov ecx, edx |
- | |
2105 | .only_one_block: |
- | |
2106 | mov esi, ebx |
- | |
2107 | rep movsb |
- | |
2108 | .end_read: |
- | |
2109 | call ext_unlock |
2051 | mov eax, ecx |
2110 | pop eax ebx eax |
2052 | pop ecx |
2111 | test eax, eax |
- | |
2112 | jz @f |
- | |
2113 | movi eax, ERROR_END_OF_FILE |
- | |
Line 2114... | Line -... | ||
2114 | @@: |
- | |
2115 | ret |
- | |
2116 | 2053 | jecxz .ret |
|
2117 | .error_at_first_block: |
2054 | jmp .piece |
2118 | pop ebx |
2055 | |
2119 | .error_at_read_cycle: |
2056 | .errorRead: |
2120 | pop ebx |
- | |
2121 | .error_at_finish_block: |
2057 | movi eax, ERROR_DEVICE |
2122 | pop ebx ebx |
2058 | .errorGet: |
2123 | .error_eax: |
2059 | pop ebx ebx |
2124 | push eax |
2060 | mov [esp], eax |
2125 | .error: |
- | |
2126 | call ext_unlock |
2061 | .ret: |
Line 2127... | Line 2062... | ||
2127 | xor ebx, ebx |
2062 | call ext_unlock |
2128 | pop eax |
2063 | pop eax ebx |
2129 | ret |
2064 | ret |
Line 2225... | Line 2160... | ||
2225 | lea edx, [ebp+EXTFS.inodeBuffer] |
2160 | lea edx, [ebp+EXTFS.inodeBuffer] |
2226 | movzx edx, [edx+INODE.accessMode] |
2161 | movzx edx, [edx+INODE.accessMode] |
2227 | and edx, TYPE_MASK |
2162 | and edx, TYPE_MASK |
2228 | cmp edx, DIRECTORY |
2163 | cmp edx, DIRECTORY |
2229 | jne .file |
2164 | jne .file |
2230 | push ebx ecx edx 0 |
2165 | push ebx ecx edx |
2231 | lea esi, [ebp+EXTFS.inodeBuffer] |
2166 | xor ecx, ecx |
2232 | .checkDirectory: |
2167 | .checkDirectory: |
2233 | mov ecx, [esp] |
2168 | push ecx |
2234 | call extfsGetFileBlock |
2169 | call extfsGetExtent |
2235 | jc .not_empty_eax |
- | |
2236 | test ecx, ecx |
- | |
2237 | jz .empty |
2170 | jc .empty |
2238 | mov eax, ecx |
- | |
2239 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
2171 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
2240 | call extfsReadBlock |
2172 | call extfsReadBlock |
2241 | jc .not_empty_eax |
2173 | jc .not_empty_eax |
2242 | mov edx, ebx |
2174 | mov edx, ebx |
2243 | add edx, [ebp+EXTFS.bytesPerBlock] |
2175 | add edx, [ebp+EXTFS.bytesPerBlock] |
Line 2255... | Line 2187... | ||
2255 | jne .not_empty |
2187 | jne .not_empty |
2256 | movzx ecx, [ebx+DIRENTRY.entryLength] |
2188 | movzx ecx, [ebx+DIRENTRY.entryLength] |
2257 | add ebx, ecx |
2189 | add ebx, ecx |
2258 | cmp ebx, edx |
2190 | cmp ebx, edx |
2259 | jb .dir_entry |
2191 | jb .dir_entry |
- | 2192 | pop ecx |
|
2260 | inc dword[esp] |
2193 | inc ecx |
2261 | jmp .checkDirectory |
2194 | jmp .checkDirectory |
Line 2262... | Line 2195... | ||
2262 | 2195 | ||
- | 2196 | .empty: |
|
- | 2197 | cmp eax, ERROR_END_OF_FILE |
|
2263 | .empty: |
2198 | jnz .not_empty_eax |
2264 | pop edx edx ecx ebx |
2199 | pop edx edx ecx ebx |
2265 | .file: |
2200 | .file: |
2266 | mov eax, ecx |
2201 | mov eax, ecx |
2267 | push ebx ecx |
2202 | push ebx ecx |
Line 2420... | Line 2355... | ||
2420 | parent_link db "..", 0 |
2355 | parent_link db "..", 0 |
Line 2421... | Line 2356... | ||
2421 | 2356 | ||
2422 | ;---------------------------------------------------------------- |
2357 | ;---------------------------------------------------------------- |
2423 | ext_CreateFile: |
2358 | ext_CreateFile: |
2424 | call extfsWritingInit |
2359 | call extfsWritingInit |
2425 | push 0 ebx |
2360 | pushd 0 0 ebx |
2426 | call findInode |
2361 | call findInode |
2427 | jnc .exist |
2362 | jnc .exist |
2428 | test edi, edi |
2363 | test edi, edi |
2429 | jz .error |
2364 | jz .error |
Line 2454... | Line 2389... | ||
2454 | mov esi, edi |
2389 | mov esi, edi |
2455 | mov dl, DIR_FLAG_FILE |
2390 | mov dl, DIR_FLAG_FILE |
2456 | call linkInode |
2391 | call linkInode |
2457 | jc .error2 |
2392 | jc .error2 |
2458 | pop esi ebx |
2393 | pop esi ebx |
2459 | push ebx esi |
- | |
2460 | mov ecx, [ebx+12] |
2394 | mov ecx, [ebx+12] |
2461 | jmp ext_WriteFile.start |
2395 | jmp ext_WriteFile.start |
Line 2462... | Line 2396... | ||
2462 | 2396 | ||
2463 | .exist: |
- | |
2464 | lea edx, [ebp+EXTFS.inodeBuffer] |
2397 | .exist: |
2465 | movi eax, ERROR_ACCESS_DENIED |
2398 | movi eax, ERROR_ACCESS_DENIED |
2466 | test [edx+INODE.accessMode], FLAG_FILE |
2399 | test [ebp+EXTFS.inodeBuffer.accessMode], FLAG_FILE |
2467 | jz .error ; not a file |
2400 | jz .error ; not a file |
2468 | pop ebx |
- | |
2469 | push ebx esi |
2401 | pop ebx |
2470 | mov ecx, [ebx+12] |
2402 | mov ecx, [ebx+12] |
2471 | call extfsTruncateFile |
2403 | call extfsTruncateFile |
Line 2472... | Line 2404... | ||
2472 | jmp ext_WriteFile.start |
2404 | jmp ext_WriteFile.start |
2473 | 2405 | ||
2474 | .error2: |
2406 | .error2: |
2475 | pop ebx |
2407 | pop ebx |
2476 | .error: |
2408 | .error: |
2477 | push eax |
2409 | push eax |
2478 | call ext_unlock |
- | |
2479 | pop eax ebx ebx |
2410 | call ext_unlock |
Line 2480... | Line 2411... | ||
2480 | xor ebx, ebx |
2411 | pop eax ebx ebx ebx |
2481 | ret |
2412 | ret |
2482 | 2413 | ||
2483 | ;---------------------------------------------------------------- |
2414 | ;---------------------------------------------------------------- |
2484 | ext_WriteFile: |
2415 | ext_WriteFile: |
2485 | call extfsWritingInit |
2416 | call extfsWritingInit |
2486 | push 0 ebx |
2417 | push ebx |
2487 | call findInode |
2418 | call findInode |
2488 | pop ebx |
- | |
2489 | push ebx esi |
2419 | pop ebx |
2490 | jc .error |
2420 | pushd 0 eax |
2491 | lea edx, [ebp+EXTFS.inodeBuffer] |
2421 | jc .ret |
2492 | movi eax, ERROR_ACCESS_DENIED |
2422 | mov byte [esp], ERROR_ACCESS_DENIED |
2493 | test [edx+INODE.accessMode], FLAG_FILE |
2423 | test [ebp+EXTFS.inodeBuffer.accessMode], FLAG_FILE |
2494 | jz .error ; not a file |
2424 | jz .ret ; not a file |
- | 2425 | mov ecx, [ebx+4] |
|
2495 | mov ecx, [ebx+4] |
2426 | add ecx, [ebx+12] |
2496 | add ecx, [ebx+12] |
2427 | .start: |
2497 | .start: |
- | |
2498 | mov eax, esi |
- | |
2499 | call extfsExtendFile |
2428 | push esi |
2500 | mov ecx, [ebx+12] |
- | |
2501 | push eax |
2429 | mov eax, esi |
2502 | jc .error_inode_size |
2430 | call extfsExtendFile |
2503 | pop eax |
2431 | jc .errorExtend |
- | 2432 | mov eax, [ebx+4] |
|
2504 | mov eax, [ebx+4] |
2433 | mov ecx, [ebx+12] |
2505 | mov ebx, [ebx+16] |
2434 | mov esi, [ebx+16] |
2506 | push eax |
2435 | .write: |
2507 | xor edx, edx |
2436 | xor edx, edx |
- | 2437 | div [ebp+EXTFS.bytesPerBlock] |
|
- | 2438 | test edx, edx |
|
- | 2439 | jz .aligned |
|
- | 2440 | .piece: |
|
- | 2441 | mov ebx, ecx |
|
- | 2442 | mov edi, edx |
|
- | 2443 | mov ecx, eax |
|
- | 2444 | push eax |
|
- | 2445 | call extfsGetExtent |
|
- | 2446 | jc .errorGet |
|
- | 2447 | mov ecx, [ebp+EXTFS.sectorsPerBlock] |
|
- | 2448 | mul ecx |
|
- | 2449 | push ecx eax ebx |
|
- | 2450 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
|
- | 2451 | call fs_read64_sys |
|
2508 | div [ebp+EXTFS.bytesPerBlock] |
2452 | test eax, eax |
2509 | test edx, edx |
2453 | jnz .errorDevice |
2510 | jz .start_aligned |
2454 | pop eax |
2511 | mov esi, [ebp+EXTFS.bytesPerBlock] |
2455 | mov ecx, [ebp+EXTFS.bytesPerBlock] |
- | 2456 | sub ecx, edi |
|
2512 | sub esi, edx |
2457 | sub eax, ecx |
2513 | cmp esi, ecx |
2458 | jnc @f |
2514 | jbe @f |
- | |
2515 | mov esi, ecx |
- | |
2516 | @@: |
- | |
2517 | mov edi, eax |
- | |
2518 | call extfsReadFileBlock |
- | |
2519 | jc .error_inode_size |
- | |
2520 | mov eax, edi |
- | |
2521 | push ebx ecx |
- | |
2522 | mov ecx, esi |
- | |
2523 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
2459 | add ecx, eax |
2524 | mov esi, ebx |
2460 | xor eax, eax |
2525 | mov ebx, edi |
2461 | @@: |
2526 | add edi, edx |
- | |
2527 | mov edx, ecx |
- | |
2528 | rep movsb |
- | |
2529 | call extfsWriteFileBlock |
- | |
2530 | pop ecx ebx |
2462 | add edi, ebx |
2531 | jc .error_inode_size |
2463 | add [esp+20], ecx |
2532 | add [esp], edx |
- | |
2533 | add ebx, edx |
- | |
2534 | sub ecx, edx |
- | |
2535 | jz .write_inode |
- | |
2536 | .start_aligned: |
- | |
2537 | cmp ecx, [ebp+EXTFS.bytesPerBlock] |
2464 | rep movsb |
2538 | jb @f |
- | |
2539 | mov eax, [esp] |
2465 | mov edi, eax |
2540 | xor edx, edx |
- | |
2541 | div [ebp+EXTFS.bytesPerBlock] |
- | |
2542 | call extfsWriteFileBlock |
2466 | pop eax ecx |
2543 | jc .error_inode_size |
2467 | xor edx, edx |
2544 | mov eax, [ebp+EXTFS.bytesPerBlock] |
- | |
2545 | sub ecx, eax |
- | |
2546 | add ebx, eax |
- | |
2547 | add [esp], eax |
- | |
2548 | jmp .start_aligned |
2468 | call fs_write64_sys |
2549 | - | ||
2550 | @@: ; handle the remaining bytes |
- | |
2551 | test ecx, ecx |
2469 | mov ecx, edi |
- | 2470 | pop eax |
|
- | 2471 | inc eax |
|
- | 2472 | xor edx, edx |
|
2552 | jz .write_inode |
2473 | jecxz .done |
- | 2474 | .aligned: |
|
- | 2475 | xchg eax, ecx |
|
- | 2476 | div [ebp+EXTFS.bytesPerBlock] |
|
- | 2477 | push edx |
|
- | 2478 | mov edx, eax |
|
2553 | mov eax, [esp] |
2479 | .writeExtent: |
- | 2480 | test edx, edx |
|
- | 2481 | jz .end |
|
- | 2482 | push ecx |
|
- | 2483 | call extfsGetExtent |
|
- | 2484 | jc .errorGet2 |
|
2554 | xor edx, edx |
2485 | sub edx, ecx |
- | 2486 | jnc @f |
|
- | 2487 | add ecx, edx |
|
2555 | div [ebp+EXTFS.bytesPerBlock] |
2488 | xor edx, edx |
2556 | push ecx |
2489 | @@: |
- | 2490 | add [esp], ecx |
|
- | 2491 | imul ecx, [ebp+EXTFS.sectorsPerBlock] |
|
- | 2492 | mov ebx, esi |
|
- | 2493 | push edx ecx |
|
- | 2494 | mul [ebp+EXTFS.sectorsPerBlock] |
|
- | 2495 | call fs_write64_sys |
|
2557 | mov esi, ebx |
2496 | test eax, eax |
- | 2497 | jnz .errorDevice |
|
- | 2498 | pop ebx edx ecx |
|
- | 2499 | shl ebx, 9 |
|
- | 2500 | add esi, ebx |
|
- | 2501 | add [esp+12], ebx |
|
- | 2502 | jmp .writeExtent |
|
2558 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
2503 | |
2559 | mov ebx, edi |
- | |
2560 | rep movsb |
2504 | .end: |
2561 | pop ecx |
2505 | mov eax, ecx |
- | 2506 | pop ecx |
|
2562 | call extfsWriteFileBlock |
2507 | jecxz .done |
2563 | jc .error_inode_size |
- | |
2564 | xor ecx, ecx |
- | |
2565 | .error_inode_size: |
- | |
2566 | mov [esp+12], eax |
2508 | jmp .piece |
2567 | .write_inode: |
2509 | |
- | 2510 | .errorDevice: |
|
2568 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2511 | pop eax eax |
- | 2512 | movi eax, ERROR_DEVICE |
|
2569 | pop eax eax |
2513 | .errorGet2: |
- | 2514 | pop ebx |
|
2570 | call writeInode |
2515 | .errorGet: |
- | 2516 | pop ebx |
|
- | 2517 | .errorExtend: |
|
2571 | pop ebx |
2518 | mov [esp+4], eax |
2572 | mov ebx, [ebx+12] |
2519 | .done: |
2573 | sub ebx, ecx |
2520 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2574 | test eax, eax |
- | |
2575 | jz @f |
2521 | pop eax |
2576 | mov [esp], eax |
2522 | call writeInode |
2577 | @@: |
2523 | add [esp], eax |
2578 | call writeSuperblock |
2524 | call writeSuperblock |
2579 | mov esi, [ebp+PARTITION.Disk] |
2525 | mov esi, [ebp+PARTITION.Disk] |
2580 | call disk_sync |
2526 | call disk_sync |
2581 | @@: |
2527 | .ret: |
Line 2582... | Line 2528... | ||
2582 | call ext_unlock |
2528 | call ext_unlock |
2583 | pop eax |
2529 | pop eax ebx |
2584 | ret |
2530 | ret |
2585 | 2531 | ||
Line 2586... | Line 2532... | ||
2586 | .error: |
2532 | .erase: |
2587 | pop ebx ebx ebx |
2533 | push eax eax edx |
2588 | push eax |
2534 | mov eax, ebx |
2589 | jmp @b |
2535 | jmp .write |
2590 | 2536 | ||
- | 2537 | ;---------------------------------------------------------------- |
|
2591 | ;---------------------------------------------------------------- |
2538 | ext_SetFileEnd: |
2592 | ext_SetFileEnd: |
2539 | call extfsWritingInit |
2593 | call extfsWritingInit |
2540 | pushd [ebx+4] |
2594 | pushd [ebx+4] |
2541 | call findInode |
2595 | call findInode |
2542 | pop ecx |
2596 | jc .error2 |
- | |
2597 | lea edi, [ebp+EXTFS.inodeBuffer] |
2543 | jc .error2 |
2598 | movi eax, ERROR_ACCESS_DENIED |
2544 | lea edi, [ebp+EXTFS.inodeBuffer] |
2599 | cmp [edi+INODE.accessMode], FLAG_FILE |
2545 | movi eax, ERROR_ACCESS_DENIED |
2600 | jnz .error2 ; not a file |
2546 | test [edi+INODE.accessMode], FLAG_FILE |
2601 | pop ecx |
2547 | jz .error2 ; not a file |
2602 | push esi |
- | |
2603 | mov ebx, [edi+INODE.fileSize] |
- | |
2604 | mov eax, esi |
- | |
2605 | cmp ebx, ecx |
- | |
2606 | jc @f |
2548 | push esi |
2607 | call extfsTruncateFile |
2549 | mov ebx, [edi+INODE.fileSize] |
2608 | jmp .done |
2550 | mov eax, esi |
- | 2551 | cmp ebx, ecx |
|
- | 2552 | jnc @f |
|
- | 2553 | call extfsExtendFile |
|
- | 2554 | jc .error |
|
- | 2555 | sub ecx, ebx |
|
2609 | 2556 | cmp ecx, 1000001h |
|
- | 2557 | jnc .done |
|
- | 2558 | push ecx |
|
- | 2559 | stdcall kernel_alloc, ecx |
|
2610 | @@: |
2560 | pop ecx |
2611 | call extfsExtendFile |
2561 | test eax, eax |
2612 | jc .error |
2562 | jz .error |
2613 | sub ecx, ebx |
- | |
2614 | mov eax, ebx |
- | |
2615 | xor edx, edx |
- | |
2616 | div [ebp+EXTFS.bytesPerBlock] |
- | |
2617 | mov edi, eax |
- | |
2618 | test edx, edx |
- | |
2619 | jz .start_aligned |
- | |
2620 | call extfsReadFileBlock |
- | |
2621 | jc .error |
- | |
2622 | mov eax, [ebp+EXTFS.bytesPerBlock] |
- | |
2623 | sub eax, edx |
- | |
2624 | cmp eax, ecx |
- | |
2625 | jbe @f |
- | |
2626 | mov eax, ecx |
- | |
2627 | @@: |
- | |
2628 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
2563 | push ecx |
2629 | push edi ecx |
- | |
2630 | mov ecx, eax |
2564 | add ecx, 3 |
2631 | mov edi, ebx |
2565 | shr ecx, 2 |
2632 | add edi, edx |
2566 | mov esi, eax |
2633 | xor eax, eax |
2567 | mov edi, eax |
2634 | mov edx, ecx |
2568 | xor eax, eax |
2635 | rep stosb |
- | |
2636 | pop ecx edi |
- | |
2637 | mov eax, edi |
- | |
2638 | call extfsWriteFileBlock |
- | |
2639 | jc .error |
- | |
2640 | sub ecx, edx |
- | |
2641 | jz .done |
- | |
2642 | inc edi |
- | |
2643 | .start_aligned: |
- | |
2644 | mov eax, ecx |
- | |
2645 | mov ecx, [ebp+EXTFS.bytesPerBlock] |
- | |
2646 | dec eax |
- | |
2647 | xor edx, edx |
- | |
2648 | div ecx |
2569 | rep stosd |
2649 | inc eax |
2570 | pop ecx edx |
2650 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
- | |
- | 2571 | push esi |
|
2651 | push eax edi |
2572 | call ext_WriteFile.erase |
2652 | mov edi, ebx |
- | |
2653 | xor eax, eax |
2573 | call kernel_free |
2654 | rep stosb |
- | |
2655 | pop edi ecx |
- | |
2656 | @@: |
- | |
2657 | mov eax, edi |
2574 | xor eax, eax |
2658 | call extfsWriteFileBlock |
2575 | ret |
2659 | jc .error |
2576 | |
2660 | inc edi |
2577 | @@: |
2661 | loop @b |
2578 | call extfsTruncateFile |
2662 | .done: |
2579 | .done: |
2663 | xor eax, eax |
- | |
2664 | .error: |
2580 | xor eax, eax |
2665 | xchg eax, [esp] |
- | |
2666 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2581 | .error: |
2667 | call writeInode |
2582 | xchg eax, [esp] |
2668 | jnc @f |
2583 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2669 | mov [esp], eax |
2584 | call writeInode |
2670 | @@: |
2585 | add [esp], eax |
2671 | call writeSuperblock |
2586 | call writeSuperblock |
2672 | mov esi, [ebp+PARTITION.Disk] |
2587 | mov esi, [ebp+PARTITION.Disk] |
2673 | call disk_sync |
2588 | call disk_sync |
2674 | mov eax, [esp] |
2589 | pop eax |