Rev 465 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 465 | Rev 495 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | $Revision: 465 $ |
1 | $Revision: 495 $ |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | 3 | ;; ;; |
|
- | 4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
|
- | 5 | ;; Distributed under terms of the GNU General Public License ;; |
|
3 | ;; ;; |
6 | ;; ;; |
4 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
- | |
5 | ;; Distributed under terms of the GNU General Public License ;; |
- | |
6 | ;; ;; |
- | |
7 | ;; FAT32.INC ;; |
7 | ;; FAT32.INC ;; |
8 | ;; ;; |
8 | ;; ;; |
9 | ;; FAT16/32 functions for KolibriOS ;; |
9 | ;; FAT16/32 functions for KolibriOS ;; |
10 | ;; ;; |
10 | ;; ;; |
11 | ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; |
11 | ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; |
Line 67... | Line 67... | ||
67 | PUSHAD_ESI equ [esp+4] |
67 | PUSHAD_ESI equ [esp+4] |
68 | PUSHAD_EDI equ [esp+0] |
68 | PUSHAD_EDI equ [esp+0] |
Line 69... | Line 69... | ||
69 | 69 | ||
70 | uglobal |
70 | uglobal |
71 | align 4 |
- | |
72 | cluster dd 0 ; used by file_write,makedir,append |
71 | align 4 |
73 | partition_count dd 0 ; partitions found by set_FAT32_variables |
72 | partition_count dd 0 ; partitions found by set_FAT32_variables |
74 | longname_sec1 dd 0 ; used by analyze_directory to save 2 previous |
73 | longname_sec1 dd 0 ; used by analyze_directory to save 2 previous |
Line 75... | Line 74... | ||
75 | longname_sec2 dd 0 ; directory sectors for delete long filename |
74 | longname_sec2 dd 0 ; directory sectors for delete long filename |
Line 81... | Line 80... | ||
81 | cluster_tmp dd 0 ; used by analyze_directory |
80 | cluster_tmp dd 0 ; used by analyze_directory |
82 | ; and analyze_directory_to_write |
81 | ; and analyze_directory_to_write |
Line 83... | Line 82... | ||
83 | 82 | ||
Line 84... | Line -... | ||
84 | file_size dd 0 ; used by file_read |
- | |
85 | - | ||
86 | sector_tmp dd 0 ; used by rename,append,file_write |
- | |
87 | entry_pos dd 0 ; used by rename,append,file_write |
- | |
88 | - | ||
89 | old_filesize dd 0 ; used by append |
- | |
90 | new_filepos dd 0 ; used by append |
- | |
91 | bytes2write dd 0 ; used by append |
83 | file_size dd 0 ; used by file_read |
92 | 84 | ||
Line 93... | Line 85... | ||
93 | cache_search_start dd 0 ; used by find_empty_slot |
85 | cache_search_start dd 0 ; used by find_empty_slot |
94 | endg |
86 | endg |
Line 104... | Line 96... | ||
104 | buffer: times 512 db 0 |
96 | buffer: times 512 db 0 |
105 | fsinfo_buffer: times 512 db 0 |
97 | fsinfo_buffer: times 512 db 0 |
106 | endg |
98 | endg |
Line 107... | Line 99... | ||
107 | 99 | ||
108 | uglobal |
- | |
109 | dir_entry: times 32 db 0 |
- | |
110 | - | ||
111 | startpath: times 255 db 0 |
- | |
112 | 100 | uglobal |
|
113 | fat16_root db 0 ; flag for fat16 rootdir |
101 | fat16_root db 0 ; flag for fat16 rootdir |
114 | fat_change db 0 ; 1=fat has changed |
- | |
115 | 102 | fat_change db 0 ; 1=fat has changed |
|
Line 116... | Line 103... | ||
116 | endg |
103 | endg |
Line 117... | Line 104... | ||
117 | 104 | ||
Line 468... | Line 455... | ||
468 | pop edi edi esi edx ecx ; first edi will remove ebx |
455 | pop edi edi esi edx ecx ; first edi will remove ebx |
469 | clc ; file found |
456 | clc ; file found |
470 | ret |
457 | ret |
Line 471... | Line -... | ||
471 | - | ||
472 | - | ||
473 | analyze_directory_to_write: |
- | |
474 | ;----------------------------------------------------------- |
- | |
475 | ; input : EAX = first cluster of the directory |
- | |
476 | ; output : IF CARRY=0 EAX = sector where the empty pos is found |
- | |
477 | ; EBX = pointer in buffer |
- | |
478 | ; [buffer .. buffer+511] |
- | |
479 | ; ECX,EDX,ESI,EDI not changed |
- | |
480 | ; IF CARRY=1 disk full or fat corrupted |
- | |
481 | ; Note : if cluster=0 it's changed to read rootdir |
- | |
482 | ;----------------------------------------------------------- |
- | |
483 | push ecx edx edi |
- | |
484 | - | ||
485 | adw_new_cluster: |
- | |
486 | mov [cluster_tmp],eax |
- | |
487 | mov [fat16_root],0 |
- | |
488 | cmp eax,[LAST_CLUSTER] |
- | |
489 | ja adw_not_found ; too big cluster number, something is wrong |
- | |
490 | cmp eax,2 |
- | |
491 | jnb adw_data_cluster |
- | |
492 | - | ||
493 | mov eax,[ROOT_CLUSTER] ; if cluster < 2 then read rootdir |
- | |
494 | cmp [fs_type],16 |
- | |
495 | jne adw_data_cluster |
- | |
496 | mov eax,[ROOT_START] |
- | |
497 | mov edx,[ROOT_SECTORS] |
- | |
498 | mov [fat16_root],1 ; flag for fat16 rootdir |
- | |
499 | jmp adw_new_sector |
- | |
500 | - | ||
501 | adw_data_cluster: |
- | |
502 | sub eax,2 |
- | |
503 | mov edx,[SECTORS_PER_CLUSTER] |
- | |
504 | imul eax,edx |
- | |
505 | add eax,[DATA_START] |
- | |
506 | - | ||
507 | adw_new_sector: |
- | |
508 | mov ebx,buffer |
- | |
509 | call hd_read |
- | |
510 | cmp [hd_error],0 |
- | |
511 | jne adw_not_found |
- | |
512 | - | ||
513 | mov ecx,512/32 ; count of dir entrys per sector = 16 |
- | |
514 | - | ||
515 | adw_analyze: |
- | |
516 | cmp byte [ebx],0x00 ; is free entry? |
- | |
517 | je adw_found ; yes |
- | |
518 | cmp byte [ebx],0xe5 ; is deleted entry? |
- | |
519 | je adw_found ; yes |
- | |
520 | add ebx,32 ; position of next dir entry |
- | |
521 | dec ecx |
- | |
522 | jnz adw_analyze |
- | |
523 | - | ||
524 | inc eax ; next sector |
- | |
525 | dec edx |
- | |
526 | jne adw_new_sector |
- | |
527 | cmp [fat16_root],1 ; end of fat16 rootdir |
- | |
528 | je adw_not_found |
- | |
529 | - | ||
530 | mov eax,[cluster_tmp] |
- | |
531 | call get_FAT ; get next cluster |
- | |
532 | cmp [hd_error],0 |
- | |
533 | jne adw_not_found |
- | |
534 | - | ||
535 | cmp eax,2 ; incorrect fat chain? |
- | |
536 | jb adw_not_found ; yes |
- | |
537 | cmp eax,[fatRESERVED] ; is it end of directory? |
- | |
538 | jb adw_new_cluster ; no. analyse it |
- | |
539 | - | ||
540 | mov eax,2 ; this block of code add a new cluster |
- | |
541 | call get_free_FAT ; for the directory because the directory |
- | |
542 | jc adw_not_found ; is full |
- | |
543 | - | ||
544 | mov edx,[fatEND] ; new end for directory |
- | |
545 | call set_FAT |
- | |
546 | cmp [hd_error],0 |
- | |
547 | jne adw_not_found |
- | |
548 | - | ||
549 | push eax ; save new cluster |
- | |
550 | mov edx,eax |
- | |
551 | mov eax,[cluster_tmp] ; change last cluster to point new cluster |
- | |
552 | call set_FAT |
- | |
553 | cmp [hd_error],0 |
- | |
554 | jne adw_not_found_1 |
- | |
555 | - | ||
556 | mov ecx,-1 ; remove 1 cluster from free disk space |
- | |
557 | call add_disk_free_space |
- | |
558 | cmp [hd_error],0 |
- | |
559 | jne adw_not_found_1 |
- | |
560 | - | ||
561 | mov ecx,512/4 |
- | |
562 | xor eax,eax |
- | |
563 | mov edi,buffer |
- | |
564 | cld |
- | |
565 | rep stosd ; clear new directory cluster |
- | |
566 | pop eax |
- | |
567 | - | ||
568 | sub eax,2 |
- | |
569 | mov ecx,[SECTORS_PER_CLUSTER] |
- | |
570 | imul eax,ecx |
- | |
571 | add eax,[DATA_START] |
- | |
572 | mov ebx,buffer |
- | |
573 | push eax ; save sector number |
- | |
574 | - | ||
575 | adw_set_empty_directory: |
- | |
576 | call hd_write |
- | |
577 | cmp [hd_error],0 |
- | |
578 | jne adw_not_found_1 |
- | |
579 | - | ||
580 | inc eax ; next sector |
- | |
581 | dec ecx |
- | |
582 | jnz adw_set_empty_directory |
- | |
583 | - | ||
584 | pop eax |
- | |
585 | - | ||
586 | adw_found: |
- | |
587 | pop edi edx ecx |
- | |
588 | clc ; free space found |
- | |
589 | ret |
- | |
590 | adw_not_found_1: |
- | |
591 | add esp,4 |
- | |
592 | adw_not_found: |
- | |
593 | pop edi edx ecx |
- | |
594 | stc ; free space not found |
- | |
595 | ret |
- | |
596 | 458 | ||
597 | 459 | ||
598 | get_data_cluster: |
460 | get_data_cluster: |
599 | ;----------------------------------------------------------- |
461 | ;----------------------------------------------------------- |
600 | ; input : EAX = cluster |
462 | ; input : EAX = cluster |
Line 658... | Line 520... | ||
658 | pop ecx eax |
520 | pop ecx eax |
659 | stc |
521 | stc |
660 | ret |
522 | ret |
Line 661... | Line -... | ||
661 | - | ||
662 | - | ||
663 | set_data_cluster: |
- | |
664 | ;----------------------------------------------------------- |
- | |
665 | ; input : EAX = cluster |
- | |
666 | ; EBX = pointer to buffer |
- | |
667 | ; output : if CARRY=0 ok |
- | |
668 | ; if CARRY=1 cluster out of range |
- | |
669 | ;----------------------------------------------------------- |
- | |
670 | push eax ebx edx |
- | |
671 | - | ||
672 | cmp eax,[LAST_CLUSTER] |
- | |
673 | ja sdc_error ; too big cluster number, something is wrong |
- | |
674 | sub eax,2 |
- | |
675 | jb sdc_error ; don't allow rootdir write |
- | |
676 | - | ||
677 | mov edx,[SECTORS_PER_CLUSTER] |
- | |
678 | imul eax,edx |
- | |
679 | add eax,[DATA_START] |
- | |
680 | - | ||
681 | sdc_write: |
- | |
682 | call hd_write |
- | |
683 | cmp [hd_error],0 |
- | |
684 | jne sdc_error |
- | |
685 | - | ||
686 | add ebx,512 ; update pointer |
- | |
687 | inc eax |
- | |
688 | dec edx |
- | |
689 | jnz sdc_write |
- | |
690 | pop edx ebx eax |
- | |
691 | clc |
- | |
692 | ret |
- | |
693 | - | ||
694 | sdc_error: |
- | |
695 | pop edx ebx eax |
- | |
696 | stc |
- | |
697 | ret |
- | |
698 | 523 | ||
699 | 524 | ||
700 | get_cluster_of_a_path: |
525 | get_cluster_of_a_path: |
701 | ;--------------------------------------------------------- |
526 | ;--------------------------------------------------------- |
702 | ; input : EBX = pointer to a path string |
527 | ; input : EBX = pointer to a path string |
Line 853... | Line 678... | ||
853 | 678 | ||
854 | add_dfs_no: |
679 | add_dfs_no: |
Line 855... | Line -... | ||
855 | ret |
- | |
856 | - | ||
857 | - | ||
858 | file_write: |
- | |
859 | ;-------------------------------------------------------------------------- |
- | |
860 | ; INPUT : user-reg register-in-this meaning symbol-in-this-routine |
- | |
861 | ; |
- | |
862 | ; EAX EDI system call to write / |
- | |
863 | ; EBX EAX (PAR0) pointer to file-name PAR0 |
- | |
864 | ; EDX ECX (PAR1) pointer to buffer PAR1 |
- | |
865 | ; ECX EBX (PAR2) file size PAR2 |
- | |
866 | ; ESI EDX (PAR3) pointer to path PAR3 |
- | |
867 | ; |
- | |
868 | ; output : eax = 0 - ok |
- | |
869 | ; 3 - unknown FS |
- | |
870 | ; 5 - file not found |
- | |
871 | ; 8 - disk full |
- | |
872 | ; 10 - access denied |
- | |
873 | ;-------------------------------------------------------------------------- |
- | |
874 | cmp [fs_type], 16 |
- | |
875 | jz fat_ok_for_writing |
- | |
876 | cmp [fs_type], 32 |
- | |
877 | jz fat_ok_for_writing |
- | |
878 | push ERROR_UNKNOWN_FS |
- | |
879 | pop eax |
- | |
880 | ret |
- | |
881 | - | ||
882 | fat_ok_for_writing: |
- | |
883 | ; call reserve_hd1 |
- | |
884 | - | ||
885 | pushad |
- | |
886 | - | ||
887 | xor edi,edi ; don't allow directory remove |
- | |
888 | call file_delete ; try to delete the file first |
- | |
889 | cmp [hd_error],0 |
- | |
890 | jne exit_write_access_1 |
- | |
891 | - | ||
892 | test eax,eax |
- | |
893 | jz old_deleted ; deleted ok |
- | |
894 | cmp eax,ERROR_FILE_NOT_FOUND |
- | |
895 | jnz exit_write_access ; it exist but can't delete |
- | |
896 | - | ||
897 | old_deleted: |
- | |
898 | mov ebx,PUSHAD_EDX |
- | |
899 | call get_cluster_of_a_path |
- | |
900 | jnc found_directory_for_writing |
- | |
901 | cmp [hd_error],0 |
- | |
902 | jne exit_write_access |
- | |
903 | - | ||
904 | exit_writing_with_error: |
- | |
905 | popad |
- | |
906 | call update_disk ; write all of cache and fat to hd |
- | |
907 | cmp [hd_error],0 |
- | |
908 | jne exit_write_access_2 |
- | |
909 | - | ||
910 | mov [hd1_status],0 |
- | |
911 | mov eax,ERROR_FILE_NOT_FOUND |
- | |
912 | ret |
- | |
913 | - | ||
914 | exit_writing_disk_full_clear: |
- | |
915 | cmp [hd_error],0 |
- | |
916 | jne exit_write_access_1 |
- | |
917 | mov eax,[sector_tmp] |
- | |
918 | mov ebx,buffer |
- | |
919 | call hd_read ; read directory sector |
- | |
920 | cmp [hd_error],0 |
- | |
921 | jne exit_write_access_1 |
- | |
922 | - | ||
923 | mov edx,[entry_pos] |
- | |
924 | mov byte [edx],0xe5 ; mark as deleted |
- | |
925 | call hd_write |
- | |
926 | cmp [hd_error],0 |
- | |
927 | jne exit_write_access_1 |
- | |
928 | - | ||
929 | mov eax,[edx+20-2] ; FAT entry |
- | |
930 | mov ax,[edx+26] |
- | |
931 | and eax,[fatMASK] |
- | |
932 | call clear_cluster_chain |
- | |
933 | - | ||
934 | exit_writing_disk_full: |
- | |
935 | cmp [hd_error],0 |
- | |
936 | jne exit_write_access_1 |
- | |
937 | popad |
- | |
938 | call update_disk ; write all of cache and fat to hd |
- | |
939 | cmp [hd_error],0 |
- | |
940 | jne exit_write_access_2 |
- | |
941 | mov [hd1_status],0 |
- | |
942 | mov eax,ERROR_DISK_FULL |
- | |
943 | ret |
- | |
944 | - | ||
945 | exit_write_access: |
- | |
946 | popad |
- | |
947 | call update_disk ; write all of cache and fat to hd |
- | |
948 | mov [hd1_status],0 |
- | |
949 | mov eax,ERROR_ACCESS_DENIED |
- | |
950 | ret |
- | |
951 | - | ||
952 | exit_write_access_1: |
- | |
953 | popad |
- | |
954 | exit_write_access_2: |
- | |
955 | mov [hd1_status],0 |
- | |
956 | mov eax,ERROR_ACCESS_DENIED |
- | |
957 | ret |
- | |
958 | - | ||
959 | found_directory_for_writing: |
- | |
960 | call analyze_directory_to_write |
- | |
961 | jc exit_writing_disk_full |
- | |
962 | - | ||
963 | mov [sector_tmp],eax |
- | |
964 | mov [entry_pos],ebx |
- | |
965 | push eax ; save directory sector |
- | |
966 | mov eax,2 |
- | |
967 | call get_free_FAT |
- | |
968 | mov [cluster],eax ; first free cluster |
- | |
969 | pop eax |
- | |
970 | jc exit_writing_disk_full |
- | |
971 | - | ||
972 | mov esi,PUSHAD_EAX ; file name |
- | |
973 | mov edi,ebx ; pointer in buffer |
- | |
974 | mov ecx,11 |
- | |
975 | cld |
- | |
976 | rep movsb |
- | |
977 | - | ||
978 | mov esi,PUSHAD_EBX ; file size (bytes left) |
- | |
979 | mov [ebx+28],esi ; file size |
- | |
980 | mov ecx,[cluster] |
- | |
981 | mov [ebx+26],cx ; 16 bits low of cluster |
- | |
982 | shr ecx,16 |
- | |
983 | mov [ebx+20],cx ; 16 bits high of cluster (=0 fat16) |
- | |
984 | mov byte [ebx+11],0x20 ; attribute = archive |
- | |
985 | - | ||
986 | call set_current_time_for_entry |
- | |
987 | - | ||
988 | mov ebx,buffer ; save the directory name,length,cluster |
- | |
989 | call hd_write |
- | |
990 | cmp [hd_error],0 |
- | |
991 | jne exit_write_access_1 |
- | |
992 | - | ||
993 | imul edi,[SECTORS_PER_CLUSTER],512 ; edi = cluster size in bytes |
- | |
994 | xor ecx,ecx ; cluster count |
- | |
995 | mov ebx,PUSHAD_ECX ; ebx = buffer |
- | |
996 | - | ||
997 | hd_new_block_write: |
- | |
998 | - | ||
999 | mov eax,[cluster] ; eax = block |
- | |
1000 | call set_data_cluster |
- | |
1001 | cmp [hd_error],0 |
- | |
1002 | jne exit_write_access_1 |
- | |
1003 | - | ||
1004 | sub esi,edi ; sub wrote bytes |
- | |
1005 | jbe file_saved_OK ; end if all done |
- | |
1006 | add ebx,edi ; update buffer position |
- | |
1007 | - | ||
1008 | inc eax |
- | |
1009 | call get_free_FAT ; next free in FAT |
- | |
1010 | jc exit_writing_disk_full_clear |
- | |
1011 | - | ||
1012 | mov edx,eax |
- | |
1013 | xchg eax,[cluster] ; get old cluster and save new cluster |
- | |
1014 | call set_FAT ; add it in cluster chain |
- | |
1015 | cmp [hd_error],0 |
- | |
1016 | jne exit_write_access_1 |
- | |
1017 | - | ||
1018 | dec ecx ; update cluster count |
- | |
1019 | jmp hd_new_block_write |
- | |
1020 | - | ||
1021 | file_saved_OK: |
- | |
1022 | - | ||
1023 | mov edx,[fatEND] ; new end for cluster chain |
- | |
1024 | call set_FAT |
- | |
1025 | cmp [hd_error],0 |
- | |
1026 | jne exit_write_access_1 |
- | |
1027 | - | ||
1028 | dec ecx ; update cluster count |
- | |
1029 | - | ||
1030 | call add_disk_free_space ; remove clusters from free disk space |
- | |
1031 | cmp [hd_error],0 |
- | |
1032 | jne exit_write_access_1 |
- | |
1033 | - | ||
1034 | popad |
- | |
1035 | call update_disk ; write all of cache and fat to hd |
- | |
1036 | cmp [hd_error],0 |
- | |
1037 | jne exit_write_access_2 |
- | |
1038 | mov [hd1_status],0 |
- | |
1039 | xor eax,eax |
- | |
1040 | ret |
680 | ret |
1041 | 681 | ||
1042 | 682 | ||
1043 | file_read: |
683 | file_read: |
1044 | ;-------------------------------------------------------------------------- |
684 | ;-------------------------------------------------------------------------- |
Line 1207... | Line 847... | ||
1207 | dir_size_ret: |
847 | dir_size_ret: |
1208 | pop edx |
848 | pop edx |
1209 | ret |
849 | ret |
Line 1210... | Line -... | ||
1210 | - | ||
1211 | - | ||
1212 | file_delete: |
- | |
1213 | ;----------------------------------------------------- |
- | |
1214 | ; input : eax = file/directory name |
- | |
1215 | ; edx = path |
- | |
1216 | ; edi = 1 - allow directory remove else don't remove directory |
- | |
1217 | ; output : eax = 0 - ok |
- | |
1218 | ; 3 - unknown FS |
- | |
1219 | ; 5 - file not found |
- | |
1220 | ; 10 - access denied |
- | |
1221 | ;----------------------------------------------------- |
- | |
1222 | cmp [fs_type], 16 |
- | |
1223 | jz file_del_fat_ok |
- | |
1224 | cmp [fs_type], 32 |
- | |
1225 | jz file_del_fat_ok |
- | |
1226 | push ERROR_UNKNOWN_FS |
- | |
1227 | pop eax |
- | |
1228 | ret |
- | |
1229 | - | ||
1230 | file_del_fat_ok: |
- | |
1231 | pushad |
- | |
1232 | - | ||
1233 | mov ebx,edx |
- | |
1234 | call get_cluster_of_a_path |
- | |
1235 | jc file_to_delete_not_found |
- | |
1236 | - | ||
1237 | mov ebx,PUSHAD_EAX ; file/directory name |
- | |
1238 | call analyze_directory |
- | |
1239 | jc file_to_delete_not_found |
- | |
1240 | - | ||
1241 | test byte [ebx+11],0x10 ; is it directory? |
- | |
1242 | jnz delete_no_access |
- | |
1243 | - | ||
1244 | delete_notdir: |
- | |
1245 | call delete_entry_name |
- | |
1246 | cmp [hd_error],0 |
- | |
1247 | jne delete_no_access |
- | |
1248 | - | ||
1249 | mov eax,ecx ; first cluster of file |
- | |
1250 | call clear_cluster_chain |
- | |
1251 | cmp [hd_error],0 |
- | |
1252 | jne delete_no_access |
- | |
1253 | - | ||
1254 | popad |
- | |
1255 | xor eax,eax |
- | |
1256 | ret |
- | |
1257 | - | ||
1258 | delete_no_access_1: |
- | |
1259 | add esp,4 |
- | |
1260 | delete_no_access: |
- | |
1261 | popad |
- | |
1262 | mov eax,ERROR_ACCESS_DENIED |
- | |
1263 | ret |
- | |
1264 | - | ||
1265 | file_to_delete_not_found: |
- | |
1266 | cmp [hd_error],0 |
- | |
1267 | jne delete_no_access |
- | |
1268 | popad |
- | |
1269 | mov eax,ERROR_FILE_NOT_FOUND |
- | |
1270 | ret |
- | |
1271 | 850 | ||
1272 | 851 | ||
1273 | clear_cluster_chain: |
852 | clear_cluster_chain: |
1274 | ;----------------------------------------------------- |
853 | ;----------------------------------------------------- |
1275 | ; input : eax = first cluster |
854 | ; input : eax = first cluster |
Line 1299... | Line 878... | ||
1299 | access_denied_01: |
878 | access_denied_01: |
1300 | pop edx ecx eax |
879 | pop edx ecx eax |
1301 | ret |
880 | ret |
Line 1302... | Line -... | ||
1302 | - | ||
1303 | - | ||
1304 | delete_entry_name: |
- | |
1305 | ;----------------------------------------------------- |
- | |
1306 | ; input : eax = directory sector |
- | |
1307 | ; ebx = directory pointer in buffer |
- | |
1308 | ; longname_sec = 2 previous directory sectors |
- | |
1309 | ; output : ecx = first cluster |
- | |
1310 | ; change : eax,ebx,edx |
- | |
1311 | ;----------------------------------------------------- |
- | |
1312 | mov byte [ebx],0xe5 |
- | |
1313 | mov ecx,[ebx+20-2] ; first cluster of file |
- | |
1314 | mov cx,[ebx+26] ; 0 length files start cluster = 0 |
- | |
1315 | and ecx,[fatMASK] |
- | |
1316 | - | ||
1317 | delete_empty: |
- | |
1318 | sub ebx,32 |
- | |
1319 | cmp ebx,buffer |
- | |
1320 | jnb delete_test_long |
- | |
1321 | - | ||
1322 | mov ebx,buffer |
- | |
1323 | call hd_write ; write directory sector back |
- | |
1324 | cmp [hd_error],0 |
- | |
1325 | jne delete_name_end |
- | |
1326 | - | ||
1327 | xor eax,eax |
- | |
1328 | xchg eax,[longname_sec2] |
- | |
1329 | xchg eax,[longname_sec1] |
- | |
1330 | test eax,eax ; is there previous directory sector? |
- | |
1331 | jz delete_name_end ; no |
- | |
1332 | - | ||
1333 | mov ebx,buffer |
- | |
1334 | call hd_read ; read previous sector |
- | |
1335 | cmp [hd_error],0 |
- | |
1336 | jne delete_name_end |
- | |
1337 | - | ||
1338 | mov ebx,buffer+0x1e0 ; start from last entry |
- | |
1339 | - | ||
1340 | delete_test_long: |
- | |
1341 | mov dh,[ebx+11] ; file attribute |
- | |
1342 | and dh,0xf |
- | |
1343 | cmp dh,0xf |
- | |
1344 | jne delete_write_buffer |
- | |
1345 | - | ||
1346 | cmp byte [ebx],0x40 ; end of long dir entry? |
- | |
1347 | mov byte [ebx],0xe5 |
- | |
1348 | jb delete_empty |
- | |
1349 | - | ||
1350 | delete_write_buffer: |
- | |
1351 | mov ebx,buffer |
- | |
1352 | call hd_write ; write directory sector back |
- | |
1353 | - | ||
1354 | delete_name_end: |
- | |
1355 | ret |
- | |
1356 | 881 | ||
1357 | 882 | ||
1358 | get_hd_info: |
883 | get_hd_info: |
1359 | ;----------------------------------------------------------- |
884 | ;----------------------------------------------------------- |
1360 | ; output : eax = 0 - ok |
885 | ; output : eax = 0 - ok |
Line 1426... | Line 951... | ||
1426 | 951 | ||
1427 | call write_cache |
952 | call write_cache |
1428 | update_disk_acces_denied: |
953 | update_disk_acces_denied: |
Line 1429... | Line -... | ||
1429 | ret |
- | |
1430 | - | ||
1431 | read_hd_file: |
- | |
1432 | ;----------------------------------------------------------------- |
- | |
1433 | ; |
- | |
1434 | ; Converting old reading function for hd-application start. |
- | |
1435 | ; |
- | |
1436 | ; IN: |
- | |
1437 | ; |
- | |
1438 | ; eax - pointer to file (0 = read only first sector of drive: eg 'label') |
- | |
1439 | ; ebx - file lenght |
- | |
1440 | ; ecx - start 512 byte block number |
- | |
1441 | ; edx - number of blocks to read |
- | |
1442 | ; esi - pointer to return/work area (atleast 20 000 bytes) |
- | |
1443 | ; |
- | |
1444 | ; For new read function |
- | |
1445 | ; |
- | |
1446 | ; EAX (PAR0) pointer to file-name |
- | |
1447 | ; ECX (PAR1) pointer to buffer |
- | |
1448 | ; EBX (PAR2) vt file blocks to read |
- | |
1449 | ; EDX (PAR3) pointer to path |
- | |
1450 | ; ESI vt first 512 block to read |
- | |
1451 | ; EDI if 0 - return root |
- | |
1452 | ;-------------------------------------------------------------------------- |
- | |
1453 | - | ||
1454 | push ecx esi edi |
- | |
1455 | mov esi,eax |
- | |
1456 | mov edi,startpath |
- | |
1457 | mov ecx,250 |
- | |
1458 | cld |
- | |
1459 | rep movsb |
- | |
1460 | pop edi esi ecx |
- | |
1461 | - | ||
1462 | mov eax,startpath |
- | |
1463 | mov [eax+ebx-12],byte 0 |
- | |
1464 | - | ||
1465 | push eax ebx ecx edx esi |
- | |
1466 | - | ||
1467 | pop ecx ; pointer to buffer |
- | |
1468 | add ecx,1024 |
- | |
1469 | pop ebx ; number of blocks to read |
- | |
1470 | pop esi ; first block to read |
- | |
1471 | dec esi |
- | |
1472 | pop eax ; file length |
- | |
1473 | pop edx ; pointer to path |
- | |
1474 | - | ||
1475 | mov edi,12 |
- | |
1476 | lea eax,[eax+edx-12+1] |
- | |
1477 | call file_read |
- | |
Line 1478... | Line 954... | ||
1478 | 954 | ret |
|
1479 | ret |
955 | |
1480 | 956 | ||
1481 | ; \begin{diamond} |
957 | ; \begin{diamond} |