Rev 6558 | Rev 6643 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6558 | Rev 6575 | ||
---|---|---|---|
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: 6558 $ |
8 | $Revision: 6575 $ |
9 | 9 | ||
10 | ; EXT external functions |
10 | ; EXT external functions |
11 | ; in: |
11 | ; in: |
Line 284... | Line 284... | ||
284 | jmp free |
284 | jmp free |
Line 285... | Line 285... | ||
285 | 285 | ||
286 | extfsWriteBlock: |
286 | extfsWriteBlock: |
287 | push fs_write64_sys |
287 | push fs_write64_sys |
288 | jmp @f |
- | |
289 | ; in: |
288 | jmp @f |
290 | ; eax = block number |
- | |
291 | ; ebx -> buffer |
289 | ; in: eax = block number, ebx -> buffer |
292 | extfsReadBlock: |
290 | extfsReadBlock: |
293 | push fs_read64_sys |
291 | push fs_read64_sys |
294 | @@: |
292 | @@: |
295 | push ecx edx |
293 | push ecx edx |
Line 351... | Line 349... | ||
351 | ; eax = block/inode number |
349 | ; eax = block/inode number |
352 | push ebx edx |
350 | push ebx edx |
353 | sub eax, [ebp+EXTFS.superblock.firstGroupBlock] |
351 | sub eax, [ebp+EXTFS.superblock.firstGroupBlock] |
354 | xor edx, edx |
352 | xor edx, edx |
355 | div [ebp+EXTFS.superblock.blocksPerGroup] |
353 | div [ebp+EXTFS.superblock.blocksPerGroup] |
356 | push eax edx |
354 | push edx eax |
357 | call extfsReadDescriptor |
355 | call extfsReadDescriptor |
358 | jc .fail |
356 | jc .fail2 |
359 | inc [eax+BGDESCR.blocksFree+ecx*2] |
357 | inc [eax+BGDESCR.blocksFree+ecx*2] |
360 | mov eax, [eax+BGDESCR.blockBitmap+ecx*4] |
358 | mov edx, [eax+BGDESCR.blockBitmap+ecx*4] |
- | 359 | pop eax |
|
361 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
360 | call extfsWriteDescriptor |
- | 361 | jc .fail |
|
362 | mov edx, eax |
362 | mov eax, edx |
- | 363 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
|
363 | call extfsReadBlock |
364 | call extfsReadBlock |
364 | jc .fail |
365 | jc .fail |
365 | pop eax |
366 | pop eax |
366 | push edx |
367 | push edx |
367 | mov edx, eax |
368 | mov edx, eax |
368 | and edx, 31 |
369 | and edx, 31 |
369 | shr eax, 5 |
370 | shr eax, 5 |
370 | shl eax, 2 |
371 | shl eax, 2 |
371 | add eax, [ebp+EXTFS.mainBlockBuffer] |
372 | add eax, [ebp+EXTFS.tempBlockBuffer] |
372 | btr [eax], edx |
373 | btr [eax], edx |
373 | pop eax |
374 | pop eax |
374 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
375 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
375 | call extfsWriteBlock |
376 | call extfsWriteBlock |
376 | jc @f |
377 | jc @f |
377 | inc [ebp+EXTFS.superblock.blocksFree+ecx*4] |
378 | inc [ebp+EXTFS.superblock.blocksFree+ecx*4] |
378 | pop eax |
- | |
379 | call extfsWriteDescriptor |
- | |
380 | .ret: |
379 | @@: |
381 | pop edx ebx |
380 | pop edx ebx |
382 | ret |
381 | ret |
Line 383... | Line 382... | ||
383 | 382 | ||
384 | .fail: |
383 | .fail2: |
385 | pop eax |
384 | pop eax |
386 | @@: |
385 | .fail: |
387 | pop eax |
386 | pop eax |
388 | movi eax, ERROR_DEVICE |
387 | movi eax, ERROR_DEVICE |
Line 389... | Line 388... | ||
389 | jmp .ret |
388 | jmp @b |
390 | 389 | ||
391 | freeDoublyIndirectBlock: |
390 | freeDoublyIndirectBlock: |
392 | ; in: eax = doubly-indirect block number |
391 | ; in: eax = doubly-indirect block number |
393 | ; out: eax=1 -> finished |
392 | ; out: eax=1 -> finished |
394 | test eax, eax |
393 | test eax, eax |
395 | jz .complete |
394 | jz .complete |
396 | push eax |
395 | push eax |
397 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
396 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
398 | call extfsReadBlock |
397 | call extfsReadBlock |
399 | pop eax |
398 | pop eax |
400 | jc .ret |
399 | jc .ret |
Line 416... | Line 415... | ||
416 | 415 | ||
417 | .complete: |
416 | .complete: |
418 | inc eax |
417 | inc eax |
Line 419... | Line 418... | ||
419 | ret |
418 | ret |
420 | 419 | ||
421 | inodeBlockAlloc: |
420 | inodeBlockAlloc: ; also erases |
422 | ; in: esi -> inode, eax = inode number |
- | |
423 | ; out: ebx = block number |
- | |
424 | call extfsBlockAlloc |
- | |
425 | jc @f |
- | |
426 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
- | |
427 | add [esi+INODE.sectorsUsed], eax |
- | |
428 | xor eax, eax |
- | |
429 | @@: |
- | |
430 | ret |
- | |
431 | - | ||
432 | extfsBlockAlloc: ; also erases |
- | |
433 | ; in: eax = inode number |
421 | ; in: esi -> inode, eax = inode number |
434 | ; out: ebx = block number |
422 | ; out: ebx = block number |
435 | xor ebx, ebx |
423 | xor ebx, ebx |
436 | call extfsResourceAlloc |
424 | call extfsResourceAlloc |
437 | jc @f |
425 | jc @f |
438 | push ebx ecx edi |
426 | push ebx ecx edi |
439 | mov ecx, [ebp+EXTFS.dwordsPerBlock] |
427 | mov ecx, [ebp+EXTFS.dwordsPerBlock] |
440 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
428 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
441 | mov ebx, edi |
429 | mov ebx, edi |
442 | xor eax, eax |
430 | xor eax, eax |
443 | rep stosd |
431 | rep stosd |
444 | pop edi ecx |
432 | pop edi ecx eax |
445 | mov eax, [esp] |
433 | push eax |
- | 434 | call extfsWriteBlock |
|
- | 435 | pop ebx |
|
- | 436 | jc @f |
|
- | 437 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
|
446 | call extfsWriteBlock |
438 | add [esi+INODE.sectorsUsed], eax |
447 | pop ebx |
439 | xor eax, eax |
Line 448... | Line 440... | ||
448 | @@: |
440 | @@: |
449 | ret |
441 | ret |
Line 462... | Line 454... | ||
462 | mov esi, .forward ; search forward, then backward |
454 | mov esi, .forward ; search forward, then backward |
463 | .test_block_group: |
455 | .test_block_group: |
464 | call extfsReadDescriptor |
456 | call extfsReadDescriptor |
465 | jc .fail |
457 | jc .fail |
466 | dec [eax+BGDESCR.blocksFree+ebx*2] |
458 | dec [eax+BGDESCR.blocksFree+ebx*2] |
- | 459 | js .next |
|
467 | mov eax, [eax+BGDESCR.blockBitmap+ebx*4] |
460 | mov edx, [eax+BGDESCR.blockBitmap+ebx*4] |
- | 461 | mov eax, [esp] |
|
- | 462 | call extfsWriteDescriptor |
|
- | 463 | jc .fail |
|
468 | push ebx |
464 | push ebx |
469 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
465 | mov eax, edx |
470 | mov edx, eax |
466 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
471 | mov edi, ebx |
467 | mov edi, ebx |
472 | call extfsReadBlock |
468 | call extfsReadBlock |
473 | pop ebx |
469 | pop ebx |
474 | jc .fail |
470 | jc .fail |
475 | mov ecx, [ebp+EXTFS.superblock.blocksPerGroup+ebx*8] |
471 | mov ecx, [ebp+EXTFS.superblock.blocksPerGroup+ebx*8] |
Line 481... | Line 477... | ||
481 | sub edi, 4 |
477 | sub edi, 4 |
482 | mov eax, [edi] |
478 | mov eax, [edi] |
483 | not eax |
479 | not eax |
484 | bsf eax, eax |
480 | bsf eax, eax |
485 | bts [edi], eax |
481 | bts [edi], eax |
486 | sub edi, [ebp+EXTFS.mainBlockBuffer] |
482 | sub edi, [ebp+EXTFS.tempBlockBuffer] |
487 | shl edi, 3 |
483 | shl edi, 3 |
488 | add eax, edi |
484 | add eax, edi |
489 | mov ecx, eax |
485 | mov ecx, eax |
490 | mov eax, edx |
486 | mov eax, edx |
491 | push ebx |
487 | push ebx |
492 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
488 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
493 | call extfsWriteBlock |
489 | call extfsWriteBlock |
494 | pop ebx |
490 | pop ebx |
495 | jc .fail |
491 | jc .fail |
496 | mov eax, [esp] |
492 | pop eax |
497 | mul [ebp+EXTFS.superblock.blocksPerGroup+ebx*8] |
493 | mul [ebp+EXTFS.superblock.blocksPerGroup+ebx*8] |
498 | add eax, ecx |
494 | add eax, ecx |
499 | dec [ebp+EXTFS.superblock.blocksFree+ebx*4] |
495 | dec [ebp+EXTFS.superblock.blocksFree+ebx*4] |
500 | mov ebx, eax |
496 | mov ebx, eax |
501 | pop eax |
497 | pop eax |
502 | add esp, 4 |
498 | xor eax, eax |
503 | call extfsWriteDescriptor |
- | |
504 | @@: |
499 | @@: |
505 | pop edi esi edx ecx |
500 | pop edi esi edx ecx |
506 | ret |
501 | ret |
Line 507... | Line 502... | ||
507 | 502 | ||
Line 534... | Line 529... | ||
534 | jc .fail |
529 | jc .fail |
535 | mov eax, [esp] |
530 | mov eax, [esp] |
536 | jmp .test_block_group |
531 | jmp .test_block_group |
Line 537... | Line 532... | ||
537 | 532 | ||
538 | extfsGetFileBlock: |
- | |
539 | ; in: |
533 | extfsGetFileBlock: |
540 | ; ecx = file block number |
- | |
541 | ; esi -> inode |
- | |
542 | ; out: |
534 | ; in: esi -> inode, ecx = file block number |
543 | ; ecx = block number |
535 | ; out: ecx = block number |
544 | test [esi+INODE.featureFlags], EXTENTS_USED |
536 | test [esi+INODE.featureFlags], EXTENTS_USED |
545 | jz .listTreeSearch |
537 | jz .listTreeSearch |
546 | pushad |
538 | pushad |
547 | add esi, INODE.blockNumbers |
539 | add esi, INODE.blockNumbers |
Line 699... | Line 691... | ||
699 | jc .ret |
691 | jc .ret |
700 | mov [esi+INODE.tripleAddress], ebx |
692 | mov [esi+INODE.tripleAddress], ebx |
701 | mov eax, ebx |
693 | mov eax, ebx |
702 | @@: |
694 | @@: |
703 | push eax |
695 | push eax |
704 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
696 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
705 | call extfsReadBlock |
697 | call extfsReadBlock |
706 | jc .fail_alloc_4 |
698 | jc .fail_alloc_4 |
707 | xor edx, edx |
699 | xor edx, edx |
708 | mov eax, ecx |
700 | mov eax, ecx |
709 | div [ebp+EXTFS.dwordsPerBranch] |
701 | div [ebp+EXTFS.dwordsPerBranch] |
Line 715... | Line 707... | ||
715 | mov eax, [esp+4] |
707 | mov eax, [esp+4] |
716 | call inodeBlockAlloc |
708 | call inodeBlockAlloc |
717 | jc .fail_alloc_4 |
709 | jc .fail_alloc_4 |
718 | mov [ecx], ebx |
710 | mov [ecx], ebx |
719 | mov eax, [esp] |
711 | mov eax, [esp] |
720 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
712 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
721 | call extfsWriteBlock |
713 | call extfsWriteBlock |
722 | jc .fail_alloc_4 |
714 | jc .fail_alloc_4 |
723 | mov eax, [ecx] |
715 | mov eax, [ecx] |
724 | @@: |
716 | @@: |
725 | mov [esp], eax |
717 | mov [esp], eax |
Line 737... | Line 729... | ||
737 | jc .ret |
729 | jc .ret |
738 | mov [esi+INODE.doubleAddress], ebx |
730 | mov [esi+INODE.doubleAddress], ebx |
739 | mov eax, ebx |
731 | mov eax, ebx |
740 | .double_indirect_present: |
732 | .double_indirect_present: |
741 | push eax |
733 | push eax |
742 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
734 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
743 | call extfsReadBlock |
735 | call extfsReadBlock |
744 | jc .fail_alloc_4 |
736 | jc .fail_alloc_4 |
745 | mov eax, ecx |
737 | mov eax, ecx |
746 | @@: |
738 | @@: |
747 | xor edx, edx |
739 | xor edx, edx |
Line 755... | Line 747... | ||
755 | mov eax, [esp+8] |
747 | mov eax, [esp+8] |
756 | call inodeBlockAlloc |
748 | call inodeBlockAlloc |
757 | jc .fail_alloc_8 |
749 | jc .fail_alloc_8 |
758 | mov [ecx], ebx |
750 | mov [ecx], ebx |
759 | mov eax, [esp+4] |
751 | mov eax, [esp+4] |
760 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
752 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
761 | call extfsWriteBlock |
753 | call extfsWriteBlock |
762 | jc .fail_alloc_8 |
754 | jc .fail_alloc_8 |
763 | @@: |
755 | @@: |
764 | mov eax, [ecx] |
756 | mov eax, [ecx] |
765 | push eax |
757 | push eax |
Line 779... | Line 771... | ||
779 | jc .ret |
771 | jc .ret |
780 | mov [esi+INODE.addressBlock], ebx |
772 | mov [esi+INODE.addressBlock], ebx |
781 | mov eax, ebx |
773 | mov eax, ebx |
782 | @@: |
774 | @@: |
783 | push eax |
775 | push eax |
784 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
776 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
785 | call extfsReadBlock |
777 | call extfsReadBlock |
786 | jc .fail_alloc_4 |
778 | jc .fail_alloc_4 |
787 | mov [ebx+ecx*4], edi |
779 | mov [ebx+ecx*4], edi |
788 | pop eax |
780 | pop eax |
789 | call extfsWriteBlock |
781 | call extfsWriteBlock |
Line 802... | Line 794... | ||
802 | pop ebx |
794 | pop ebx |
803 | .fail_alloc_4: |
795 | .fail_alloc_4: |
804 | pop ebx |
796 | pop ebx |
805 | jmp .ret |
797 | jmp .ret |
Line 806... | Line 798... | ||
806 | 798 | ||
807 | extfsEraseFileBlock: ; also allocates |
799 | extfsFileBlockAlloc: |
- | 800 | ; in: |
|
808 | ; in: |
801 | ; esi -> inode |
809 | ; edx = inode number |
802 | ; edx = inode number |
810 | ; eax = file block number |
803 | ; eax = file block number |
811 | ; [ebp+EXTFS.inodeBuffer] = inode |
804 | ; out: |
812 | push ebx ecx edx edi esi |
805 | ; edi = allocated block number |
813 | mov edi, eax |
806 | push ebx ecx |
814 | mov ecx, eax |
- | |
815 | lea esi, [ebp+EXTFS.inodeBuffer] |
- | |
816 | call extfsGetFileBlock |
- | |
817 | jc @f |
- | |
818 | test ecx, ecx |
- | |
819 | jz .allocate |
- | |
820 | mov edx, ecx |
- | |
821 | mov ecx, [ebp+EXTFS.bytesPerBlock] |
- | |
822 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
- | |
823 | xor eax, eax |
- | |
824 | rep stosb |
807 | mov ecx, eax |
825 | mov eax, edx |
- | |
826 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
- | |
827 | call extfsWriteBlock |
- | |
828 | jmp @f |
- | |
829 | - | ||
830 | .allocate: |
808 | mov eax, edx |
831 | mov eax, edx |
809 | xor ebx, ebx |
832 | call extfsBlockAlloc |
810 | call extfsResourceAlloc |
833 | jc @f |
- | |
834 | mov ecx, edi |
811 | jc @f |
835 | mov edi, ebx |
- | |
836 | lea esi, [ebp+EXTFS.inodeBuffer] |
812 | mov edi, ebx |
837 | call extfsSetFileBlock |
813 | call extfsSetFileBlock |
838 | jc @f |
814 | jc @f |
839 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
815 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
840 | add [esi+INODE.sectorsUsed], eax |
816 | add [esi+INODE.sectorsUsed], eax |
841 | xor eax, eax |
817 | xor eax, eax |
842 | @@: |
- | |
843 | pop esi edi edx ecx ebx |
- | |
844 | ret |
- | |
845 | - | ||
846 | extfsFreeFileBlock: |
- | |
847 | ; in: |
- | |
848 | ; eax = file block number |
- | |
849 | ; [ebp+EXTFS.inodeBuffer] = inode |
- | |
850 | push ebx ecx edx edi esi |
- | |
851 | mov edi, eax |
818 | @@: |
852 | mov ecx, eax |
- | |
853 | lea esi, [ebp+EXTFS.inodeBuffer] |
- | |
854 | call extfsGetFileBlock |
- | |
855 | jc @f |
- | |
856 | test ecx, ecx |
- | |
857 | jz @f |
- | |
858 | mov eax, ecx |
- | |
859 | xor ecx, ecx |
- | |
860 | call extfsResourceFree |
- | |
861 | mov ecx, edi |
- | |
862 | xor edi, edi |
- | |
863 | movi edx, ROOT_INODE |
- | |
864 | lea esi, [ebp+EXTFS.inodeBuffer] |
- | |
865 | call extfsSetFileBlock |
- | |
866 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
- | |
867 | sub [esi+INODE.sectorsUsed], eax |
- | |
868 | xor eax, eax |
- | |
869 | @@: |
- | |
870 | pop esi edi edx ecx ebx |
819 | pop ecx ebx |
Line 871... | Line 820... | ||
871 | ret |
820 | ret |
872 | 821 | ||
873 | extfsReadFileBlock: |
822 | extfsReadFileBlock: |
Line 896... | Line 845... | ||
896 | jmp .ret |
845 | jmp .ret |
Line 897... | Line 846... | ||
897 | 846 | ||
898 | extfsWriteFileBlock: |
847 | extfsWriteFileBlock: |
899 | ; in: |
848 | ; in: |
- | 849 | ; eax = file block number |
|
900 | ; eax = file block number |
850 | ; ebx -> data |
901 | ; [ebp+EXTFS.inodeBuffer] = inode |
- | |
902 | ; [ebp+EXTFS.mainBlockBuffer] -> block to write |
851 | ; [ebp+EXTFS.inodeBuffer] = inode |
903 | push ebx ecx edx esi |
852 | push ecx edx esi |
904 | mov ecx, eax |
853 | mov ecx, eax |
905 | lea esi, [ebp+EXTFS.inodeBuffer] |
854 | lea esi, [ebp+EXTFS.inodeBuffer] |
906 | call extfsGetFileBlock |
855 | call extfsGetFileBlock |
907 | jc @f |
856 | jc @f |
908 | test ecx, ecx |
857 | test ecx, ecx |
909 | jz @b |
858 | jz @b |
910 | mov eax, ecx |
- | |
911 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
859 | mov eax, ecx |
912 | call extfsWriteBlock |
860 | call extfsWriteBlock |
913 | @@: |
861 | @@: |
914 | pop esi edx ecx ebx |
862 | pop esi edx ecx |
Line 915... | Line 863... | ||
915 | ret |
863 | ret |
916 | 864 | ||
917 | getInodeLocation: |
- | |
918 | ; in: eax = inode number |
- | |
919 | ; out: |
865 | getInodeLocation: |
920 | ; ebx = inode sector |
866 | ; in: eax = inode number |
921 | ; edx = offset in sector |
867 | ; out: ebx = inode sector, edx = offset in sector |
922 | dec eax |
868 | dec eax |
923 | xor edx, edx |
869 | xor edx, edx |
924 | div [ebp+EXTFS.superblock.inodesPerGroup] |
870 | div [ebp+EXTFS.superblock.inodesPerGroup] |
Line 944... | Line 890... | ||
944 | xor eax, eax |
890 | xor eax, eax |
945 | @@: |
891 | @@: |
946 | ret |
892 | ret |
Line 947... | Line 893... | ||
947 | 893 | ||
948 | writeInode: |
- | |
949 | ; in: |
894 | writeInode: |
950 | ; eax = inode number |
- | |
951 | ; ebx -> inode data |
895 | ; in: eax = inode number, ebx -> inode data |
952 | push edx edi esi ecx ebx eax |
896 | push edx edi esi ecx ebx eax |
953 | mov edi, ebx |
897 | mov edi, ebx |
954 | call fsGetTime |
898 | call fsGetTime |
955 | add eax, 978307200 |
899 | add eax, 978307200 |
Line 978... | Line 922... | ||
978 | movi eax, ERROR_DEVICE |
922 | movi eax, ERROR_DEVICE |
979 | stc |
923 | stc |
980 | jmp .ret |
924 | jmp .ret |
Line 981... | Line 925... | ||
981 | 925 | ||
982 | readInode: |
- | |
983 | ; in: |
- | |
984 | ; eax = inode number |
926 | readInode: |
985 | ; ebx -> inode buffer |
927 | ; in: eax = inode number, ebx -> inode buffer |
986 | push edx edi esi ecx ebx |
928 | push edx edi esi ecx ebx |
987 | mov edi, ebx |
929 | mov edi, ebx |
988 | call getInodeLocation |
930 | call getInodeLocation |
989 | jc @f |
931 | jc @f |
Line 1005... | Line 947... | ||
1005 | ; in: |
947 | ; in: |
1006 | ; [ebp+EXTFS.inodeBuffer] = inode |
948 | ; [ebp+EXTFS.inodeBuffer] = inode |
1007 | ; eax = inode number |
949 | ; eax = inode number |
1008 | ; ecx = new size |
950 | ; ecx = new size |
1009 | push ebx ecx edx esi edi eax |
951 | push ebx ecx edx esi edi eax |
1010 | lea ebx, [ebp+EXTFS.inodeBuffer] |
952 | lea esi, [ebp+EXTFS.inodeBuffer] |
1011 | cmp [ebx+INODE.fileSize], ecx |
- | |
1012 | jnc .ret |
- | |
1013 | mov eax, [ebx+INODE.fileSize] |
953 | mov eax, [esi+INODE.fileSize] |
1014 | push eax |
- | |
1015 | sub ecx, eax |
954 | sub ecx, eax |
- | 955 | jna .ret |
|
- | 956 | mov ebx, eax |
|
1016 | xor edx, edx |
957 | xor edx, edx |
1017 | div [ebp+EXTFS.bytesPerBlock] |
958 | div [ebp+EXTFS.bytesPerBlock] |
1018 | test edx, edx |
959 | test edx, edx |
1019 | jz .start_aligned |
960 | jz .start_aligned |
1020 | mov esi, [ebp+EXTFS.bytesPerBlock] |
961 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1021 | sub esi, edx |
962 | sub eax, edx |
1022 | cmp esi, ecx |
963 | cmp eax, ecx |
1023 | jbe @f |
964 | jbe @f |
1024 | mov esi, ecx |
965 | mov eax, ecx |
1025 | @@: ; clear esi trailing bytes in block number eax |
- | |
1026 | push eax |
- | |
1027 | call extfsReadFileBlock |
- | |
1028 | pop edi |
966 | @@: |
1029 | jc .error_inode_size |
- | |
1030 | push edi ecx |
- | |
1031 | xor eax, eax |
- | |
1032 | mov ecx, esi |
- | |
1033 | mov edi, ebx |
- | |
1034 | add edi, edx |
967 | add ebx, eax |
1035 | rep stosb |
- | |
1036 | pop ecx eax |
- | |
1037 | call extfsWriteFileBlock |
- | |
1038 | jc .error_inode_size |
- | |
1039 | add [esp], esi |
- | |
1040 | sub ecx, esi |
968 | sub ecx, eax |
1041 | jz .done |
969 | jz .done |
1042 | .start_aligned: |
970 | .start_aligned: |
1043 | cmp ecx, [ebp+EXTFS.bytesPerBlock] |
- | |
1044 | jb @f |
- | |
1045 | mov eax, [esp] |
971 | mov eax, ebx |
1046 | xor edx, edx |
972 | xor edx, edx |
1047 | div [ebp+EXTFS.bytesPerBlock] |
973 | div [ebp+EXTFS.bytesPerBlock] |
1048 | mov edx, [esp+4] |
974 | mov edx, [esp] |
1049 | call extfsEraseFileBlock |
975 | call extfsFileBlockAlloc |
1050 | jc .error_inode_size |
976 | jc .error |
1051 | mov eax, [ebp+EXTFS.bytesPerBlock] |
977 | mov eax, [ebp+EXTFS.bytesPerBlock] |
- | 978 | add ebx, eax |
|
1052 | sub ecx, eax |
979 | sub ecx, eax |
1053 | add [esp], eax |
- | |
1054 | jmp .start_aligned |
980 | ja .start_aligned |
1055 | - | ||
1056 | @@: ; handle the remaining bytes |
- | |
1057 | test ecx, ecx |
- | |
1058 | jz .done |
- | |
1059 | mov eax, [esp] |
- | |
1060 | xor edx, edx |
- | |
1061 | div [ebp+EXTFS.bytesPerBlock] |
- | |
1062 | mov edx, [esp+4] |
- | |
1063 | call extfsEraseFileBlock |
- | |
1064 | jc .error_inode_size |
- | |
1065 | add [esp], ecx |
981 | add ebx, ecx |
1066 | .done: |
982 | .done: |
1067 | xor eax, eax |
983 | xor eax, eax |
1068 | .error_inode_size: |
984 | .error: |
1069 | lea ebx, [ebp+EXTFS.inodeBuffer] |
- | |
1070 | pop [ebx+INODE.fileSize] |
985 | mov [esi+INODE.fileSize], ebx |
1071 | .ret: |
986 | .ret: |
1072 | pop edi edi esi edx ecx ebx |
987 | pop edi edi esi edx ecx ebx |
1073 | ret |
988 | ret |
Line 1074... | Line 989... | ||
1074 | 989 | ||
1075 | extfsTruncateFile: |
990 | extfsTruncateFile: |
1076 | ; in: |
991 | ; in: |
1077 | ; [ebp+EXTFS.inodeBuffer] = inode |
992 | ; [ebp+EXTFS.inodeBuffer] = inode |
1078 | ; ecx = new size |
993 | ; ecx = new size |
1079 | push ebx ecx edx esi edi |
994 | push ebx ecx edx esi edi |
1080 | lea ebx, [ebp+EXTFS.inodeBuffer] |
- | |
1081 | cmp ecx, [ebx+INODE.fileSize] |
- | |
1082 | jnc .ret |
995 | lea esi, [ebp+EXTFS.inodeBuffer] |
1083 | mov eax, [ebx+INODE.fileSize] |
- | |
1084 | push eax |
996 | mov eax, [esi+INODE.fileSize] |
1085 | sub ecx, eax |
997 | sub ecx, eax |
1086 | not ecx |
998 | jnc .ret |
- | 999 | neg ecx |
|
1087 | inc ecx |
1000 | mov ebx, eax |
1088 | xor edx, edx |
1001 | xor edx, edx |
1089 | div [ebp+EXTFS.bytesPerBlock] |
1002 | div [ebp+EXTFS.bytesPerBlock] |
1090 | test edx, edx |
- | |
1091 | jz .start_aligned |
- | |
1092 | mov esi, edx |
- | |
1093 | cmp esi, ecx |
1003 | test edx, edx |
1094 | jbe @f |
- | |
1095 | ; if the size to truncate is smaller than the unaligned bytes |
- | |
1096 | ; we're going to clear neccessary bytes from the EOF |
- | |
1097 | push eax |
- | |
1098 | call extfsReadFileBlock |
- | |
1099 | pop edi |
- | |
1100 | jc .error_inode_size |
- | |
1101 | push edi ecx |
- | |
1102 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
- | |
1103 | sub edx, ecx |
- | |
1104 | add edi, edx |
- | |
1105 | xor eax, eax |
- | |
1106 | rep stosb |
- | |
1107 | pop ecx eax |
- | |
1108 | call extfsWriteFileBlock |
- | |
1109 | jc .error_inode_size |
- | |
1110 | sub [esp], ecx |
- | |
1111 | jmp .done |
- | |
1112 | - | ||
1113 | @@: |
- | |
1114 | call extfsFreeFileBlock |
- | |
1115 | sub [esp], esi |
- | |
1116 | sub ecx, esi |
- | |
1117 | jz .done |
1004 | jnz @f |
1118 | .start_aligned: |
1005 | .start_aligned: |
1119 | cmp ecx, [ebp+EXTFS.bytesPerBlock] |
- | |
1120 | jb @f |
- | |
1121 | mov eax, [esp] |
- | |
1122 | xor edx, edx |
- | |
1123 | div [ebp+EXTFS.bytesPerBlock] |
1006 | mov edx, [ebp+EXTFS.bytesPerBlock] |
- | 1007 | dec eax |
|
1124 | dec eax |
1008 | @@: |
1125 | call extfsFreeFileBlock |
1009 | cmp ecx, edx |
1126 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1010 | jc .tail |
1127 | sub ecx, eax |
1011 | push ecx edx |
1128 | sub [esp], eax |
1012 | mov edi, eax |
1129 | jmp .start_aligned |
- | |
1130 | 1013 | mov ecx, eax |
|
- | 1014 | call extfsGetFileBlock |
|
1131 | @@: ; handle the remaining bytes |
1015 | jc .error |
- | 1016 | test ecx, ecx |
|
- | 1017 | jz @f |
|
- | 1018 | mov eax, ecx |
|
- | 1019 | xor ecx, ecx |
|
- | 1020 | call extfsResourceFree |
|
- | 1021 | mov ecx, edi |
|
- | 1022 | xor edi, edi |
|
- | 1023 | movi edx, ROOT_INODE |
|
- | 1024 | call extfsSetFileBlock |
|
- | 1025 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
|
- | 1026 | sub [esi+INODE.sectorsUsed], eax |
|
- | 1027 | @@: |
|
- | 1028 | pop edx ecx |
|
- | 1029 | sub ebx, edx |
|
1132 | test ecx, ecx |
1030 | sub ecx, edx |
1133 | jz .done |
1031 | jz .done |
1134 | mov eax, [esp] |
1032 | mov eax, ebx |
1135 | xor edx, edx |
1033 | xor edx, edx |
1136 | div [ebp+EXTFS.bytesPerBlock] |
- | |
1137 | dec eax |
- | |
1138 | push eax |
1034 | div [ebp+EXTFS.bytesPerBlock] |
1139 | call extfsReadFileBlock |
- | |
- | 1035 | jmp .start_aligned |
|
1140 | pop edi |
1036 | |
1141 | jc .error_inode_size |
- | |
1142 | push edi ecx |
- | |
1143 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
- | |
1144 | mov edx, [ebp+EXTFS.bytesPerBlock] |
1037 | .tail: ; handle the remaining bytes |
1145 | sub edx, ecx |
- | |
1146 | add edi, edx |
- | |
1147 | xor eax, eax |
- | |
1148 | rep stosb |
- | |
1149 | pop ecx eax |
- | |
1150 | call extfsWriteFileBlock |
- | |
1151 | jc .error_inode_size |
- | |
1152 | sub [esp], ecx |
1038 | sub ebx, ecx |
1153 | .done: |
1039 | .done: |
1154 | xor eax, eax |
1040 | xor eax, eax |
1155 | .error_inode_size: |
- | |
1156 | lea ebx, [ebp+EXTFS.inodeBuffer] |
1041 | @@: |
1157 | pop [ebx+INODE.fileSize] |
1042 | mov [esi+INODE.fileSize], ebx |
1158 | .ret: |
1043 | .ret: |
1159 | pop edi esi edx ecx ebx |
1044 | pop edi esi edx ecx ebx |
Line -... | Line 1045... | ||
- | 1045 | ret |
|
- | 1046 | ||
- | 1047 | .error: |
|
- | 1048 | pop edx ecx |
|
- | 1049 | jmp @b |
|
1160 | ret |
1050 | |
1161 | 1051 | ||
1162 | linkInode: |
1052 | linkInode: |
1163 | ; in: |
1053 | ; in: |
1164 | ; eax = inode on which to link |
1054 | ; eax = inode on which to link |
Line 1247... | Line 1137... | ||
1247 | jz .alloc_block |
1137 | jz .alloc_block |
1248 | push ecx |
1138 | push ecx |
1249 | jmp .prepare_block |
1139 | jmp .prepare_block |
Line 1250... | Line 1140... | ||
1250 | 1140 | ||
1251 | .alloc_block: |
1141 | .alloc_block: |
1252 | mov eax, [esp+24] |
- | |
1253 | mov edx, eax |
- | |
1254 | call extfsBlockAlloc |
- | |
1255 | jc .error_get_inode_block |
1142 | mov eax, [esp] |
1256 | mov ecx, [esp] |
- | |
1257 | mov edi, ebx |
1143 | mov edx, [esp+24] |
1258 | call extfsSetFileBlock |
1144 | call extfsFileBlockAlloc |
1259 | jc .error_get_inode_block |
1145 | jc .error_get_inode_block |
1260 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1146 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1261 | add [esi+INODE.fileSize], eax |
- | |
1262 | mov eax, [ebp+EXTFS.sectorsPerBlock] |
- | |
1263 | add [esi+INODE.sectorsUsed], eax |
1147 | add [esi+INODE.fileSize], eax |
1264 | mov eax, [esp+24] |
1148 | mov eax, [esp+24] |
1265 | mov ebx, esi |
1149 | mov ebx, esi |
1266 | call writeInode |
1150 | call writeInode |
1267 | jc .error_get_inode_block |
1151 | jc .error_get_inode_block |
1268 | push edi ; save the block we just allocated |
1152 | push edi ; save the block we just allocated |
1269 | .prepare_block: |
- | |
1270 | mov eax, [esp] |
1153 | .prepare_block: |
1271 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
- | |
1272 | call extfsReadBlock |
- | |
1273 | jc .error_block_read |
- | |
1274 | mov edi, ebx |
1154 | mov edi, [ebp+EXTFS.tempBlockBuffer] |
1275 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1155 | mov eax, [ebp+EXTFS.bytesPerBlock] |
1276 | mov [edi+DIRENTRY.entryLength], ax |
1156 | mov [edi+DIRENTRY.entryLength], ax |
1277 | .found: |
1157 | .found: |
1278 | pop edx ecx ecx ecx ebx esi |
1158 | pop edx ecx ecx ecx ebx esi |
1279 | push ebx |
1159 | push ebx |
1280 | mov [edi], ebx ; save inode |
1160 | mov [edi+DIRENTRY.inodeNumber], ebx |
- | 1161 | sub ecx, 8 |
|
1281 | mov eax, [esp+4] |
1162 | mov word [edi+DIRENTRY.nameLength], cx |
1282 | cmp [ebp+EXTFS.superblock.dynamicVersionFlag], 0 |
1163 | cmp [ebp+EXTFS.superblock.dynamicVersionFlag], 0 |
- | 1164 | je .name |
|
1283 | je .name |
1165 | mov eax, [esp+4] |
1284 | mov [edi+DIRENTRY.fileType], al |
1166 | mov [edi+DIRENTRY.fileType], al |
1285 | .name: |
- | |
1286 | sub ecx, 8 |
- | |
1287 | mov [edi+DIRENTRY.nameLength], cl |
1167 | .name: |
1288 | add edi, 8 |
1168 | add edi, 8 |
1289 | rep movsb |
1169 | rep movsb |
1290 | mov eax, edx |
1170 | mov eax, edx |
1291 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1171 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
Line 2063... | Line 1943... | ||
2063 | cmp eax, 1 |
1943 | cmp eax, 1 |
2064 | je .success |
1944 | je .success |
2065 | mov eax, [edi+INODE.tripleAddress] |
1945 | mov eax, [edi+INODE.tripleAddress] |
2066 | test eax, eax |
1946 | test eax, eax |
2067 | jz .success |
1947 | jz .success |
- | 1948 | xor edx, edx |
|
- | 1949 | mov ecx, eax |
|
- | 1950 | @@: |
|
2068 | push eax |
1951 | mov eax, ecx |
2069 | mov ebx, [ebp+EXTFS.tempBlockBuffer] |
1952 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
2070 | call extfsReadBlock |
1953 | call extfsReadBlock |
2071 | pop ecx |
- | |
2072 | jc .error_stack8_eax |
1954 | jc .error_stack8_eax |
2073 | mov eax, ecx |
- | |
2074 | xor ecx, ecx |
- | |
2075 | call extfsResourceFree |
- | |
2076 | mov edx, ebx |
- | |
2077 | add edx, [ebp+EXTFS.bytesPerBlock] |
- | |
2078 | @@: |
- | |
2079 | mov eax, [ebx] |
1955 | mov eax, [ebx+edx] |
2080 | test eax, eax |
1956 | test eax, eax |
2081 | jz .success |
1957 | jz @f |
2082 | push ebx edx |
1958 | push ecx edx |
2083 | call freeDoublyIndirectBlock |
1959 | call freeDoublyIndirectBlock |
2084 | pop edx ebx |
1960 | pop edx ecx |
2085 | cmp eax, 1 |
1961 | cmp eax, 1 |
2086 | je .success |
1962 | je @f |
2087 | add ebx, 4 |
1963 | add edx, 4 |
2088 | cmp ebx, edx |
1964 | cmp edx, [ebp+EXTFS.bytesPerBlock] |
2089 | jb @b |
1965 | jb @b |
- | 1966 | @@: |
|
- | 1967 | mov eax, ecx |
|
- | 1968 | xor ecx, ecx |
|
- | 1969 | call extfsResourceFree |
|
2090 | .success: ; clear the inode, and add deletion time |
1970 | .success: ; clear the inode, and add deletion time |
2091 | xor eax, eax |
1971 | xor eax, eax |
2092 | movzx ecx, [ebp+EXTFS.superblock.inodeSize] |
1972 | movzx ecx, [ebp+EXTFS.superblock.inodeSize] |
2093 | rep stosb |
1973 | rep stosb |
2094 | lea edi, [ebp+EXTFS.inodeBuffer] |
1974 | lea edi, [ebp+EXTFS.inodeBuffer] |
Line 2308... | Line 2188... | ||
2308 | mov eax, esi |
2188 | mov eax, esi |
2309 | call extfsExtendFile |
2189 | call extfsExtendFile |
2310 | jc .error |
2190 | jc .error |
2311 | mov eax, [ebx+4] |
2191 | mov eax, [ebx+4] |
2312 | mov ecx, [ebx+12] |
2192 | mov ecx, [ebx+12] |
2313 | mov esi, [ebx+16] |
2193 | mov ebx, [ebx+16] |
2314 | push eax |
2194 | push eax |
2315 | xor edx, edx |
2195 | xor edx, edx |
2316 | div [ebp+EXTFS.bytesPerBlock] |
2196 | div [ebp+EXTFS.bytesPerBlock] |
2317 | test edx, edx |
2197 | test edx, edx |
2318 | jz .start_aligned |
2198 | jz .start_aligned |
2319 | mov ebx, [ebp+EXTFS.bytesPerBlock] |
2199 | mov esi, [ebp+EXTFS.bytesPerBlock] |
2320 | sub ebx, edx |
2200 | sub esi, edx |
2321 | cmp ebx, ecx |
2201 | cmp esi, ecx |
2322 | jbe @f |
2202 | jbe @f |
2323 | mov ebx, ecx |
2203 | mov esi, ecx |
2324 | @@: |
2204 | @@: |
2325 | push eax |
2205 | mov edi, eax |
2326 | call extfsReadFileBlock |
2206 | call extfsReadFileBlock |
2327 | pop edi |
- | |
2328 | jc .error_inode_size |
2207 | jc .error_inode_size |
2329 | mov eax, edi |
2208 | mov eax, edi |
2330 | push ecx |
2209 | push ebx ecx |
2331 | mov ecx, ebx |
2210 | mov ecx, esi |
- | 2211 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
|
2332 | mov edi, ebx |
2212 | mov esi, ebx |
- | 2213 | mov ebx, edi |
|
2333 | add edi, edx |
2214 | add edi, edx |
- | 2215 | mov edx, ecx |
|
2334 | rep movsb |
2216 | rep movsb |
2335 | pop ecx |
- | |
2336 | call extfsWriteFileBlock |
2217 | call extfsWriteFileBlock |
- | 2218 | pop ecx ebx |
|
2337 | jc .error_inode_size |
2219 | jc .error_inode_size |
2338 | add [esp], ebx |
2220 | add [esp], edx |
- | 2221 | add ebx, edx |
|
2339 | sub ecx, ebx |
2222 | sub ecx, edx |
2340 | jz .write_inode |
2223 | jz .write_inode |
2341 | .start_aligned: |
2224 | .start_aligned: |
2342 | cmp ecx, [ebp+EXTFS.bytesPerBlock] |
2225 | cmp ecx, [ebp+EXTFS.bytesPerBlock] |
2343 | jb @f |
2226 | jb @f |
2344 | mov eax, [esp] |
2227 | mov eax, [esp] |
2345 | xor edx, edx |
2228 | xor edx, edx |
2346 | div [ebp+EXTFS.bytesPerBlock] |
2229 | div [ebp+EXTFS.bytesPerBlock] |
2347 | mov edx, [esp+4] |
- | |
2348 | push eax |
- | |
2349 | call extfsEraseFileBlock |
- | |
2350 | pop edi |
- | |
2351 | jc .error_inode_size |
- | |
2352 | mov eax, edi |
- | |
2353 | push ecx |
- | |
2354 | mov ecx, [ebp+EXTFS.bytesPerBlock] |
- | |
2355 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
- | |
2356 | rep movsb |
- | |
2357 | pop ecx |
- | |
2358 | call extfsWriteFileBlock |
2230 | call extfsWriteFileBlock |
2359 | jc .error_inode_size |
2231 | jc .error_inode_size |
2360 | mov eax, [ebp+EXTFS.bytesPerBlock] |
2232 | mov eax, [ebp+EXTFS.bytesPerBlock] |
2361 | sub ecx, eax |
2233 | sub ecx, eax |
- | 2234 | add ebx, eax |
|
2362 | add [esp], eax |
2235 | add [esp], eax |
2363 | jmp .start_aligned |
2236 | jmp .start_aligned |
- | 2237 | ||
2364 | @@: ; Handle the remaining bytes. |
2238 | @@: ; handle the remaining bytes |
2365 | test ecx, ecx |
2239 | test ecx, ecx |
2366 | jz .write_inode |
2240 | jz .write_inode |
2367 | mov eax, [esp] |
2241 | mov eax, [esp] |
2368 | xor edx, edx |
2242 | xor edx, edx |
2369 | div [ebp+EXTFS.bytesPerBlock] |
2243 | div [ebp+EXTFS.bytesPerBlock] |
2370 | push eax |
- | |
2371 | call extfsReadFileBlock |
- | |
2372 | pop eax |
- | |
2373 | jnc @f |
- | |
2374 | mov edx, [esp+4] |
- | |
2375 | push eax |
- | |
2376 | call extfsEraseFileBlock |
- | |
2377 | pop edi |
- | |
2378 | jc .error_inode_size |
- | |
2379 | mov eax, edi |
- | |
2380 | @@: |
- | |
2381 | push ecx |
2244 | push ecx |
- | 2245 | mov esi, ebx |
|
2382 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
2246 | mov edi, [ebp+EXTFS.mainBlockBuffer] |
- | 2247 | mov ebx, edi |
|
2383 | rep movsb |
2248 | rep movsb |
2384 | pop ecx |
2249 | pop ecx |
2385 | call extfsWriteFileBlock |
2250 | call extfsWriteFileBlock |
2386 | jc .error_inode_size |
2251 | jc .error_inode_size |
2387 | add [esp], ecx |
- | |
2388 | xor ecx, ecx |
2252 | xor ecx, ecx |
2389 | .error_inode_size: |
2253 | .error_inode_size: |
2390 | mov [esp+12], eax |
2254 | mov [esp+12], eax |
2391 | .write_inode: |
2255 | .write_inode: |
2392 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2256 | lea ebx, [ebp+EXTFS.inodeBuffer] |
Line 2415... | Line 2279... | ||
2415 | ;---------------------------------------------------------------- |
2279 | ;---------------------------------------------------------------- |
2416 | ext_SetFileEnd: |
2280 | ext_SetFileEnd: |
2417 | call extfsWritingInit |
2281 | call extfsWritingInit |
2418 | pushd [ebx+4] |
2282 | pushd [ebx+4] |
2419 | call findInode |
2283 | call findInode |
2420 | pop ecx |
- | |
2421 | jc @f |
2284 | jc .error |
2422 | lea edx, [ebp+EXTFS.inodeBuffer] |
2285 | lea edi, [ebp+EXTFS.inodeBuffer] |
2423 | movi eax, ERROR_ACCESS_DENIED |
2286 | movi eax, ERROR_ACCESS_DENIED |
2424 | cmp [edx+INODE.accessMode], FLAG_FILE |
2287 | cmp [edi+INODE.accessMode], FLAG_FILE |
2425 | jnz @f ; not a file |
2288 | jnz .error ; not a file |
- | 2289 | pop ecx |
|
- | 2290 | push esi |
|
- | 2291 | mov ebx, [edi+INODE.fileSize] |
|
2426 | mov eax, esi |
2292 | mov eax, esi |
2427 | call extfsExtendFile |
2293 | cmp ebx, ecx |
2428 | jc @f |
2294 | jc @f |
2429 | call extfsTruncateFile |
2295 | call extfsTruncateFile |
- | 2296 | jc .error |
|
- | 2297 | jmp .done |
|
- | 2298 | ||
- | 2299 | @@: |
|
- | 2300 | call extfsExtendFile |
|
- | 2301 | jc .error |
|
- | 2302 | sub ecx, ebx |
|
- | 2303 | mov eax, ebx |
|
- | 2304 | xor edx, edx |
|
- | 2305 | div [ebp+EXTFS.bytesPerBlock] |
|
- | 2306 | mov edi, eax |
|
- | 2307 | test edx, edx |
|
- | 2308 | jz .start_aligned |
|
- | 2309 | call extfsReadFileBlock |
|
- | 2310 | jc .error |
|
- | 2311 | mov eax, [ebp+EXTFS.bytesPerBlock] |
|
- | 2312 | sub eax, edx |
|
- | 2313 | cmp eax, ecx |
|
2430 | jc @f |
2314 | jbe @f |
- | 2315 | mov eax, ecx |
|
- | 2316 | @@: |
|
- | 2317 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
|
- | 2318 | push edi ecx |
|
- | 2319 | mov ecx, eax |
|
- | 2320 | mov edi, ebx |
|
- | 2321 | add edi, edx |
|
- | 2322 | xor eax, eax |
|
- | 2323 | mov edx, ecx |
|
- | 2324 | rep stosb |
|
- | 2325 | pop ecx edi |
|
- | 2326 | mov eax, edi |
|
- | 2327 | call extfsWriteFileBlock |
|
- | 2328 | jc .error |
|
- | 2329 | sub ecx, edx |
|
- | 2330 | jz .done |
|
- | 2331 | inc edi |
|
- | 2332 | .start_aligned: |
|
- | 2333 | mov eax, ecx |
|
- | 2334 | mov ecx, [ebp+EXTFS.bytesPerBlock] |
|
- | 2335 | dec eax |
|
- | 2336 | xor edx, edx |
|
- | 2337 | div ecx |
|
- | 2338 | inc eax |
|
- | 2339 | mov ebx, [ebp+EXTFS.mainBlockBuffer] |
|
- | 2340 | push eax edi |
|
- | 2341 | mov edi, ebx |
|
- | 2342 | xor eax, eax |
|
- | 2343 | rep stosb |
|
- | 2344 | pop edi ecx |
|
- | 2345 | @@: |
|
2431 | mov eax, esi |
2346 | mov eax, edi |
- | 2347 | call extfsWriteFileBlock |
|
- | 2348 | jc .error |
|
- | 2349 | inc edi |
|
- | 2350 | loop @b |
|
- | 2351 | .done: |
|
- | 2352 | mov eax, [esp] |
|
2432 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2353 | lea ebx, [ebp+EXTFS.inodeBuffer] |
2433 | call writeInode |
2354 | call writeInode |
2434 | @@: |
- | |
2435 | push eax |
2355 | jc .error |
2436 | call writeSuperblock |
2356 | call writeSuperblock |
2437 | mov esi, [ebp+PARTITION.Disk] |
2357 | mov esi, [ebp+PARTITION.Disk] |
2438 | call disk_sync |
2358 | call disk_sync |
- | 2359 | xor eax, eax |
|
- | 2360 | .error: |
|
- | 2361 | mov [esp], eax |
|
2439 | call ext_unlock |
2362 | call ext_unlock |
2440 | pop eax |
2363 | pop eax |
2441 | ret |
2364 | ret |