From 1ace68286bccb45ce923eb48d474d3b2e1488302 Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Mon, 5 Feb 2007 14:20:36 +0000 Subject: [PATCH] * New sysfunction 70.9, create folder * Deleted obsolete 58.4 (create folder 8.3 on hd) * Updated docs * Bugfixes (file system; core; direct screen access), improvements (sysfn 70.3) * KFar 0.21, full error handling, folder creation (with new kernel) git-svn-id: svn://kolibrios.org@321 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/hd_drv.inc | 32 +- kernel/trunk/blkdev/rd.inc | 78 +++- kernel/trunk/blkdev/rdsave.inc | 2 + kernel/trunk/boot/bootcode.inc | 2 +- kernel/trunk/boot/rdload.inc | 1 - kernel/trunk/const.inc | 1 - kernel/trunk/core/heap.inc | 11 +- kernel/trunk/core/memory.inc | 10 +- kernel/trunk/core/sys32.inc | 2 + kernel/trunk/core/taskman.inc | 6 +- kernel/trunk/detect/sear_par.inc | 16 +- kernel/trunk/docs/sysfuncr.txt | 81 ++-- kernel/trunk/docs/sysfuncs.txt | 83 ++-- kernel/trunk/fs/fat12.inc | 76 +++- kernel/trunk/fs/fat32.inc | 471 +++++--------------- kernel/trunk/fs/fs.inc | 79 +--- kernel/trunk/fs/fs_lfn.inc | 9 +- kernel/trunk/fs/ntfs.inc | 1 + kernel/trunk/fs/part_set.inc | 10 +- kernel/trunk/kernel.asm | 7 +- kernel/trunk/memmap.inc | 1 - programs/fs/kfar/trunk/kfar.asm | 705 +++++++++++++++++++----------- programs/fs/kfar/trunk/viewer.inc | 99 ++++- 23 files changed, 913 insertions(+), 870 deletions(-) diff --git a/kernel/trunk/blkdev/hd_drv.inc b/kernel/trunk/blkdev/hd_drv.inc index 9edc8b3854..83dbc3f063 100755 --- a/kernel/trunk/blkdev/hd_drv.inc +++ b/kernel/trunk/blkdev/hd_drv.inc @@ -75,13 +75,11 @@ align 4 hd_read_pio: push eax edx - call disable_ide_int - call wait_for_hd_idle cmp [hd_error],0 jne hd_read_error -; cli + cli xor eax,eax mov edx,[hdbase] inc edx @@ -107,14 +105,14 @@ hd_read_pio: inc edx mov al,20h out dx,al ; ATACommand регистр команд -; sti + sti call wait_for_sector_buffer cmp [hd_error],0 jne hd_read_error -; cli + cli push edi shl edi,9 add edi,0x600000+65536 @@ -123,9 +121,7 @@ hd_read_pio: cld rep insw pop edi -; sti - - call enable_ide_int + sti pop edx eax ret @@ -420,8 +416,8 @@ endg hd_timeout_error: - call clear_hd_cache - call clear_application_table_status +; call clear_hd_cache +; call clear_application_table_status mov esi,hd_timeout_str call sys_msg_board_str ; jmp $ @@ -431,8 +427,8 @@ hd_timeout_error: hd_read_error: - call clear_hd_cache - call clear_application_table_status +; call clear_hd_cache +; call clear_application_table_status mov esi,hd_read_str call sys_msg_board_str pop edx eax @@ -440,23 +436,23 @@ hd_read_error: hd_write_error: - call clear_hd_cache - call clear_application_table_status +; call clear_hd_cache +; call clear_application_table_status mov esi,hd_write_str call sys_msg_board_str ret hd_write_error_dma: - call clear_hd_cache - call clear_application_table_status +; call clear_hd_cache +; call clear_application_table_status mov esi, hd_write_str call sys_msg_board_str pop esi ret hd_lba_error: - call clear_hd_cache - call clear_application_table_status +; call clear_hd_cache +; call clear_application_table_status mov esi,hd_lba_str call sys_msg_board_str jmp LBA_read_ret diff --git a/kernel/trunk/blkdev/rd.inc b/kernel/trunk/blkdev/rd.inc index 8b6c84ea65..1f873e780a 100644 --- a/kernel/trunk/blkdev/rd.inc +++ b/kernel/trunk/blkdev/rd.inc @@ -1466,12 +1466,13 @@ fat_gen_short_name: ;---------------------------------------------------------------- ; -; fs_RamdiskRewrite - LFN variant for writing sys floppy +; fs_RamdiskRewrite - LFN variant for writing ramdisk +; fs_RamdiskCreateFolder - create folder on ramdisk ; -; esi points to filename +; esi points to file/folder name ; ebx ignored (reserved) -; ecx number of bytes to write, 0+ -; edx mem location to data +; ecx number of bytes to write, 0+ (ignored for folders) +; edx mem location to data (ignored for folders) ; ; ret ebx = number of written bytes ; eax = 0 ok read or other = errormsg @@ -1482,7 +1483,13 @@ fat_gen_short_name: xor ebx, ebx ret +fs_RamdiskCreateFolder: + mov al, 1 ; create folder + jmp fs_RamdiskRewrite.common + fs_RamdiskRewrite: + xor eax, eax ; create file +.common: cmp byte [esi], 0 jz @b pushad @@ -1537,8 +1544,24 @@ fs_RamdiskRewrite: .common1: call fat_find_lfn jc .notfound -; found; must not be directory +; found test byte [edi+11], 10h + jz .exists_file +; found directory; if we are creating directory, return OK, +; if we are creating file, say "access denied" + add esp, 20 + popad + test al, al + mov eax, ERROR_ACCESS_DENIED + jz @f + mov al, 0 +@@: + xor ebx, ebx + ret +.exists_file: +; found file; if we are creating directory, return "access denied", +; if we are creating file, delete existing file and continue + cmp byte [esp+20+28], 0 jz @f add esp, 20 popad @@ -1556,7 +1579,7 @@ fs_RamdiskRewrite: @@: cmp eax, 0xFF8 jae .done1 - lea edi, [0x280000 + eax*2] ; position in FAT + lea edi, [RAMDISK_FAT + eax*2] ; position in FAT xor eax, eax xchg ax, [edi] jmp @b @@ -1748,6 +1771,12 @@ fs_RamdiskRewrite: and word [edi+20], 0 ; high word of cluster and word [edi+26], 0 ; low word of cluster - to be filled and dword [edi+28], 0 ; file size - to be filled + cmp byte [esp+20+28], 0 + jz .doit +; create directory + mov byte [edi+11], 10h ; attributes: folder + mov ecx, 32*2 + mov edx, edi .doit: push edx push ecx @@ -1756,7 +1785,7 @@ fs_RamdiskRewrite: push edi jecxz .done mov ecx, 2849 - mov edi, 0x280000 + mov edi, RAMDISK_FAT .write_loop: ; allocate new cluster xor eax, eax @@ -1764,7 +1793,7 @@ fs_RamdiskRewrite: jnz .disk_full2 dec edi dec edi - lea eax, [edi-0x280000] + lea eax, [edi-(RAMDISK_FAT)] shr eax, 1 ; eax = cluster mov word [edi], 0xFFF ; mark as last cluster xchg edi, [esp] @@ -1773,8 +1802,11 @@ fs_RamdiskRewrite: push edi inc ecx ; write data + cmp byte [esp+16+20+28], 0 + jnz .writedir shl eax, 9 - add eax, 0x100000+31*512 + add eax, RAMDISK+31*512 +.writefile: mov ebx, edx xchg eax, ebx push ecx @@ -1809,6 +1841,34 @@ fs_RamdiskRewrite: push ERROR_DISK_FULL pop eax ret +.writedir: + mov edi, eax + shl edi, 9 + add edi, RAMDISK+31*512 + mov esi, edx + mov ecx, 32/4 + push ecx + rep movsd + mov dword [edi-32], '. ' + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + mov word [edi-32+26], ax + mov esi, edx + pop ecx + rep movsd + mov dword [edi-32], '.. ' + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + mov eax, [esp+16+8] + mov word [edi-32+26], ax + pop edi edi ecx edx + add esp, 20 + popad + xor eax, eax + xor ebx, ebx + ret .read_symbol: or ax, -1 diff --git a/kernel/trunk/blkdev/rdsave.inc b/kernel/trunk/blkdev/rdsave.inc index 8fe849c5f3..abae7a055e 100644 --- a/kernel/trunk/blkdev/rdsave.inc +++ b/kernel/trunk/blkdev/rdsave.inc @@ -16,10 +16,12 @@ sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only) add edx,ecx img_save_hd_3: call reserve_hd1 + call reserve_hd_channel call restorefatchain ; restore FAT !!! mov eax,image_save mov ebx,1440*1024 ; size 1440 Kb mov ecx,0x100000 ; address of image call file_write + call free_hd_channel mov [esp+36],eax ret diff --git a/kernel/trunk/boot/bootcode.inc b/kernel/trunk/boot/bootcode.inc index b70cde2fe9..5e6ea01214 100644 --- a/kernel/trunk/boot/bootcode.inc +++ b/kernel/trunk/boot/bootcode.inc @@ -91,7 +91,7 @@ app_data_l: graph_data_l: - dw 0x3ff + dw 0x7ff dw 0x0000 db 0x00 dw 11010000b *256 +11110010b diff --git a/kernel/trunk/boot/rdload.inc b/kernel/trunk/boot/rdload.inc index cc98ec19ce..7182855426 100644 --- a/kernel/trunk/boot/rdload.inc +++ b/kernel/trunk/boot/rdload.inc @@ -65,7 +65,6 @@ jmp yes_sys_on_hd search_and_read_image: -; mov [0xfe10],dword 0 ; entries in hd cache call set_FAT32_variables mov edx, bootpath call read_image diff --git a/kernel/trunk/const.inc b/kernel/trunk/const.inc index be73d6594c..3f5fba17ac 100644 --- a/kernel/trunk/const.inc +++ b/kernel/trunk/const.inc @@ -175,7 +175,6 @@ X_UNDER equ OS_BASE+0x000FB4A Y_UNDER equ OS_BASE+0x000FB4C ScreenBPP equ OS_BASE+0x000FBF1 MOUSE_BUFF_COUNT equ OS_BASE+0x000FCFF -HD_CACHE_ENT equ OS_BASE+0x000FE10 LFBAddress equ OS_BASE+0x000FE80 MEM_AMOUNT equ OS_BASE+0x000FE8C ;LFBSize equ OS_BASE+0x02f9050 diff --git a/kernel/trunk/core/heap.inc b/kernel/trunk/core/heap.inc index 264ca67525..dd9cfe807b 100644 --- a/kernel/trunk/core/heap.inc +++ b/kernel/trunk/core/heap.inc @@ -366,7 +366,7 @@ proc alloc_kernel_space stdcall, size:dword endp align 4 -proc free_kernel_space stdcall, base:dword +proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword mov ebx, heap_mutex call wait_mutex ;ebx @@ -461,7 +461,7 @@ proc free_kernel_space stdcall, base:dword .m_eq: xor eax, eax mov [heap_mutex], eax - not eax + dec eax ret .insert: remove_from_used esi @@ -480,7 +480,7 @@ proc free_kernel_space stdcall, base:dword mov [esi+block_flags],FREE_BLOCK xor eax, eax mov [heap_mutex], eax - not eax + dec eax ret .fail: xor eax, eax @@ -557,6 +557,7 @@ endp align 4 proc kernel_free stdcall, base:dword + push ebx esi mov ebx, heap_mutex call wait_mutex ;ebx @@ -577,13 +578,17 @@ proc kernel_free stdcall, base:dword and [heap_mutex], 0 + push ecx mov ecx, [esi+block_size]; shr ecx, 12 call release_pages ;eax, ecx + pop ecx stdcall free_kernel_space, [base] + pop esi ebx ret .fail: and [heap_mutex], 0 + pop esi ebx ret endp diff --git a/kernel/trunk/core/memory.inc b/kernel/trunk/core/memory.inc index 779e766213..3e29f1fe52 100644 --- a/kernel/trunk/core/memory.inc +++ b/kernel/trunk/core/memory.inc @@ -231,6 +231,7 @@ endp align 4 proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword + push ebx mov eax, [phis_addr] and eax, not 0xFFF or eax, [flags] @@ -239,6 +240,7 @@ proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword mov [pages_tab+ebx*4], eax mov eax, [lin_addr] invlpg [eax] + pop ebx ret endp @@ -289,8 +291,8 @@ commit_pages: ;not implemented align 4 release_pages: - - push ebp + + pushad mov ebx, pg_data.pg_mutex call wait_mutex ;ebx @@ -329,11 +331,12 @@ release_pages: jnz @B mov [pg_data.pages_free], ebp and [pg_data.pg_mutex],0 - pop ebp + popad ret align 4 proc map_page_table stdcall, lin_addr:dword, phis_addr:dword + push ebx mov ebx, [lin_addr] shr ebx, 22 mov eax, [phis_addr] @@ -344,6 +347,7 @@ proc map_page_table stdcall, lin_addr:dword, phis_addr:dword shr eax, 10 add eax, pages_tab invlpg [eax] + pop ebx ret endp diff --git a/kernel/trunk/core/sys32.inc b/kernel/trunk/core/sys32.inc index 6a0534a3af..d5cecfc60f 100644 --- a/kernel/trunk/core/sys32.inc +++ b/kernel/trunk/core/sys32.inc @@ -768,10 +768,12 @@ fpu_ok_1: mov esi, [esi+0x3000+TASKDATA.pid] cmp [hd1_status], esi jnz @f + call free_hd_channel mov [hd1_status], 0 @@: cmp [cd_status], esi jnz @f + call free_cd_channel mov [cd_status], 0 @@: cmp [flp_status], esi diff --git a/kernel/trunk/core/taskman.inc b/kernel/trunk/core/taskman.inc index e65439f641..a236eb7240 100644 --- a/kernel/trunk/core/taskman.inc +++ b/kernel/trunk/core/taskman.inc @@ -208,6 +208,7 @@ end if .err_file: xor eax, eax mov [application_table_status],eax + mov eax, ecx ret endp @@ -951,15 +952,16 @@ align 4 wait_mutex: push eax push ebx +.do_wait: cmp dword [ebx],0 je .get_lock call change_task - jmp wait_mutex + jmp .do_wait .get_lock: mov eax, 1 xchg eax, [ebx] test eax, eax - jnz wait_mutex + jnz .do_wait pop ebx pop eax ret diff --git a/kernel/trunk/detect/sear_par.inc b/kernel/trunk/detect/sear_par.inc index 463ac48e50..9f1e547561 100644 --- a/kernel/trunk/detect/sear_par.inc +++ b/kernel/trunk/detect/sear_par.inc @@ -76,21 +76,21 @@ partition_data_transfer: mov edi,[transfer_adress] mov esi,PARTITION_START - xor ecx,ecx - mov cx,69 ;100 - rep movsb + mov ecx,(file_system_data_size+3)/4 + rep movsd ret +uglobal transfer_adress dd 0 +endg partition_data_transfer_1: - cli +; cli push edi mov edi,PARTITION_START mov esi,[transfer_adress] - xor ecx,ecx - mov cx,69 ;100 - rep movsb + mov ecx,(file_system_data_size+3)/4 + rep movsd pop edi - sti +; sti ret end_search_partitions_ide: diff --git a/kernel/trunk/docs/sysfuncr.txt b/kernel/trunk/docs/sysfuncr.txt index 1f112283f2..4fbb4866bf 100644 --- a/kernel/trunk/docs/sysfuncr.txt +++ b/kernel/trunk/docs/sysfuncr.txt @@ -2905,8 +2905,6 @@ dword- Доступные подфункции: * подфункция 0 - чтение файла/папки * подфункция 1 - перезапись файла - * подфункция 4 - создание папки - * подфункция 5 - переименование/перемещение файла/папки * подфункция 8 - LBA-чтение с устройства * подфункция 15 - получение информации о файловой системе @@ -2994,59 +2992,6 @@ dword- Замечания: * Эта функция устарела, используйте подфункцию 2 функции 70. -====================================================================== -============== Функция 58, подфункция 4 - создать папку. ============= -====================================================================== -Параметры: - * eax = 58 - номер функции - * ebx = указатель на информационную структуру -Формат информационной структуры: - * +0: dword: 4 = номер подфункции - * +4: dword: игнорируется - * +8: dword: игнорируется - * +12 = +0xC: dword: игнорируется - * +16 = +0x10: dword: указатель на буфер для работы системы - (4096 байт) - * +20 = +0x14: ASCIIZ-имя файла, правила формирования имён указаны в - общем описании -Возвращаемое значение: - * eax = 0 - успешно, иначе код ошибки файловой системы - * ebx разрушается -Замечания: - * Рамдиск и дискеты не поддерживают эту функцию, - она только для жёстких дисков. - -====================================================================== -== Функция 58, подфункция 5 - переименовать/переместить файл/папку. == -====================================================================== -Параметры: - * eax = 58 - номер функции - * ebx = указатель на информационную структуру -Формат информационной структуры: - * +0: dword: 5 = номер подфункции - * +4: dword: игнорируется - * +8: dword: игнорируется - * +12 = +0xC: dword: игнорируется - * +16 = +0x10: dword: указатель на буфер для работы системы - (4096 байт) - * +20 = +0x14: ASCIIZ-имя файла, правила формирования имён указаны в - общем описании - * +20+n: (сразу после завершающего нулевого символа) новое - ASCIIZ-имя, должно начинаться с /hd/1, что интерпретируется как - жёсткий диск, указанный в первом имени - (перемещение с одного диска на другой не поддерживается) -Возвращаемое значение: - * eax = 0 - успешно, иначе код ошибки файловой системы - * ebx разрушается -Замечания: - * Рамдиск и дискеты не поддерживают эту функцию, - она только для жёстких дисков. - * Если новое ASCIIZ-имя сильно неправильное, т.е. не начинается с - /hd/1, /hd/first, /harddisk/1, /harddisk/first или после этого - начала идёт пробел или символ с кодом 0, то функция возвращает, - как ни странно, код ошибки 4. Это единственная функция, которая - вообще возвращает этот код. - ====================================================================== ========= Функция 58, подфункция 8 - LBA-чтение с устройства. ======== ====================================================================== @@ -4097,6 +4042,7 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * подфункция 6 - установка атрибутов файла/папки * подфункция 7 - запуск программы * подфункция 8 - удаление файла/папки + * подфункция 9 - создание папки Для CD-приводов в связи с аппаратными ограничениями доступны только подфункции 0,1,5 и 7, вызов других подфункций завершится ошибкой с кодом 2. @@ -4434,6 +4380,31 @@ Architecture Software Developer's Manual, Volume 3, Appendix B); * Можно удалять только пустые папки (попытка удаления непустой папки приведёт к ошибке с кодом 10, "доступ запрещён"). +====================================================================== +============= Функция 70, подфункция 9 - создание папки. ============= +====================================================================== +Параметры: + * eax = 70 - номер функции + * ebx = указатель на информационную структуру +Формат информационной структуры: + * +0: dword: 9 = номер подфункции + * +4: dword: 0 (зарезервировано) + * +8: dword: 0 (зарезервировано) + * +12 = +0xC: dword: 0 (зарезервировано) + * +16 = +0x10: dword: 0 (зарезервировано) + * +20 = +0x14: ASCIIZ-имя папки, правила формирования имён указаны в + общем описании + или + * +20 = +0x14: db 0 + * +21 = +0x15: dd указатель на ASCIIZ-строку с именем папки +Возвращаемое значение: + * eax = 0 - успешно, иначе код ошибки файловой системы + * ebx разрушается +Замечания: + * Функция не поддерживается для CD (вернётся код ошибки 2). + * Родительская папка должна уже существовать. + * Если папка уже существует, функция завершится успешно (eax=0). + ====================================================================== === Функция 71, подфункция 1 - установить заголовок окна программы. == ====================================================================== diff --git a/kernel/trunk/docs/sysfuncs.txt b/kernel/trunk/docs/sysfuncs.txt index 514214d17b..3f9f573636 100644 --- a/kernel/trunk/docs/sysfuncs.txt +++ b/kernel/trunk/docs/sysfuncs.txt @@ -2878,8 +2878,6 @@ Examples: Existing subfunctions: * subfunction 0 - read file/folder * subfunction 1 - rewrite file - * subfunction 4 - make folder - * subfunction 5 - rename/move file/folder * subfunction 8 - LBA-read from device * subfunction 15 - get file system information @@ -2968,59 +2966,6 @@ Returned value: Remarks: * This function is obsolete, use subfunction 2 of function 70. -====================================================================== -============== Function 58, subfunction 4 - make folder. ============= -====================================================================== -Parameters: - * eax = 58 - function number - * ebx = pointer to the information structure -Format of the information structure: - * +0: dword: 4 = subfunction number - * +4: dword: ignored - * +8: dword: ignored - * +12 = +0xC: dword: ignored - * +16 = +0x10: dword: pointer to buffer for system operations - (4096 bytes) - * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are - given in the general description -Returned value: - * eax = 0 - success, otherwise file system error code - * ebx destroyed -Remarks: - * Ramdisk and floppies do not support this function, it is only - for hard disks. - -====================================================================== -======== Function 58, subfunction 5 - rename/move file/folder. ======= -====================================================================== -Parameters: - * eax = 58 - function number - * ebx = pointer to the information structure -Format of the information structure: - * +0: dword: 5 = subfunction number - * +4: dword: ignored - * +8: dword: ignored - * +12 = +0xC: dword: ignored - * +16 = +0x10: dword: pointer to buffer for system operations - (4096 bytes) - * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are - given in the general description - * +20+n: (at once after terminating null character) new - ASCIIZ-name, must start from /hd/1, that is interpreted as - the hard disk, indicated in the first name - (moving from one disk to another is not supported) -Returned value: - * eax = 0 - success, otherwise file system error code - * ebx destroyed -Remarks: - * Ramdisk and floppies do not support this function, it is only - for hard disks. - * If the new ASCIIZ-name is strongly incorrect, i.e. does not start - from /hd/1, /hd/first, /harddisk/1, /harddisk/first or after this - space or null character follows, function returns, strangely - enough, error code 4. It is the only function which returns - this code. - ====================================================================== ========= Function 58, subfunction 8 - LBA-read from device. ========= ====================================================================== @@ -4060,6 +4005,7 @@ Available subfunctions: * subfunction 6 - set attributes of file/folder * subfunction 7 - start application * subfunction 8 - delete file/folder + * subfunction 9 - create folder For CD-drives due to hardware limitations only subfunctions 0,1,5 and 7 are available, other subfunctions return error with code 2. @@ -4158,7 +4104,7 @@ Structure of block of data for folder entry (BDFE): * +40 = +0x28: name * for ASCII format: maximum length is 263 characters (263 bytes), byte after the name has value 0 - * фы  ЇюЁьрЄр UNICODE: maximum length is 259 characters + * for UNICODE format: maximum length is 259 characters (518 bytes), 2 bytes after the name have value 0 Time format: * +0: byte: seconds @@ -4392,6 +4338,31 @@ Remarks: * The function can delete only empty folders (attempt to delete nonempty folder results in error with code 10, "access denied"). +====================================================================== +============= Function 70, subfunction 9 - create folder. ============ +====================================================================== +Parameters: + * eax = 70 - function number + * ebx = pointer to the information structure +Format of the information structure: + * +0: dword: 9 = subfunction number + * +4: dword: 0 (reserved) + * +8: dword: 0 (reserved) + * +12 = +0xC: dword: 0 (reserved) + * +16 = +0x10: dword: 0 (reserved) + * +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are + given in the general description + or + * +20 = +0x14: db 0 + * +21 = +0x15: dd pointer to ASCIIZ-string with folder name +Returned value: + * eax = 0 - success, otherwise file system error code + * ebx destroyed +Remarks: + * The function is not supported for CD (returns error code 2). + * The parent folder must already exist. + * If target folder already exists, function returns success (eax=0). + ====================================================================== ========== Function 71, subfunction 1 - set window caption. ========== ====================================================================== diff --git a/kernel/trunk/fs/fat12.inc b/kernel/trunk/fs/fat12.inc index 247600d14f..349dfed4ee 100644 --- a/kernel/trunk/fs/fat12.inc +++ b/kernel/trunk/fs/fat12.inc @@ -1550,7 +1550,13 @@ fsfrfe: xor ebx, ebx ret +fs_FloppyCreateFolder: + mov al, 1 + jmp fs_FloppyRewrite.common + fs_FloppyRewrite: + xor eax, eax +.common: cmp byte [esi], 0 jz @b call read_flp_fat @@ -1616,8 +1622,24 @@ fs_FloppyRewrite: .common1: call fat_find_lfn jc .notfound -; found; must not be directory +; found test byte [edi+11], 10h + jz .exists_file +; found directory; if we are creating directory, return OK, +; if we are creating file, say "access denied" + add esp, 28 + popad + test al, al + mov eax, ERROR_ACCESS_DENIED + jz @f + mov al, 0 +@@: + xor ebx, ebx + ret +.exists_file: +; found file; if we are creating directory, return "access denied", +; if we are creating file, delete existing file and continue + cmp byte [esp+28+28], 0 jz @f add esp, 28 popad @@ -1635,7 +1657,7 @@ fs_FloppyRewrite: @@: cmp eax, 0xFF8 jae .done1 - lea edi, [0x282000 + eax*2] ; position in FAT + lea edi, [FLOPPY_FAT + eax*2] ; position in FAT xor eax, eax xchg ax, [edi] jmp @b @@ -1840,6 +1862,12 @@ fs_FloppyRewrite: and word [edi+20], 0 ; high word of cluster and word [edi+26], 0 ; low word of cluster - to be filled and dword [edi+28], 0 ; file size - to be filled + cmp byte [esp+28+28], 0 + jz .doit +; create directory + mov byte [edi+11], 10h ; attributes: folder + mov ecx, 32*2 + mov edx, edi .doit: lea eax, [esp+8] call dword [eax+12] ; flush directory @@ -1847,9 +1875,10 @@ fs_FloppyRewrite: push edi push 0 mov esi, edx - jecxz .done + test ecx, ecx + jz .done mov ecx, 2849 - mov edi, 0x282000 + mov edi, FLOPPY_FAT push 0 ; first cluster .write_loop: ; allocate new cluster @@ -1859,7 +1888,7 @@ fs_FloppyRewrite: jnz .ret dec edi dec edi - lea eax, [edi-0x282000] + lea eax, [edi-(FLOPPY_FAT)] shr eax, 1 ; eax = cluster mov word [edi], 0xFFF ; mark as last cluster xchg edi, [esp+4] @@ -1879,10 +1908,13 @@ fs_FloppyRewrite: jae @f mov ecx, [esp+20] @@: - push ecx mov edi, 0xD000 + cmp byte [esp+24+28+28], 0 + jnz .writedir + push ecx rep movsb pop ecx +.writedircont: push ecx sub ecx, 512 neg ecx @@ -1935,6 +1967,28 @@ fs_FloppyRewrite: mov eax, 11 pop edi ecx jmp .ret +.writedir: + push ecx + mov ecx, 32/4 + push ecx esi + rep movsd + pop esi ecx + mov dword [edi-32], '. ' + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + mov word [edi-32+26], ax + push esi + rep movsd + pop esi + mov dword [edi-32], '.. ' + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + mov ecx, [esp+28+8] + mov word [edi-32+26], cx + pop ecx + jmp .writedircont ;---------------------------------------------------------------- ; @@ -2059,6 +2113,13 @@ fs_FloppyWrite: jz .ret call SetUserInterrupts .write_loop: +; skip unmodified sectors + cmp dword [esp], 0x200 + jb .modify + sub ebx, 0x200 + jae .skip + add ebx, 0x200 +.modify: lea eax, [edi+31] ; current sector ; get length of data in current sector push ecx @@ -2129,6 +2190,7 @@ fs_FloppyWrite: sub [esp], ecx pop ecx jz .done +.skip: .next_cluster: movzx edi, word [edi*2+0x282000] sub esi, 0x200 @@ -2488,6 +2550,7 @@ fs_FloppySetFileInfo: @@: ret +if 0 ;---------------------------------------------------------------- ; ; fs_FloppyExecute - LFN variant for executing from floppy @@ -2589,6 +2652,7 @@ fs_FloppyExecute: popad mov eax, 11 ret +end if ;---------------------------------------------------------------- ; diff --git a/kernel/trunk/fs/fat32.inc b/kernel/trunk/fs/fat32.inc index 2fe2cdb409..e5e4b8a614 100644 --- a/kernel/trunk/fs/fat32.inc +++ b/kernel/trunk/fs/fat32.inc @@ -7,6 +7,7 @@ ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; ;; ;; ;; See file COPYING for details ;; +;; 04.02.2007 LFN create folder - diamond ;; ;; 08.10.2006 LFN delete file/folder - diamond ;; ;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;; ;; 17.08.2006 LFN write/append to file - diamond ;; @@ -101,13 +102,6 @@ fat_cache: times 512 db 0 fsinfo_buffer: times 512 db 0 endg -iglobal - NewDirEntry1 db ". ",0x10 - times 20 db 0 - NewDirEntry2 db ".. ",0x10 - times 20 db 0 -endg - uglobal dir_entry: times 32 db 0 @@ -139,6 +133,11 @@ reserve_hd1: sti ret ;******************************************** + +uglobal +hd_in_cache db ? +endg + reserve_hd_channel: cmp [hdbase], 0x1F0 jne .IDE_Channel_2 @@ -155,14 +154,27 @@ reserve_hd_channel: je .reserve_ok_2 sti call change_task - jmp .IDE_Channel_1 + jmp .IDE_Channel_2 .reserve_ok_1: - mov [IDE_Channel_1],1 - ret + mov [IDE_Channel_1], 1 + push eax + mov al, 1 + jmp @f .reserve_ok_2: - mov [IDE_Channel_2],1 - ret - + mov [IDE_Channel_2], 1 + push eax + mov al, 3 +@@: + cmp [hdid], 1 + sbb al, -1 + cmp al, [hd_in_cache] + jz @f + mov [hd_in_cache], al + call clear_hd_cache +@@: + pop eax + ret + free_hd_channel: cmp [hdbase], 0x1F0 jne .IDE_Channel_2 @@ -806,189 +818,6 @@ set_current_time_for_entry: ret -makedir: -;----------------------------------------------------- -; input : eax = directory name -; edx = path -; output : eax = 0 - ok -; 3 - unknown FS -; 5 - file not found -; 8 - disk full -; 10 - access denied -; Note : can only make one directory at time -;----------------------------------------------------- - cmp [fs_type], 16 - jz make_dir_fat_ok - cmp [fs_type], 32 - jz make_dir_fat_ok - push ERROR_UNKNOWN_FS - pop eax - ret - - make_dir_fat_ok: -; call reserve_hd1 - - pushad - - mov ebx,edx - call get_cluster_of_a_path - jnc make_dir_found_path - cmp [hd_error],0 - jne make_dir_error_1 - - make_dir_path_not_found: - popad - call update_disk ; write all of cache and fat to hd - cmp [hd_error],0 - jne make_dir_error_2 - - mov [hd1_status],0 - mov eax,ERROR_FILE_NOT_FOUND - ret - - make_dir_disk_full: - cmp [hd_error],0 - jne make_dir_error_1 - popad - call update_disk ; write all of cache and fat to hd - cmp [hd_error],0 - jne make_dir_error_2 - - mov [hd1_status],0 - mov eax,ERROR_DISK_FULL - ret - - make_dir_already_exist: - cmp [hd_error],0 - jne make_dir_error_1 - mov eax,[cluster] ; directory cluster - xor edx,edx ; free - call set_FAT - cmp [hd_error],0 - jne make_dir_error_1 - - popad - call update_disk ; write all of cache and fat to hd - make_dir_error_2: - mov [hd1_status],0 - mov eax,ERROR_ACCESS_DENIED - ret - - make_dir_error_1: - popad - jmp make_dir_error_2 - - make_dir_error_3: - add esp,4 - jmp make_dir_error_1 - - make_dir_found_path: - cmp eax,[ROOT_CLUSTER] - jnz make_dir_not_root - xor eax,eax - - make_dir_not_root: - mov ecx,eax ; directorys start cluster - mov word [NewDirEntry2+26],cx ; 16 bits low of cluster - shr ecx,16 - mov word [NewDirEntry2+20],cx ; 16 bits high of cluster (=0 fat16) - - push eax ; save parent directory cluster - mov eax,2 - call get_free_FAT - mov [cluster],eax ; first free cluster - pop eax - jc make_dir_disk_full - - push eax - mov eax,[cluster] ; directory cluster - mov edx,[fatEND] ; end for directory - call set_FAT - cmp [hd_error],0 - jne make_dir_error_3 - pop eax - - mov ebx,PUSHAD_EAX ; dir name - push eax - call analyze_directory ; check if directory already exist - cmp [hd_error],0 - jne make_dir_error_1 - - pop eax - jnc make_dir_already_exist ; need to free allocated cluster! - - call analyze_directory_to_write - jc make_dir_already_exist ; need to free allocated cluster! - - mov esi,PUSHAD_EAX ; dir name - mov edi,ebx ; pointer in buffer - mov ecx,11 - cld - rep movsb - - mov dword [ebx+28],0 ; dir size is always 0 - mov ecx,[cluster] - mov [ebx+26],cx ; 16 bits low of cluster - mov word [NewDirEntry1+26],cx - shr ecx,16 - mov [ebx+20],cx ; 16 bits high of cluster (=0 fat16) - mov word [NewDirEntry1+20],cx - mov byte [ebx+11],0x10 ; attribute = directory - - call set_current_time_for_entry - mov ecx,[ebx+22] - mov dword [NewDirEntry1+22],ecx - mov dword [NewDirEntry2+22],ecx - - mov ebx,buffer ; save the directory name,length,cluster - call hd_write - cmp [hd_error],0 - jne make_dir_error_1 - - mov ecx,512/4 - xor eax,eax - mov edi,buffer - cld - rep stosd ; clear new directory cluster - - mov eax,[cluster] ; new directory cluster - sub eax,2 - mov edx,[SECTORS_PER_CLUSTER] - imul eax,edx - add eax,[DATA_START] - mov ebx,buffer - add eax,edx ; start from last sector - - dir_set_empty_directory: - dec eax ; next sector - cmp edx,1 ; is first directory sector? - jnz not_first_sector ; no. write empty sector - mov esi,NewDirEntry1 - mov edi,buffer - mov ecx,64/4 - cld - rep movsd ; copy 2 first directory entrys "." and ".." - - not_first_sector: - call hd_write - cmp [hd_error],0 - jne make_dir_error_1 - - dec edx - jnz dir_set_empty_directory - - mov ecx,-1 ; remove 1 cluster from free disk space - call add_disk_free_space - cmp [hd_error],0 - jne make_dir_error_1 - - popad - call update_disk ; write all of cache and fat to hd - cmp [hd_error],0 - jne make_dir_error_2 - mov [hd1_status],0 - xor eax,eax - ret add_disk_free_space: ;----------------------------------------------------- @@ -1664,172 +1493,6 @@ delete_entry_name: ret -rename: -;----------------------------------------------------------- -; input : eax = source directory name -; edx = source path -; ebx = dest directory name -; edi = dest path -; output : eax = 0 - ok -; 3 - unknown FS -; 5 - file not found -; 8 - disk full -; 10 - access denied -;----------------------------------------------------------- - cmp [fs_type], 16 - jz fat_ok_for_rename - cmp [fs_type], 32 - jz fat_ok_for_rename - push ERROR_UNKNOWN_FS - pop eax - ret - - fat_ok_for_rename: -; call reserve_hd1 - - pushad - - mov ebx,edx ; source path - call get_cluster_of_a_path - jc rename_entry_not_found - - mov ebx,PUSHAD_EAX ; source directory name - call analyze_directory - jc rename_entry_not_found - - mov [sector_tmp],eax ; save source sector - mov [entry_pos],ebx - mov esi,ebx - mov edi,dir_entry - mov ecx,32/4 - cld - rep movsd ; save entry - - mov ebx,PUSHAD_EDI ; dest path - call get_cluster_of_a_path - jc rename_entry_not_found - - mov edx,eax ; save dest directory cluster - mov ebx,PUSHAD_EBX ; dest directory name - push [longname_sec1] - push [longname_sec2] - call analyze_directory ; check if entry already exist - cmp [hd_error],0 - jne rename_entry_already_exist_1 - - pop [longname_sec2] - pop [longname_sec1] - jnc rename_entry_already_exist - - mov eax,edx - call analyze_directory_to_write - jc rename_disk_full - - mov esi,dir_entry - mov edi,ebx - mov ecx,32/4 - cld - rep movsd ; copy entry - mov esi,PUSHAD_EBX ; dest directory name - mov edi,ebx - mov ecx,11 - rep movsb ; copy name - - mov ebx,buffer ; save the directory name,length,cluster - call hd_write - - test byte [dir_entry+11],0x10 ; is it directory? - jz rename_not_dir ; no - mov eax,[dir_entry+20-2] ; FAT entry - mov ax,[dir_entry+26] - and eax,[fatMASK] - call change_2dot_cluster - cmp [hd_error],0 - jne rename_entry_already_exist - - rename_not_dir: - cmp [hd_error],0 - jne rename_entry_already_exist - mov eax,[sector_tmp] - mov ebx,buffer - call hd_read ; read source directory sector - cmp [hd_error],0 - jne rename_entry_already_exist - - mov ebx,[entry_pos] - call delete_entry_name - cmp [hd_error],0 - jne rename_entry_already_exist - - popad - call update_disk ; write all of cache and fat to hd - cmp [hd_error],0 - jne rename_entry_already_exist_2 - mov [hd1_status],0 - xor eax,eax - ret - - rename_entry_not_found: - cmp [hd_error],0 - jne rename_entry_already_exist - popad - mov [hd1_status],0 - mov eax,ERROR_FILE_NOT_FOUND - ret - - rename_entry_already_exist_1: - add esp,8 - rename_entry_already_exist: - popad - rename_entry_already_exist_2: - mov [hd1_status],0 - mov eax,ERROR_ACCESS_DENIED - ret - - rename_disk_full: - cmp [hd_error],0 - jne rename_entry_already_exist - popad - mov [hd1_status],0 - mov eax,ERROR_DISK_FULL - ret - - -change_2dot_cluster: -;----------------------------------------------------------- -; input : eax = directory cluster -; edx = value to save -; change : eax,ebx,edx -;----------------------------------------------------------- - cmp eax,[LAST_CLUSTER] - ja not_2dot ; too big cluster number, something is wrong - sub eax,2 - jb not_2dot - - imul eax,[SECTORS_PER_CLUSTER] - add eax,[DATA_START] - mov ebx,buffer - call hd_read - cmp [hd_error],0 - jne not_2dot - - cmp dword [ebx+32],'.. ' - jnz not_2dot - - cmp edx,[ROOT_CLUSTER] ; is rootdir cluster? - jne not_2dot_root - xor edx,edx ; yes. set it zero - - not_2dot_root: - mov [ebx+32+26],dx ; 16 bits low of cluster - shr edx,16 - mov [ebx+32+20],dx ; 16 bits high of cluster (=0 fat16) - call hd_write - - not_2dot: - ret - - get_hd_info: ;----------------------------------------------------------- ; output : eax = 0 - ok @@ -2555,7 +2218,13 @@ fshrfs: xor ebx, ebx ret +fs_HdCreateFolder: + mov al, 1 + jmp fs_HdRewrite.common + fs_HdRewrite: + xor eax, eax +.common: cmp [fs_type], 1 jz ntfs_HdRewrite cmp [fs_type], 16 @@ -2627,8 +2296,24 @@ fs_HdRewrite: .common1: call fat_find_lfn jc .notfound -; found; must not be directory +; found test byte [edi+11], 10h + jz .exists_file +; found directory; if we are creating directory, return OK, +; if we are creating file, say "access denied" + add esp, 32 + popad + test al, al + mov eax, ERROR_ACCESS_DENIED + jz @f + mov al, 0 +@@: + xor ebx, ebx + ret +.exists_file: +; found file; if we are creating directory, return "access denied", +; if we are creating file, delete existing file and continue + cmp byte [esp+32+28], 0 jz @f add esp, 32 popad @@ -2865,11 +2550,23 @@ fs_HdRewrite: mov word [edi+20], cx ; high word of cluster mov word [edi+26], cx ; low word of cluster - to be filled mov dword [edi+28], ecx ; file size - to be filled + cmp byte [esp+32+28], cl + jz .doit +; create directory + mov byte [edi+11], 10h ; attributes: folder + mov edx, edi + lea eax, [esp+8] + call dword [eax+16] ; flush directory + push ecx + mov ecx, [SECTORS_PER_CLUSTER] + shl ecx, 9 + jmp .doit2 .doit: lea eax, [esp+8] call dword [eax+16] ; flush directory push ecx mov ecx, [esp+4+32+24] +.doit2: push ecx push edi mov esi, edx @@ -2898,6 +2595,8 @@ fs_HdRewrite: add eax, [DATA_START] ; write data .write_sector: + cmp byte [esp+16+32+28], 0 + jnz .writedir mov ecx, 512 cmp dword [esp+8], ecx jb .writeshort @@ -2911,6 +2610,7 @@ fs_HdRewrite: mov edi, buffer mov ebx, edi rep movsb +.writedircont: mov ecx, buffer+0x200 sub ecx, edi push eax @@ -2977,6 +2677,40 @@ fs_HdRewrite: call update_disk popad ret +.writedir: + push 512 + mov edi, buffer + mov ebx, edi + mov ecx, [SECTORS_PER_CLUSTER] + shl ecx, 9 + cmp ecx, [esp+12] + jnz .writedircont + dec dword [esp+16] + push esi + mov ecx, 32/4 + rep movsd + pop esi + mov dword [edi-32], '. ' + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + push esi + mov ecx, 32/4 + rep movsd + pop esi + mov dword [edi-32], '.. ' + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + mov ecx, [esp+20+8] + cmp ecx, [ROOT_CLUSTER] + jnz @f + xor ecx, ecx +@@: + mov word [edi-32+26], cx + shr ecx, 16 + mov [edi-32+20], cx + jmp .writedircont ;---------------------------------------------------------------- ; @@ -3119,6 +2853,13 @@ fs_HdWrite: sub ecx, ebx jz .ret .write_loop: +; skip unmodified sectors + cmp dword [esp], 0x200 + jb .modify + sub ebx, 0x200 + jae .skip + add ebx, 0x200 +.modify: ; get length of data in current sector push ecx sub ebx, 0x200 @@ -3175,9 +2916,8 @@ fs_HdWrite: add edi, esi rep stosb @@: - pop edi ecx eax + pop edi ecx ; copy new data - push eax mov eax, edx neg ebx jecxz @f @@ -3197,6 +2937,7 @@ fs_HdWrite: sub [esp], ecx pop ecx jz .ret +.skip: ; next sector inc ebp cmp ebp, [SECTORS_PER_CLUSTER] diff --git a/kernel/trunk/fs/fs.inc b/kernel/trunk/fs/fs.inc index a81d4dce95..342839a1a2 100644 --- a/kernel/trunk/fs/fs.inc +++ b/kernel/trunk/fs/fs.inc @@ -4,7 +4,6 @@ ;; (C) 2004 Ville Turjanmaa, License: GPL ;; ;; 29.04.2006 Elimination of hangup after the ;; ;; expiration hd_wait_timeout (for LBA) - Mario79 ;; -;; xx.04.2006 LFN support - diamond ;; ;; 15.01.2005 get file size/attr/date, file_append (only for hd) - ATV ;; ;; 23.11.2004 test if hd/partition is set - ATV ;; ;; 18.11.2004 get_disk_info and more error codes - ATV ;; @@ -37,8 +36,6 @@ file_system: ; ; eax = 0 ; read file /RamDisk/First 6 ; eax = 1 ; write file /RamDisk/First 33 /HardDisk/First 56 -; eax = 4 ; makedir -; eax = 5 ; rename file/directory ; eax = 8 ; lba read ; eax = 15 ; get_disk_info ; @@ -87,10 +84,6 @@ file_system: cmp dword [eax+0],15 ; GET_DISK_INFO je fs_info - cmp dword [eax+0],5 ; RENAME - dont care about read&write blocks - je fs_read - cmp dword [eax+0],4 ; MAKEDIR - dont care about read&write blocks - je fs_read cmp dword [0x3000],1 ; no memory checks for kernel requests jz no_checks_for_kernel @@ -384,6 +377,7 @@ fs_yesharddisk_IDE3: mov [hdid],0x10 mov [hdpos],4 fs_yesharddisk_partition: + call reserve_hd_channel ; call choice_necessity_partition ; jmp fs_yesharddisk_all jmp fs_for_new_semantic @@ -445,6 +439,7 @@ choice_necessity_partition_1: cmp [fat32part],0 ; is partition set? jnz @f hd_err_return: + call free_hd_channel and [hd1_status], 0 jmp file_system_return @@: @@ -469,6 +464,8 @@ hd_err_return: mov edi,[esp+0] mov byte [edi],'/' + call free_hd_channel + and [hd1_status], 0 jmp file_system_return fs_noharddisk_read: @@ -493,76 +490,16 @@ hd_err_return: ; eax=0 ok - eax=1 not enough free space + call free_hd_channel + and [hd1_status], 0 jmp file_system_return fs_noharddisk_write: - cmp dword [esp+20],4 ; MAKEDIR - jne fs_noharddisk_makedir - mov eax,[esp+0] ; /dirname - mov byte [eax],0 ; path to asciiz - inc eax ; filename start - mov edx,[esp+4] - add edx,12*2 ; path start - - call makedir - - mov edi,[esp+0] - mov byte [edi],'/' - - jmp file_system_return - - fs_noharddisk_makedir: - - cmp dword [esp+20],5 ; RENAME - jne fs_noharddisk_rename - - mov edi,[esp+0] ; start of source file name - add edi,12+1 ; continue after name - call expand_pathz ; convert destination name - - mov eax,[edi+1] - cmp eax,'HD ' - je fs_rename_test1 - cmp eax,'HARD' - jne fs_rename_error - - fs_rename_test1: - mov eax,[edi+1+12] - cmp eax,'1 ' - je fs_rename_start - cmp eax,'FIRS' - jne fs_rename_error - - fs_rename_start: - mov byte [ebx],0 ; path to asciiz - inc ebx ; filename start - add edi,12*2 ; path start - cmp byte [ebx],0 - je fs_rename_error - cmp byte [ebx],32 - je fs_rename_error - - mov eax,[esp+0] ; /filename - mov byte [eax],0 ; path to asciiz - inc eax ; filename start - mov edx,[esp+4] - add edx,12*2 ; path start - - call rename - - mov edi,[esp+0] - mov byte [edi],'/' - - jmp file_system_return - - fs_rename_error: - mov eax,4 ; partition not defined at hd - jmp file_system_return - - fs_noharddisk_rename: + call free_hd_channel + and [hd1_status], 0 fs_noharddisk: ; \begin{diamond}[18.03.2006] diff --git a/kernel/trunk/fs/fs_lfn.inc b/kernel/trunk/fs/fs_lfn.inc index bb46383f35..8a65ee6885 100644 --- a/kernel/trunk/fs/fs_lfn.inc +++ b/kernel/trunk/fs/fs_lfn.inc @@ -83,7 +83,7 @@ file_system_lfn: ; 6 : set file/directory attributes structure ; 7 : start application ; 8 : delete file -; 9 : create directory - not implemented yet +; 9 : create directory add eax, std_application_base_address ; parse file name @@ -362,8 +362,9 @@ fs_RamdiskServices: dd fs_RamdiskSetFileEnd dd fs_RamdiskGetFileInfo dd fs_RamdiskSetFileInfo - dd fs_RamdiskExecute + dd 0 ;fs_RamdiskExecute dd fs_RamdiskDelete + dd fs_RamdiskCreateFolder fs_NumRamdiskServices = ($ - fs_RamdiskServices)/4 fs_OnFloppy: @@ -392,8 +393,9 @@ fs_FloppyServices: dd fs_FloppySetFileEnd dd fs_FloppyGetFileInfo dd fs_FloppySetFileInfo - dd fs_FloppyExecute + dd 0 ;fs_FloppyExecute dd fs_FloppyDelete + dd fs_FloppyCreateFolder fs_NumFloppyServices = ($ - fs_FloppyServices)/4 fs_OnHd0: @@ -466,6 +468,7 @@ fs_HdServices: dd fs_HdSetFileInfo dd 0 ;fs_HdExecute dd fs_HdDelete + dd fs_HdCreateFolder fs_NumHdServices = ($ - fs_HdServices)/4 ;******************************************************* diff --git a/kernel/trunk/fs/ntfs.inc b/kernel/trunk/fs/ntfs.inc index 4243cfb431..29c09965d8 100755 --- a/kernel/trunk/fs/ntfs.inc +++ b/kernel/trunk/fs/ntfs.inc @@ -222,6 +222,7 @@ ntfs_setup: ; CODE XREF: part_set.inc mov [ntfs_data.cur_index_buf], eax popad + call free_hd_channel and [hd1_status], 0 ret diff --git a/kernel/trunk/fs/part_set.inc b/kernel/trunk/fs/part_set.inc index ba5fb148ec..fba973569f 100644 --- a/kernel/trunk/fs/part_set.inc +++ b/kernel/trunk/fs/part_set.inc @@ -39,6 +39,10 @@ fatEND dd 0x0FFFFFF8 fatMASK dd 0x0FFFFFFF fs_dependent_data_end: +file_system_data_size = $ - PARTITION_START +if file_system_data_size > 96 +ERROR: sizeof(file system data) too big! +end if virtual at fs_dependent_data_start ; NTFS data @@ -111,10 +115,9 @@ endg ; - it will skip over removed partitions set_FAT32_variables: - mov [0xfe10],dword 0 ; entries in hd cache mov [problem_partition],0 call reserve_hd1 - call clear_hd_cache + call reserve_hd_channel cmp dword [hdpos],0 je problem_hd @@ -303,6 +306,7 @@ problem_partition_or_fat: problem_hd: mov [fs_type],0 + call free_hd_channel mov [hd1_status],0 ; free mov [problem_partition],1 ret @@ -420,6 +424,7 @@ fat32_partition: mov [fatEND],0x0FFFFFF8 mov [fatMASK],0x0FFFFFFF mov [fs_type],32 ; Fat32 + call free_hd_channel mov [hd1_status],0 ; free ret @@ -434,5 +439,6 @@ fat16_partition: mov [fatEND],0x0000FFF8 mov [fatMASK],0x0000FFFF mov [fs_type],16 ; Fat16 + call free_hd_channel mov [hd1_status],0 ; free ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 7e116128ae..42f745ccee 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -1496,9 +1496,9 @@ cd_base db 0 mov [hdpos],4 ; call set_FAT32_variables noseslhd: - mov [0xfe10],dword 0 call reserve_hd1 - call clear_hd_cache + call reserve_hd_channel + call free_hd_channel mov [hd1_status],0 ; free nosethd: ret @@ -1514,7 +1514,8 @@ endg mov [fat32part],ebx ; call set_FAT32_variables call reserve_hd1 - call clear_hd_cache + call reserve_hd_channel + call free_hd_channel pusha call choice_necessity_partition_1 popa diff --git a/kernel/trunk/memmap.inc b/kernel/trunk/memmap.inc index 8f18ea6439..9d941725ce 100644 --- a/kernel/trunk/memmap.inc +++ b/kernel/trunk/memmap.inc @@ -105,7 +105,6 @@ ; FE04 dword screen y size ; FE08 dword screen y multiplier ; FE0C dword screen mode -; FE10 dword entries in hd cache ; FE80 dword address of LFB in physical ; FE84 dword address of applications memory start in physical ; FE88 dword address of button list diff --git a/programs/fs/kfar/trunk/kfar.asm b/programs/fs/kfar/trunk/kfar.asm index 3651f5464c..6abd03907f 100644 --- a/programs/fs/kfar/trunk/kfar.asm +++ b/programs/fs/kfar/trunk/kfar.asm @@ -34,7 +34,6 @@ start: stosb test al, al jnz @b -@@: mov esi, def_right_dir mov edi, panel2_dir @@: @@ -675,12 +674,13 @@ panels_OnKey: .dorun: lea esi, [ebp + panel1_dir - panel1_data] mov edi, execdata -; TODO: add overflow check @@: lodsb test al, al jz @f stosb + cmp edi, execdataend-1 + jae .bigfilename jmp @b @@: lea esi, [ecx+40] @@ -689,6 +689,8 @@ panels_OnKey: @@: lodsb stosb + cmp edi, execdataend + ja .bigfilename test al, al jnz @b ; for fasm call - special handling, because @@ -699,7 +701,8 @@ panels_OnKey: jz .nofasm cmp [execptr], fasm jnz .nofasm -; TODO: add buffer/cmdline overflow check + cmp edi, execdata+(execdataend-execdata)/2 + ja .bigfilename mov esi, execdata @@: lodsb @@ -717,6 +720,8 @@ panels_OnKey: cmp byte [edi], '/' jnz @b pop edi + cmp edi, execdataend-4 + ja .bigfilename mov dword [edi-1], '.bin' mov byte [edi+3], 0 jmp .nofasm @@ -724,10 +729,45 @@ panels_OnKey: mov byte [edi], 0 pop edi .nofasm: + mov ebx, execinfo +; if command line is more than 256 symbols, the kernel will truncate it +; we does not want this! +; N.B. We know that command line is either NULL or execdata, which is always ASCIIZ string, +; but can be up to 1023 symbols + mov esi, [ebx+8] + test esi, esi + jz .cmdlinelenok +@@: + lodsb + test al, al + jnz @b + sub esi, [ebx+8] + dec esi + cmp esi, 256 + ja .bigcmdline +.cmdlinelenok: push 70 pop eax - mov ebx, execinfo int 40h + neg eax + js @f + push aContinue + mov esi, esp + call get_error_msg + push eax + push aRunError + mov eax, esp + push esi + push 1 + push eax + push 2 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + ret +@@: test edx, edx jz @f push 5 @@ -738,6 +778,38 @@ panels_OnKey: jmp .ctrl_r @@: ret +.bigfilename3: + pop esi +.bigfilename2: + pop esi +.bigfilename: + mov eax, aFileNameTooBig +@@: + push aContinue + mov esi, esp + push eax + mov eax, esp + push esi + push 1 + push eax + push 1 + push -1 + push -1 + push aError + call SayErr + add esp, 2*4 + ret +.bigcmdline: + mov eax, aCmdLineTooBig + jmp @b +.bigfoldername2: + mov byte [ecx], 0 +.bigfoldername: + mov eax, aFolderNameTooBig + jmp @b +.copytoself: + mov eax, aCannotCopyToSelf + jmp @b .enter_folder: lea esi, [ecx+40] cmp word [esi], '..' @@ -754,15 +826,19 @@ panels_OnKey: test al, al jnz @b lea edi, [esi-1] + lea edx, [ebp + panel1_dir - panel1_data + 1024] + cmp esi, edx pop esi + jae .bigfoldername + mov ecx, edi mov al, '/' cmp [edi-1], al jz @f stosb -@@: -; TODO: add buffer overflow check @@: lodsb + cmp edi, edx + jae .bigfoldername2 stosb test al, al jnz @b @@ -791,9 +867,7 @@ panels_OnKey: mov ecx, [ebp + panel1_numfiles - panel1_data] .scanloop: mov esi, [edx] - mov eax, [ebp + panel1_nfa - panel1_data] - lea esi, [esi+eax*4+32+40] - add esi, [ebp + panel1_files - panel1_data] + add esi, 40 push esi edi @@: lodsb @@ -1019,6 +1093,8 @@ panels_OnKey: lodsb test al, al jz @f + cmp edi, CopyDestEditBuf+12+511 + jae .bigfoldername stosb jmp @b @@: @@ -1123,6 +1199,14 @@ panels_OnKey: repnz scasb not ecx pop edi + push edi + add edi, ecx + cmp edi, CopyDestEditBuf+12+513 + pop edi + jb @f + pop esi + jmp .bigfilename +@@: lea edx, [edi+2] sub edx, esi lea edi, [edi+ecx+1] @@ -1164,6 +1248,8 @@ panels_OnKey: test cl, 0x10 jz .copyfile ; Нам подсунули каталог назначения, дописываем имя файла + cmp edi, CopyDestEditBuf+12+513 + jae .bigfilename mov al, '/' stosb push esi @@ -1171,6 +1257,8 @@ panels_OnKey: lea esi, [ecx+40] @@: lodsb + cmp edi, CopyDestEditBuf+12+513 + jae .bigfilename2 stosb test al, al jnz @b @@ -1194,6 +1282,8 @@ panels_OnKey: lea esi, [ecx+40] @@: lodsb + cmp edi, saved_file_name+1024 + jae .bigfilename3 stosb test al, al jnz @b @@ -1203,7 +1293,7 @@ panels_OnKey: push esi edi call strcmpi pop edi esi - jz .ret2 + jz .copytoself ; Собственно, копируем ; esi->source name, edi->destination name mov [writeinfo.code], 2 @@ -1222,17 +1312,58 @@ panels_OnKey: push 70 pop eax int 0x40 - cmp ebx, -1 - jz .copydone + test eax, eax + jz .copyreadok + cmp eax, 6 + jz .copyreadok + push esi + push aCannotReadFile + call get_error_msg + push eax + mov eax, esp + push RetryOrCancelBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + test eax, eax + jz .copyloop + jmp .copyfailed +.copyreadok: test ebx, ebx jz .copydone add dword [readinfo.first], ebx adc dword [readinfo.first+4], 0 mov [writeinfo.size], ebx +.copywrite: mov ebx, writeinfo push 70 pop eax int 0x40 + test eax, eax + jz .copywriteok + push edi + push aCannotWriteFile + call get_error_msg + push eax + mov eax, esp + push RetryOrCancelBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + test eax, eax + jz .copywrite + jmp .copyfailed +.copywriteok: mov ecx, [writeinfo.size] add dword [writeinfo.first], ecx adc dword [writeinfo.first+4], 0 @@ -1245,6 +1376,34 @@ panels_OnKey: pop ebp xor ebp, panel1_data xor panel2_data jmp .ctrl_r +.copyfailed: + cmp [bConfirmDeleteIncomplete], 0 + jz @f + cmp [writeinfo.code], 2 + jz .copydone + push aIncompleteFile + mov eax, esp + push DeleteOrKeepBtn + push 2 + push eax + push 1 + push -1 + push -1 + push aCopyCaption + call SayErr + add esp, 4 + test eax, eax + jnz .copydone +@@: + mov ebx, delinfo + push dword [ebx+21] + mov dword [ebx+21], edi + push 70 + pop eax + int 0x40 +; ignore errors + pop dword [delinfo+21] + jmp .copydone .f3: call view_file @@ -1326,13 +1485,39 @@ panels_OnKey: stosb @@: lodsb + cmp edi, execdataend + jae .bigfilename stosb test al, al jnz @b +.retrydel: push 70 pop eax mov ebx, delinfo int 0x40 + test eax, eax + jz .ctrl_r + push execdata + push aCannotDeleteFolder + call get_curfile_folder_entry + test byte [ecx], 10h + jnz @f + mov dword [esp], aCannotDeleteFile +@@: + call get_error_msg + push eax + mov eax, esp + push RetryOrCancelBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + test eax, eax + jz .retrydel .ctrl_r: ; Rescan panel ; call read_folder @@ -1356,10 +1541,9 @@ panels_OnKey: inc eax cmp eax, [ebp + panel1_numfiles - panel1_data] jae .ctrl_r.notfound - mov esi, [ebp + panel1_nfa - panel1_data] mov ecx, [ebp + panel1_files - panel1_data] - lea esi, [ecx+esi*4+32+40] - add esi, [ecx+eax*4] + mov esi, [ecx+eax*4] + add esi, 40 mov edi, saved_file_name call strcmpi jnz @b @@ -1496,6 +1680,102 @@ panels_OnKey: pop eax call get_curfile_folder_entry jmp .run_association2 +.f7: + mov dword [CopyDestEditBuf], CopyDestEditBuf.length + and dword [CopyDestEditBuf+4], 0 + and dword [CopyDestEditBuf+8], 0 + mov byte [CopyDestEditBuf+12], 0 + mov ebx, mkdir_dlgdata + mov eax, [cur_width] + sub eax, 12 + mov [ebx + dlgtemplate.width], eax + dec eax + dec eax + mov [ebx - mkdir_dlgdata + mkdir_dlgdata.width2], eax + shr eax, 1 + dec eax + dec eax + mov [ebx - mkdir_dlgdata + mkdir_dlgdata.cont_x2], eax + sub eax, a_ContinueLength-1 + mov [ebx - mkdir_dlgdata + mkdir_dlgdata.cont_x1], eax + add eax, a_ContinueLength+3 + mov [ebx - mkdir_dlgdata + mkdir_dlgdata.cnl_x1], eax + add eax, aCancelBLength - 1 + mov [ebx - mkdir_dlgdata + mkdir_dlgdata.cnl_x2], eax + mov byte [ebx - mkdir_dlgdata + mkdir_dlgdata.flags0], 0xC + and byte [ebx - mkdir_dlgdata + mkdir_dlgdata.flags1], not 4 + and byte [ebx - mkdir_dlgdata + mkdir_dlgdata.flags2], not 4 + push ebx + call DialogBox + cmp eax, mkdir_dlgdata.cont_btn + jnz .ret2 + mov esi, CopyDestEditBuf+12 + cmp byte [esi], 0 + jz .ret2 + cmp byte [esi], '/' + jz .mkdir_absolute_path + push esi + lea edi, [ebp + panel1_dir - panel1_data] + or ecx, -1 + xor eax, eax + repnz scasb + not ecx + mov edi, esi +@@: + cmp byte [edi+1], 0 + jz @f + inc edi + jmp @b +@@: + push edi + add edi, ecx + cmp edi, CopyDestEditBuf+12+513 + pop edi + jb @f + pop esi + jmp .bigfilename +@@: + lea edx, [edi+2] + sub edx, esi + lea edi, [edi+ecx+1] + xchg ecx, edx + std + lea esi, [esi+ecx-1] + rep movsb + cld + pop edi + lea esi, [ebp + panel1_dir - panel1_data] + push edi + mov ecx, edx + rep movsb + mov byte [edi-1], '/' + pop esi +.mkdir_absolute_path: +.mkdir_retry: + push 70 + pop eax + mov ebx, mkdirinfo + int 0x40 + test eax, eax + jz @f + push CopyDestEditBuf+12 + push aCannotMakeFolder + call get_error_msg + push eax + mov eax, esp + push RetryOrCancelBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + test eax, eax + jz .mkdir_retry +@@: + jmp .copydone panels_OnRedraw: call draw_cmdbar @@ -1539,14 +1819,10 @@ init_console: ret get_curfile_folder_entry: - push eax mov ecx, [ebp + panel1_index - panel1_data] - mov eax, [ebp + panel1_files - panel1_data] - mov ecx, [eax+ecx*4] - mov eax, [ebp + panel1_nfa - panel1_data] - lea ecx, [ecx+eax*4+32] + shl ecx, 2 add ecx, [ebp + panel1_files - panel1_data] - pop eax + mov ecx, [ecx] ret get_curfile_name: call get_curfile_folder_entry @@ -1602,12 +1878,11 @@ end if sub ebx, [esp] dec esi push esi - mov edx, [ebp + panel1_files - panel1_data] mov esi, [ebp + panel1_index - panel1_data] - mov esi, [edx+esi*4] - add esi, edx - mov edx, [ebp + panel1_nfa - panel1_data] - lea esi, [esi+edx*4+32+40] + shl esi, 2 + add esi, [ebp + panel1_files - panel1_data] + mov esi, [esi] + add esi, 40 push esi @@: lodsb @@ -2286,9 +2561,6 @@ draw_panel: mov ebx, [ebp + panel1_index - panel1_data] mov eax, [ebp + panel1_files - panel1_data] mov ebx, [eax+ebx*4] - mov eax, [ebp + panel1_nfa - panel1_data] - lea ebx, [ebx+eax*4+32] - add ebx, [ebp + panel1_files - panel1_data] mov eax, [ebp + panel1_left - panel1_data] add eax, [ebp + panel1_width - panel1_data] dec eax @@ -2519,9 +2791,7 @@ end if mov esi, [column_index] mov ecx, [ebp + panel1_files - panel1_data] mov esi, [ecx+esi*4] - mov ecx, [ebp + panel1_nfa - panel1_data] - lea esi, [esi + ecx*4 + 32 + 40] - add esi, [ebp + panel1_files - panel1_data] + add esi, 40 mov ah, [esi - 40 + 5] cmp ebp, [active_panel] jnz @f @@ -2732,6 +3002,7 @@ read_folder: .succ1: mov [ebp + panel1_files - panel1_data], eax pop [ebp + panel1_nfa - panel1_data] + mov [prev_dir], 0 jmp read_folder .readdone: and [ebp + panel1_start - panel1_data], 0 @@ -2739,22 +3010,44 @@ read_folder: and [ebp + panel1_start - panel1_data], 0 mov edi, [ebp + panel1_files - panel1_data] mov eax, [ebp + panel1_nfa - panel1_data] - lea esi, [edi + eax*4 + 32] - xor eax, eax - mov ecx, [esi-32+4] + lea eax, [edi + eax*4 + 32] + mov ecx, [eax-32+4] test ecx, ecx jz .loopdone + xor edx, edx ; Игнорируем специальные входы, соответствующие папке '.' и метке тома .ptrinit: - cmp word [esi+eax+40], '.' + cmp word [eax+40], '.' jz .loopcont - test byte [esi+eax], 8 + test byte [eax], 8 jnz .loopcont + test edx, edx + jnz .nodotdot + cmp word [eax+40], '..' + jnz .nodotdot + cmp byte [eax+42], 0 + jnz .nodotdot + mov edx, eax + push edi +@@: + cmp edi, [ebp + panel1_files - panel1_data] + jbe @f + push dword [edi-4] + pop dword [edi] + sub edi, 4 + jmp @b +@@: stosd + pop edi + scasd + jmp .dotdot +.nodotdot: + stosd +.dotdot: ; подсветка ; call insert_last_dot pushad - lea ebp, [esi+eax] + mov ebp, eax lea esi, [ebp+40] mov edi, lower_file_name mov edx, edi @@ -2817,27 +3110,21 @@ sort_files: mov ebx, [compare_fns + eax*4] mov edx, [ebp + panel1_files - panel1_data] mov ecx, [ebp + panel1_numfiles - panel1_data] + jecxz .skip + mov eax, [edx] + cmp word [eax], '..' + jnz .nodotdot + cmp byte [eax+2], 0 + jnz .nodotdot + dec ecx + add edx, 4 +.nodotdot: call sort +.skip: mov [bSilentFolderMode], 0 ; leave silent mode ret compare_name: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -2858,22 +3145,6 @@ compare_name: ret compare_name_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -2908,22 +3179,6 @@ strcmpi: ret compare_ext: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -2955,22 +3210,6 @@ compare_ext: ret compare_ext_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3021,22 +3260,6 @@ seek_ext: ret compare_modified: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3069,22 +3292,6 @@ compare_modified: ret compare_modified_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3118,22 +3325,6 @@ compare_modified_rev: ret compare_size: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3166,22 +3357,6 @@ compare_size: ret compare_size_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3218,49 +3393,10 @@ compare_unordered: cmp esi, edi ret compare_unordered_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: cmp edi, esi ret -.greater: - test esi, esi - ret -.less: - xor edi, edi - stc - ret compare_created: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3293,22 +3429,6 @@ compare_created: ret compare_created_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3342,22 +3462,6 @@ compare_created_rev: ret compare_accessed: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -3390,22 +3494,6 @@ compare_accessed: ret compare_accessed_rev: - push eax - mov eax, [ebp + panel1_nfa - panel1_data] - add esi, [ebp + panel1_files - panel1_data] - add edi, [ebp + panel1_files - panel1_data] - lea esi, [esi+eax*4+0x20] - lea edi, [edi+eax*4+0x20] - pop eax - cmp word [esi+40], '..' - jnz @f - cmp byte [esi+42], 0 - jz .less -@@: cmp word [edi+40], '..' - jnz @f - cmp byte [edi+42], 0 - jz .greater -@@: test byte [esi], 10h jnz .1dir test byte [edi], 10h @@ -4007,7 +4095,7 @@ find_extension: pop esi ret -header db 'Kolibri Far 0.2',0 +header db 'Kolibri Far 0.21',0 nomem_draw db 'No memory for redraw.',0 .size = $ - nomem_draw @@ -4534,6 +4622,8 @@ panels_ctrlkeys: dd panels_OnKey.f5 dw 0x3F, 1 dd panels_OnKey.shift_f5 + dw 0x41, 0 + dd panels_OnKey.f7 dw 0x42, 0 dd panels_OnKey.f8 dw 0x43, 0x100 @@ -4644,6 +4734,15 @@ delinfo: db 0 dd execdata +mkdirinfo: + dd 9 + dd 0 + dd 0 + dd 0 + dd 0 + db 0 + dd CopyDestEditBuf+12 + if lang eq ru compare_names db 'иИрРмМаАнНсСдД' else @@ -4854,6 +4953,7 @@ fasm db '/rd/1/develop/fasm',0 animage db '/rd/1/animage',0 bConfirmDelete db 1 +bConfirmDeleteIncomplete db 0 ; Здесь заканчиваются конфигурационные данные @@ -4924,7 +5024,7 @@ f8_confirm_dlgdata: .del_x2 dd ? dd 2 dd aDelete -.flags1 dd 4 +.flags1 dd 0xC ; кнопка "отменить" dd 2 .cnl_x1 dd ? @@ -4932,7 +5032,7 @@ f8_confirm_dlgdata: .cnl_x2 dd ? dd 2 dd aCancel -.flags2 dd 0 +.flags2 dd 8 ; диалог копирования copy_dlgdata: @@ -4983,6 +5083,56 @@ copy_dlgdata: dd aCancelB .flags2 dd 8 +mkdir_dlgdata: + dd 1 + dd -1, -1 +.width dd ? +.height dd 4 + dd 4, 2 + dd aMkDirCaption + dd ? + dd 0 + dd 0 + dd 4 +; Строка "Создать папку" + dd 1 + dd 1,0,aMkDirLen,0 + dd aMkDir + dd 0 +; поле редактирования с именем создаваемой папки + dd 3 + dd 1,1 +.width2 dd ? + dd 1 + dd CopyDestEditBuf +.flags0 dd 0xC +; кнопка "Продолжить" +.cont_btn: + dd 2 +.cont_x1 dd ? + dd 3 +.cont_x2 dd ? + dd 3 + dd a_Continue +.flags1 dd 18h +; кнопка "отменить" + dd 2 +.cnl_x1 dd ? + dd 3 +.cnl_x2 dd ? + dd 3 + dd aCancelB +.flags2 dd 8 + +RetryOrCancelBtn: + dd aRetry + dd a_Cancel +DeleteOrKeepBtn: + dd a_Delete + dd aKeep +RetryOrIgnoreBtn: + dd aRetry + dd aIgnore if lang eq ru aDeleteCaption db 'Удаление',0 @@ -4999,11 +5149,15 @@ aCancelBLength = $ - aCancelB - 1 aCopyCaption db 'Копирование',0 aCopy db '[ Копировать ]',0 aCopyLength = $ - aCopy - 1 +a_Continue db '[ Продолжить ]',0 +a_ContinueLength = $ - a_Continue - 1 aCopy1 db 'Копировать "',0 aCopy2 db '" в:',0 aError db 'Ошибка',0 aContinue db 'Продолжить',0 aRetry db 'Повторить',0 +a_Cancel db 'Отменить',0 +a_Delete db 'Удалить',0 error0msg db 'Странно... Нет ошибки',0 error1msg db 'Странно... Не определена база и/или раздел жёсткого диска',0 error2msg db 'Функция не поддерживается для данной файловой системы',0 @@ -5021,6 +5175,22 @@ error31msg db ' error32msg db 'Слишком много процессов',0 aUnknownError db 'Неизвестный код ошибки: ',0 aCannotReadFolder db 'Не могу прочитать папку',0 +aRunError db 'Ошибка при запуске программы:',0 +aFileNameTooBig db 'Полное имя файла слишком длинное',0 +aFolderNameTooBig db 'Полное имя папки слишком длинное',0 +aCmdLineTooBig db 'Командная строка превышает границу OS в 256 символов',0 +aCannotCopyToSelf db 'Файл не может быть скопирован в самого себя',0 +aCannotReadFile db 'Не могу прочитать файл',0 +aIncompleteFile db 'Был получен неполный файл. Удалить его?',0 +aKeep db 'Оставить',0 +aCannotWriteFile db 'Не могу записать в файл',0 +aCannotDeleteFile db 'Не могу удалить файл',0 +aCannotDeleteFolder db 'Не могу удалить папку',0 +aIgnore db 'Игнорировать',0 +aMkDirCaption db 'Создание папки',0 +aMkDir db 'Создать папку',0 +aMkDirLen = $ - aMkDir - 1 +aCannotMakeFolder db 'Не могу создать папку',0 else aDeleteCaption db 'Delete',0 aConfirmDeleteText db 'Do you wish to delete ',0 @@ -5036,11 +5206,15 @@ aCancelBLength = $ - aCancelB - 1 aCopyCaption db 'Copy',0 aCopy db '[ Copy ]',0 aCopyLength = $ - aCopy - 1 +a_Continue db '[ Continue ]',0 +a_ContinueLength = $ - a_Continue - 1 aCopy1 db 'Copy "',0 aCopy2 db '" to:',0 aError db 'Error',0 aContinue db 'Continue',0 aRetry db 'Retry',0 +a_Cancel db 'Cancel',0 +a_Delete db 'Delete',0 error0msg db 'Strange... No error',0 error1msg db 'Strange... Hard disk base and/or partition not defined',0 error2msg db 'The file system does not support this function',0 @@ -5058,6 +5232,22 @@ error31msg db 'File is not executable',0 error32msg db 'Too many processes',0 aUnknownError db 'Unknown error code: ',0 aCannotReadFolder db 'Cannot read folder',0 +aRunError db 'Cannot execute program:',0 +aFileNameTooBig db 'Full file name is too long',0 +aFolderNameTooBig db 'Full folder name is too long',0 +aCmdLineTooBig db 'Command line is too long (OS limit is 256 symbols)',0 +aCannotCopyToSelf db 'File cannot be copied onto itself',0 +aCannotReadFile db 'Cannot read file',0 +aIncompleteFile db 'Incomplete file was retrieved. Delete it?',0 +aKeep db 'Keep',0 +aCannotWriteFile db 'Cannot write file',0 +aCannotDeleteFile db 'Cannot delete file',0 +aCannotDeleteFolder db 'Cannot delete folder',0 +aIgnore db 'Ignore',0 +aMkDirCaption db 'Make folder',0 +aMkDir db 'Create the folder',0 +aMkDirLen = $ - aMkDir - 1 +aCannotMakeFolder db 'Cannot create folder',0 end if aOk db 'OK',0 aNoMemory db 'No memory!',0 @@ -5078,6 +5268,7 @@ i_end: IncludeUGlobals execdata rb 1024 +execdataend: align 4 attrinfo.attr rb 40 @@ -5161,7 +5352,7 @@ active_screen_data dd ? aConfirmDeleteTextBuf rb aConfirmDeleteTextMax + 1 CopySourceTextBuf rb 512 CopyDestEditBuf rb 12+512+1 -.length = $ - CopyDestEditBuf - 9 +.length = $ - CopyDestEditBuf - 13 align 4 layout rb 128 diff --git a/programs/fs/kfar/trunk/viewer.inc b/programs/fs/kfar/trunk/viewer.inc index d87da82ff0..facf5e79df 100644 --- a/programs/fs/kfar/trunk/viewer.inc +++ b/programs/fs/kfar/trunk/viewer.inc @@ -19,9 +19,6 @@ end virtual view_file: mov eax, [ebp + panel1_files - panel1_data] mov ecx, [eax+ecx*4] - mov eax, [ebp + panel1_nfa - panel1_data] - lea ecx, [ecx+eax*4+32] - add ecx, [ebp + panel1_files - panel1_data] test byte [ecx], 10h jz .file ret @@ -59,10 +56,32 @@ view_file: push eax mov ebx, attrinfo mov [ebx+21], eax +.attr_retry: push 70 pop eax int 40h -; TODO: add error handling + test eax, eax + jz @f + lea ebx, [ebp+viewer_data.filename] + push ebx + push aCannotReadFile + call get_error_msg + push eax + mov eax, esp + push RetryOrCancelBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + mov ebx, attrinfo + test eax, eax + jz .attr_retry + jmp delete_active_screen +@@: mov eax, dword [attrinfo.attr+32] mov dword [ebp+viewer_data.filesize], eax mov eax, dword [attrinfo.attr+36] @@ -80,11 +99,35 @@ view_file: mov [readinfo.data], eax mov [ebp+viewer_data.buf_pos], eax pop dword [readinfo.name] +.retry: push 70 pop eax int 40h mov [ebp+viewer_data.buf_size], ebx -; TODO: add error handling + test eax, eax + jz .readok + cmp eax, 6 + jz .readok + lea ebx, [ebp+viewer_data.filename] + push ebx + push aCannotReadFile + call get_error_msg + push eax + mov eax, esp + push RetryOrCancelBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + mov ebx, readinfo + test eax, eax + jz .attr_retry + jmp delete_active_screen +.readok: call viewer_set_keybar call viewer_draw_text ret @@ -118,10 +161,18 @@ viewer_get_next_char: mov [readinfo.data], edi lea eax, [ebp+viewer_data.filename] mov [readinfo.name], eax +.readretry: mov ebx, readinfo push 70 pop eax int 40h + test eax, eax + jz .readok + cmp eax, 6 + jz .readok + call ask_retry_ignore + jz .readretry +.readok: sub [ebp+viewer_data.buf_pos], 8192 add ebx, 16384-8192 mov [ebp+viewer_data.buf_size], ebx @@ -781,6 +832,13 @@ viewer_seek: push 70 pop eax int 40h + test eax, eax + jz .readok + cmp eax, 6 + jz .readok + call ask_retry_ignore + jz .doread +.readok: cmp ebx, [readinfo.size] jnz @f add ebx, [ebp+viewer_data.buf_size] @@ -822,13 +880,44 @@ viewer_seek: mov [ebx+12], eax lea eax, [ebp+viewer_data.filename] mov [ebx+21], eax +@@: push 70 pop eax int 40h + test eax, eax + jz @f + cmp eax, 6 + jz @f + call ask_retry_ignore + jnz @f + mov ebx, readinfo + jmp @b +@@: sub ebx, [readinfo.size] add ebx, 16384 jmp .ret +ask_retry_ignore: + push esi + lea esi, [ebp+viewer_data.filename] + push esi + push aCannotReadFile + call get_error_msg + push eax + mov eax, esp + push RetryOrIgnoreBtn + push 2 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + pop esi + test eax, eax + ret + viewer_set_curpos: mov eax, [ebp+viewer_data.buf_pos] sub eax, ebp