From 21572e62ae5e1c151618e3d0cee91f3a3326577c Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Sat, 10 Feb 2007 11:23:45 +0000 Subject: [PATCH] Fixed creation of files with empty names when writing to '/path/' git-svn-id: svn://kolibrios.org@335 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/rd.inc | 3 + kernel/trunk/fs/fat12.inc | 3 + kernel/trunk/fs/fat32.inc | 147 +------------------------------------ 3 files changed, 10 insertions(+), 143 deletions(-) diff --git a/kernel/trunk/blkdev/rd.inc b/kernel/trunk/blkdev/rd.inc index 1f873e780a..5c5a44b8da 100644 --- a/kernel/trunk/blkdev/rd.inc +++ b/kernel/trunk/blkdev/rd.inc @@ -1514,6 +1514,9 @@ fs_RamdiskRewrite: push ramdisk_root_next jmp .common1 .noroot: + mov eax, ERROR_ACCESS_DENIED + cmp byte [ebp+1], 0 + jz .ret1 ; check existence mov byte [ebp], 0 call rd_find_lfn diff --git a/kernel/trunk/fs/fat12.inc b/kernel/trunk/fs/fat12.inc index 349dfed4ee..366d265326 100644 --- a/kernel/trunk/fs/fat12.inc +++ b/kernel/trunk/fs/fat12.inc @@ -1590,6 +1590,9 @@ fs_FloppyRewrite: push flp_rootmem_next jmp .common1 .noroot: + mov eax, ERROR_ACCESS_DENIED + cmp byte [ebp+1], 0 + jz .ret1 ; check existence mov byte [ebp], 0 call fd_find_lfn diff --git a/kernel/trunk/fs/fat32.inc b/kernel/trunk/fs/fat32.inc index e5e4b8a614..f68238f11b 100644 --- a/kernel/trunk/fs/fat32.inc +++ b/kernel/trunk/fs/fat32.inc @@ -98,7 +98,6 @@ align 4 fat_cache: times 512 db 0 Sector512: ; label for dev_hdcd.inc buffer: times 512 db 0 - deltree_buffer: times 512 db 0 fsinfo_buffer: times 512 db 0 endg @@ -1236,25 +1235,7 @@ file_delete: jc file_to_delete_not_found test byte [ebx+11],0x10 ; is it directory? - jz delete_notdir ; no. it's file - cmp edi,1 ; allow directory remove - jnz delete_no_access ; no - - push eax ; save directory sector - mov eax,[ebx+20-2] ; first cluster of file - mov ax,[ebx+26] ; 0 length files start cluster = 0 - and eax,[fatMASK] - xor ebp,ebp ; counter for directory deepnes - call clear_directory - pop eax - jc delete_no_access - - push ebx ; save directory pointer in buffer - mov ebx,buffer - call hd_read ; read directory sector - cmp [hd_error],0 - jne delete_no_access_1 - pop ebx + jnz delete_no_access delete_notdir: call delete_entry_name @@ -1316,129 +1297,6 @@ clear_cluster_chain: ret -clear_directory: -;----------------------------------------------------- -; input : eax = directory cluster -; ebp = directory deepnes -; Note : use recursive call -;----------------------------------------------------- - pushad - inc ebp - cmp ebp,64 ; if over 63 directory deep - jnb clear_error ; something must be wrong - - clear_new_cluster: - cmp eax,[LAST_CLUSTER] - ja clear_end - cmp eax,[ROOT_CLUSTER] ; don't remove root cluster - jz clear_end - mov esi,eax ; esi = current directory cluster - sub eax,2 - jb clear_end - mov ecx,[SECTORS_PER_CLUSTER] - imul eax,ecx - add eax,[DATA_START] - - clear_new_sector: - mov edi,eax ; edi = current directory sector - mov ebx,deltree_buffer - call hd_read - cmp [hd_error],0 - jne clear_error - - mov edx,512/32 ; count of dir entrys per sector = 16 - - clear_analyze: - mov al,[ebx+11] ; file attribute - and al,0xf - cmp al,0xf - je clear_long_filename - - cmp byte [ebx],'.' ; parent or current directory - je clear_next_entry - cmp byte [ebx],0xe5 ; deleted - je clear_next_entry - cmp byte [ebx],0 ; empty - je clear_write_last - ;je clear_next_entry - - mov eax,[ebx+20-2] ; first cluster of entry - mov ax,[ebx+26] - and eax,[fatMASK] - - test byte [ebx+11],0x10 ; is it directory? - jz clear_file ; no - - push eax ebx - mov eax,edi - mov ebx,deltree_buffer ; save buffer over recursive call - call hd_write ; write directory sector to disk - cmp [hd_error],0 - jne clear_error - - pop ebx eax - - call clear_directory ; recursive call !!! - jc clear_error ; exit if error found - - push eax ebx - mov eax,edi - mov ebx,deltree_buffer - call hd_read ; read directory sector again - cmp [hd_error],0 - jne clear_error_1 - - pop ebx eax - - clear_file: - call clear_cluster_chain - cmp [hd_error],0 - jne clear_error - - clear_long_filename: - mov byte [ebx],0xe5 - - clear_next_entry: - add ebx,32 ; position of next dir entry - dec edx - jnz clear_analyze - - mov eax,edi - mov ebx,deltree_buffer - call hd_write ; write directory sector to disk - cmp [hd_error],0 - jne clear_error - - inc eax ; next sector - dec ecx - jnz clear_new_sector - - mov eax,esi - call get_FAT ; get next cluster - cmp [hd_error],0 - jne clear_error - - jmp clear_new_cluster ; clear it - - clear_write_last: - mov eax,edi - mov ebx,deltree_buffer - call hd_write ; write directory sector to disk - cmp [hd_error],0 - jne clear_error - - clear_end: - popad - clc - ret -clear_error_1: - add esp,8 - clear_error: - popad - stc - ret - - delete_entry_name: ;----------------------------------------------------- ; input : eax = directory sector @@ -2263,6 +2121,9 @@ fs_HdRewrite: push fat16_root_next jmp .common1 .noroot: + mov eax, ERROR_ACCESS_DENIED + cmp byte [ebp+1], 0 + jz .ret1 ; check existence mov byte [ebp], 0 call hd_find_lfn