one-string path for filesystems, some cleaning

git-svn-id: svn://kolibrios.org@6468 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2016-08-02 20:28:34 +00:00
parent 25b23034ea
commit 1048443a57
6 changed files with 376 additions and 587 deletions

View File

@ -1045,8 +1045,7 @@ endg
; This function is called from file_system_lfn.
; This handler gets the control each time when fn 70 is called
; with unknown item of root subdirectory.
; in: esi -> name
; ebp = 0 or rest of name relative to esi
; in: esi = ebp -> path string
; out: if the handler processes path, it must not return in file_system_lfn,
; but instead pop return address and return directly to the caller
; otherwise simply return
@ -1142,6 +1141,25 @@ dyndisk_handler:
@@:
; 11c. Let the procedure from fs_lfn.inc do the job.
jmp file_system_lfn.maindir_noesi
.access_denied:
mov dword [esp+32], ERROR_ACCESS_DENIED
mov esi, ecx ; disk*dereference assume that esi points to DISK
.cleanup_esi:
test edx, edx ; if there are no media, we didn't reference it
jz @f
call disk_media_dereference
@@:
call disk_dereference
stdcall kernel_free, ebp
ret
.dyndisk_cleanup:
pop esi
pop edx
mov dword [esp+32], ERROR_FILE_NOT_FOUND
jmp .cleanup_esi
.haspartition:
; 12. The fs operation has specified some partition.
push edx
@ -1160,36 +1178,84 @@ dyndisk_handler:
jnz .dyndisk_cleanup
dec esi
@@:
cmp byte [esi], 0
jnz @f
test ebp, ebp
jz @f
mov esi, ebp
xor ebp, ebp
@@:
jmp fs_dyndisk
.dyndisk_cleanup:
pop esi
dec ecx ; convert to zero-based partition index
pop edx ; edx = pointer to DISK, dword [esp] = NULL or edx
; If the driver does not support insert notifications and we are the only fs
; operation with this disk, ask the driver whether the media
; was inserted/removed/changed. Otherwise, assume that media status is valid.
test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION
jz .media_accurate
push ecx esi
mov esi, edx
cmp dword [esp+8], 0
jz .test_no_media
cmp [esi+DISK.MediaRefCount], 2
jnz .media_accurate_pop
lea edx, [esi+DISK.MediaInfo]
and [edx+DISKMEDIAINFO.Flags], 0
mov al, DISKFUNC.querymedia
stdcall disk_call_driver, edx
test eax, eax
jz .media_accurate_pop
stdcall disk_media_dereference ; drop our reference so that disk_media_changed could close the media
stdcall disk_media_changed, esi, 0
and dword [esp+8], 0 ; no media
.test_no_media:
stdcall disk_media_changed, esi, 1 ; issue fake notification
; if querymedia() inside disk_media_changed returns error, the notification is ignored
cmp [esi+DISK.MediaInserted], 0
jz .media_accurate_pop
lock inc [esi+DISK.MediaRefCount]
mov dword [esp+8], esi
.media_accurate_pop:
mov edx, esi
pop esi ecx
.media_accurate:
pop eax
test eax, eax
jz .nomedia
cmp ecx, [edx+DISK.NumPartitions]
jae .notfound2
mov eax, [edx+DISK.Partitions]
mov eax, [eax+ecx*4]
mov edi, [eax+PARTITION.FSUserFunctions]
mov ecx, [ebx]
cmp [edi+4], ecx
jbe .unsupported
push edx
push ebp
mov ebp, eax
call dword [edi+8+ecx*4]
pop ebp
pop edx
mov dword [esp+32], ERROR_FILE_NOT_FOUND
jmp .cleanup_esi
.access_denied:
; 13. Fail the operation with the appropriate code.
mov dword [esp+32], ERROR_ACCESS_DENIED
mov dword [esp+32], eax
mov dword [esp+20], ebx
.cleanup:
; 14. Cleanup.
mov esi, ecx ; disk*dereference assume that esi points to DISK
.cleanup_esi:
test edx, edx ; if there are no media, we didn't reference it
jz @f
mov esi, edx
call disk_media_dereference
@@:
call disk_dereference
; 15. Return.
stdcall kernel_free, ebp
ret
.unsupported:
mov dword [esp+32], ERROR_UNKNOWN_FS
cmp edi, default_fs_functions
jz .cleanup
mov dword [esp+32], ERROR_UNSUPPORTED_FS
jmp .cleanup
.notfound2:
mov dword [esp+32], ERROR_FILE_NOT_FOUND
jmp .cleanup
.nomedia:
test ecx, ecx
jnz .notfound2
mov dword [esp+32], ERROR_DEVICE
mov esi, edx
jmp @b
; This is a callback for enumerating partitions called from
; file_system_lfn.maindir in the case of inserted media.
; It just increments eax until DISK.NumPartitions reached and then
@ -1228,86 +1294,6 @@ fs_dyndisk_next_nomedia:
stc
ret
; esp -> {dd pointer to DISK, dd media object}
; ecx = partition number, esi+ebp = ASCIIZ name
fs_dyndisk:
dec ecx ; convert to zero-based partition index
pop edx ; edx = pointer to DISK, dword [esp] = NULL or edx
; If the driver does not support insert notifications and we are the only fs
; operation with this disk, ask the driver whether the media
; was inserted/removed/changed. Otherwise, assume that media status is valid.
test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION
jz .media_accurate
push ecx esi
mov esi, edx
cmp dword [esp+8], 0
jz .test_no_media
cmp [esi+DISK.MediaRefCount], 2
jnz .media_accurate_pop
lea edx, [esi+DISK.MediaInfo]
and [edx+DISKMEDIAINFO.Flags], 0
mov al, DISKFUNC.querymedia
stdcall disk_call_driver, edx
test eax, eax
jz .media_accurate_pop
stdcall disk_media_dereference ; drop our reference so that disk_media_changed could close the media
stdcall disk_media_changed, esi, 0
and dword [esp+8], 0 ; no media
.test_no_media:
stdcall disk_media_changed, esi, 1 ; issue fake notification
; if querymedia() inside disk_media_changed returns error, the notification is ignored
cmp [esi+DISK.MediaInserted], 0
jz .media_accurate_pop
lock inc [esi+DISK.MediaRefCount]
mov dword [esp+8], esi
.media_accurate_pop:
mov edx, esi
pop esi ecx
.media_accurate:
pop eax
test eax, eax
jz .nomedia
.main:
cmp ecx, [edx+DISK.NumPartitions]
jae .notfound
mov eax, [edx+DISK.Partitions]
mov eax, [eax+ecx*4]
mov edi, [eax+PARTITION.FSUserFunctions]
mov ecx, [ebx]
cmp [edi+4], ecx
jbe .unsupported
push edx
push ebp
mov ebp, eax
call dword [edi+8+ecx*4]
pop ebp
pop edx
mov dword [esp+32], eax
mov dword [esp+20], ebx
.cleanup:
mov esi, edx
call disk_media_dereference
call disk_dereference
ret
.nofs:
mov dword [esp+32], ERROR_UNKNOWN_FS
jmp .cleanup
.notfound:
mov dword [esp+32], ERROR_FILE_NOT_FOUND
jmp .cleanup
.unsupported:
cmp edi, default_fs_functions
jz .nofs
mov dword [esp+32], ERROR_UNSUPPORTED_FS
jmp .cleanup
.nomedia:
test ecx, ecx
jnz .notfound
mov dword [esp+32], ERROR_DEVICE
mov esi, edx
call disk_dereference
ret
; This function is called from file_system_lfn.
; This handler is called when virtual root is enumerated
; and must return all items which can be handled by this.

View File

@ -11,7 +11,7 @@ $Revision$
; in:
; ebx -> parameter structure of sysfunc 70
; ebp -> EXTFS structure
; [esi]+[[esp+4]] = name
; esi -> path string
; out:
; eax, ebx = return values for sysfunc 70
iglobal
@ -1444,12 +1444,12 @@ findInode_parent:
pop esi
.get_inode:
push ebx edx
stdcall findInode, 0
call findInode
pop edx ebx
ret
findInode:
; in: [esi]+[[esp+4]] = name
; in: esi -> path string
; out:
; [ebp+EXTFS.mainInodeBuffer] = inode
; esi = inode number
@ -1469,7 +1469,7 @@ findInode:
xor eax, eax
xor dl, dl
mov esi, ROOT_INODE
ret 4
ret
.next_path_part:
push [edx+INODE.sectorsUsed]
@ -1534,12 +1534,7 @@ findInode:
cmp edi, esi
je .next_folder_block
cmp byte [esi], 0
jnz @f
cmp dword[esp+8], 0
je .get_inode_ret
mov esi, [esp+8]
mov dword[esp+8], 0
@@:
mov eax, [ebx+DIRENTRY.inodeNumber]
lea ebx, [ebp+EXTFS.mainInodeBuffer]
call readInode
@ -1567,18 +1562,18 @@ findInode:
lea ebx, [ebp+EXTFS.mainInodeBuffer]
mov esi, eax
call readInode
ret 4
ret
.not_found:
movi eax, ERROR_FILE_NOT_FOUND
stc
ret 4
ret
.error_get_block:
pop ebx
.error_get_inode:
pop ebx
ret 4
ret
writeSuperblock:
push ebx
@ -1614,7 +1609,7 @@ ext_ReadFolder:
cmp byte [esi], 0
jz .root_folder
push ebx
stdcall findInode, [esp+4+4]
call findInode
pop ebx
jc .error_ret
lea esi, [ebp+EXTFS.mainInodeBuffer]
@ -1801,7 +1796,7 @@ ext_ReadFile:
cmp byte [esi], 0
jz .error ; root
mov [esp], ebx
stdcall findInode, [esp+4+4]
call findInode
pop ebx
jc .error_eax
push ERROR_ACCESS_DENIED
@ -1931,7 +1926,7 @@ ext_GetFileInfo:
cmp byte [esi], 0
jz .is_root
push edx
stdcall findInode, [esp+4+4]
call findInode
mov ebx, edx
pop edx
lea esi, [ebp+EXTFS.mainInodeBuffer]
@ -1982,7 +1977,7 @@ ext_GetFileInfo:
ext_SetFileInfo:
call extfsWritingInit
pushd [ebx+16]
stdcall findInode, [esp+4+4]
call findInode
pop edx
jc @f
push esi ; inode number
@ -2014,7 +2009,7 @@ ext_SetFileInfo:
ext_Delete:
call extfsWritingInit
push esi
stdcall findInode, [esp+4+4]
call findInode
mov ebx, esi
pop esi
push eax
@ -2216,7 +2211,7 @@ ext_Delete:
ext_CreateFolder:
call extfsWritingInit
push esi
stdcall findInode, [esp+4+4]
call findInode
pop esi
jnc .success ; exist
call findInode_parent
@ -2300,12 +2295,12 @@ parent_link db "..", 0
ext_CreateFile:
call extfsWritingInit
push ebx esi
stdcall findInode, [esp+8+4]
call findInode
mov esi, [esp]
jc @f
call ext_unlock
stdcall ext_Delete, [esp+8+4]
mov [esp], eax
call ext_Delete
push eax
call ext_lock
pop eax
test eax, eax
@ -2359,7 +2354,7 @@ ext_CreateFile:
ext_WriteFile:
call extfsWritingInit
push 0 ebx
stdcall findInode, [esp+8+4]
call findInode
jc .error
lea edx, [ebp+EXTFS.mainInodeBuffer]
movi eax, ERROR_ACCESS_DENIED
@ -2482,7 +2477,7 @@ ext_WriteFile:
ext_SetFileEnd:
call extfsWritingInit
pushd [ebx+4]
stdcall findInode, [esp+4+4]
call findInode
pop ecx
jc @f
lea edx, [ebp+EXTFS.mainInodeBuffer]

View File

@ -1,50 +1,37 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; FAT functions for KolibriOS ;;
;; ;;
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;;
;; See file COPYING for details ;;
;; 06.2015 fs_read64 - pathoswithin ;;
;; 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 ;;
;; 23.06.2006 LFN start application - diamond ;;
;; 15.06.2006 LFN get/set file/folder info - diamond ;;
;; 27.05.2006 LFN create/rewrite file - diamond ;;
;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;;
;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;;
;; 23.11.2004 don't allow overwrite dir with file - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;;
;; 10.11.2004 removedir clear whole directory structure - ATV ;;
;; 08.11.2004 rename - ATV ;;
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
;; 20.10.2004 Makedir/Removedir - ATV ;;
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
;; 06.09.2004 Fix free space - Mario79 ;;
;; 24.05.2004 Write back buffer for File_write - VT ;;
;; 20.05.2004 File_read function to work with syscall 58 - VT ;;
;; 30.03.2004 Error parameters at function return - VT ;;
;; 29.06.2002 Improved fat32 verification - VT ;;
;; 20.05.2002 Hd status check - VT ;;
;; 01.05.2002 Bugfix in device write - VT ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
; FAT external functions
; in:
; ebx -> parameter structure of sysfunc 70
; ebp -> FAT structure
; esi -> path string
; out:
; eax, ebx = return values for sysfunc 70
iglobal
align 4
fat_user_functions:
dd fat_free
dd (fat_user_functions_end - fat_user_functions - 4) / 4
dd fat_Read
dd fat_ReadFolder
dd fat_CreateFile
dd fat_Write
dd fat_SetFileEnd
dd fat_GetFileInfo
dd fat_SetFileInfo
dd 0
dd fat_Delete
dd fat_CreateFolder
fat_user_functions_end:
endg
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
PUSHAD_EAX equ [esp+28]
@ -57,84 +44,56 @@ PUSHAD_EDI equ [esp+0]
; Internal data for every FAT partition.
struct FAT PARTITION
fs_type db ?
fat16_root db 0 ; flag for fat16 rootdir
fat_change db 0 ; 1=fat has changed
rb 1
Lock MUTEX ? ; currently operations with one partition
fs_type db ?
fat_change db ? ; 1=fat has changed
rb 2
Lock MUTEX ; currently operations with one partition
; can not be executed in parallel since the legacy code is not ready
SECTORS_PER_FAT dd 0x1f3a
NUMBER_OF_FATS dd 0x2
SECTORS_PER_CLUSTER dd 0x8
BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes
ROOT_CLUSTER dd 2 ; first rootdir cluster
FAT_START dd 0 ; start of fat table
ROOT_START dd 0 ; start of rootdir (only fat16)
ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16)
DATA_START dd 0 ; start of data area (=first cluster 2)
LAST_CLUSTER dd 0 ; last availabe cluster
ADR_FSINFO dd 0 ; used only by fat32
fatRESERVED dd 0x0FFFFFF6
fatBAD dd 0x0FFFFFF7
fatEND dd 0x0FFFFFF8
fatMASK dd 0x0FFFFFFF
fatStartScan dd 2
cluster_tmp dd 0 ; used by analyze_directory
; and analyze_directory_to_write
longname_sec1 dd 0 ; used by analyze_directory to save 2 previous
longname_sec2 dd 0 ; directory sectors for delete long filename
fat_in_cache dd -1
SECTORS_PER_FAT dd ?
NUMBER_OF_FATS dd ?
SECTORS_PER_CLUSTER dd ?
BYTES_PER_SECTOR dd ? ; Note: if BPS <> 512 need lots of changes
ROOT_CLUSTER dd ? ; first rootdir cluster
FAT_START dd ? ; start of fat table
ROOT_START dd ? ; start of rootdir (only fat16)
ROOT_SECTORS dd ? ; count of rootdir sectors (only fat16)
DATA_START dd ? ; start of data area (=first cluster 2)
LAST_CLUSTER dd ? ; last availabe cluster
ADR_FSINFO dd ? ; used only by fat32
fatRESERVED dd ?
fatBAD dd ?
fatEND dd ?
fatMASK dd ?
fatStartScan dd ?
cluster_tmp dd ? ; used by analyze_directory and analyze_directory_to_write
longname_sec1 dd ? ; used by analyze_directory to save 2 previous
longname_sec2 dd ? ; directory sectors for delete long filename
fat_in_cache dd ?
; For FAT16/FAT32, this points to 512-byte buffer for the current sector of FAT.
; For FAT12, the entire FAT structure is read
; and unpacked from 12bit per cluster to word per cluster.
; Note: work with unpacked copy of FAT12 means
; additional memory and additional code for packing/unpacking.
; I'm not sure that the economy justifies the cost, but anyway,
; there is how work was done before my edits, and I'm just keeping the principle.
fat_cache_ptr dd ?
fat12_unpacked_ptr dd ?
buffer rb 512
fsinfo_buffer rb 512
fat_cache_ptr dd ?
fat12_unpacked_ptr dd ?
buffer rb 512
fsinfo_buffer rb 512
ends
uglobal
align 4
partition_count dd 0 ; partitions found by set_FAT32_variables
hd_error dd 0
hd_setup dd 0
hd_wait_timeout dd 0
cache_search_start dd 0 ; used by find_empty_slot
endg
uglobal
align 4
partition_count dd ? ; partitions found by set_FAT32_variables
hd_error dd ?
hd_setup dd ?
hd_wait_timeout dd ?
cache_search_start dd ? ; used by find_empty_slot
Sector512: ; label for dev_hdcd.inc
buffer:
rb 512
endg
iglobal
align 4
fat_user_functions:
dd fat_free
dd (fat_user_functions_end - fat_user_functions - 4) / 4
dd fat_Read
dd fat_ReadFolder
dd fat_Rewrite
dd fat_Write
dd fat_SetFileEnd
dd fat_GetFileInfo
dd fat_SetFileInfo
dd 0
dd fat_Delete
dd fat_CreateFolder
fat_user_functions_end:
endg
; these labels are located before the main function to make
; most of jumps to these be short
fat_create_partition.free_return0:
@ -1598,11 +1557,9 @@ bdfe_to_fat_entry:
ret
hd_find_lfn:
; in: ebp -> FAT structure
; in: esi+[esp+4] -> name
; in: esi -> path string
; out: CF=1 - file not found, eax=error code
; else CF=0 and edi->direntry, eax=sector
; destroys eax
push esi edi
push 0
push 0
@ -1618,7 +1575,6 @@ hd_find_lfn:
jc .notfound
cmp byte [esi], 0
jz .found
.continue:
test byte [edi+11], 10h
jz .notfound
and dword [esp+12], 0
@ -1629,38 +1585,28 @@ hd_find_lfn:
mov dword [esp+4], fat_notroot_first
mov dword [esp], fat_notroot_next
jmp .loop
.notfound:
add esp, 16
pop edi esi
stc
ret 4
ret
.found:
lea eax, [esp+4+24]
cmp dword [eax], 0
jz @f
mov esi, [eax]
and dword [eax], 0
jmp .continue
@@:
lea eax, [esp+8]
cmp dword [eax], 0
jz .root
call fat_get_sector
jmp .cmn
.root:
mov eax, [eax+4]
add eax, [ebp+FAT.ROOT_START]
.cmn:
add esp, 20 ; CF=0
pop esi
ret 4
ret
;----------------------------------------------------------------
; fat_Read - FAT implementation of reading a file
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_Read:
call fat_lock
@ -1674,7 +1620,7 @@ fat_Read:
mov eax, ERROR_ACCESS_DENIED
ret
@@:
stdcall hd_find_lfn, [esp+8]
call hd_find_lfn
jnc .found
pop edi
push eax
@ -1850,12 +1796,6 @@ fat_Read:
xor ecx, ecx
jmp .fragmentEnd
;----------------------------------------------------------------
; fat_ReadFolder - FAT implementation of reading a folder
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_ReadFolder:
call fat_lock
@ -1863,7 +1803,7 @@ fat_ReadFolder:
push edi
cmp byte [esi], 0
jz .doit
stdcall hd_find_lfn, [esp+4+4]
call hd_find_lfn
jnc .found
pop edi
push eax
@ -2253,27 +2193,14 @@ fshrad:
xor ebx, ebx
ret
;----------------------------------------------------------------
; fat_CreateFolder - FAT implementation of creating a folder
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_CreateFolder:
push 1
jmp fat_Rewrite.common
jmp @f
;----------------------------------------------------------------
; fat_Rewrite - FAT implementation of creating a new file
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_Rewrite:
fat_CreateFile:
push 0
.common:
@@:
call fat_lock
pop eax
cmp byte [esi], 0
@ -2282,11 +2209,7 @@ fat_Rewrite:
mov edx, [ebx+16]
pushad
xor edi, edi
mov edx, [esp+4+20h]
push esi
test edx, edx
jz @f
mov esi, edx
@@:
lodsb
test al, al
@ -2295,12 +2218,11 @@ fat_Rewrite:
jnz @b
lea edi, [esi-1]
jmp @b
@@:
pop esi
test edi, edi
jnz .noroot
test edx, edx
jnz .hasebp
mov edx, [ebp+FAT.ROOT_CLUSTER]
cmp [ebp+FAT.fs_type], 32
jz .pushnotroot
@ -2315,14 +2237,7 @@ fat_Rewrite:
push fat1x_root_first
push fat1x_root_next
jmp .common1
.hasebp:
mov eax, ERROR_ACCESS_DENIED
cmp byte [edx], 0
jz .ret1
stdcall hd_find_lfn, 0
mov esi, [esp+4+20h]
jc .ret1
jmp .common0
.noroot:
mov eax, ERROR_ACCESS_DENIED
cmp byte [edi+1], 0
@ -2330,7 +2245,7 @@ fat_Rewrite:
; check existence
mov byte [edi], 0
push edi
stdcall hd_find_lfn, [esp+4+24h]
call hd_find_lfn
pop esi
mov byte [esi], '/'
jnc @f
@ -2342,15 +2257,15 @@ fat_Rewrite:
popad
xor ebx, ebx
ret
@@:
inc esi
.common0:
test byte [edi+11], 0x10 ; must be directory
mov eax, ERROR_ACCESS_DENIED
jz .ret1
mov edx, [edi+20-2]
mov dx, [edi+26] ; ebp=cluster
mov eax, ERROR_FAT_TABLE
mov eax, ERROR_FS_FAIL
cmp edx, 2
jb .ret1
.pushnotroot:
@ -2366,11 +2281,9 @@ fat_Rewrite:
.common1:
call fat_find_lfn
jc .notfound
; 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"
; found directory
add esp, 36
call fat_unlock
popad
@ -2381,9 +2294,8 @@ fat_Rewrite:
@@:
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+36+28], 0
jz @f
add esp, 36
@ -2392,8 +2304,8 @@ fat_Rewrite:
mov eax, ERROR_ACCESS_DENIED
xor ebx, ebx
ret
@@:
; delete FAT chain
@@: ; delete FAT chain
push edi
xor eax, eax
mov dword [edi+28], eax ; zero size
@ -2415,17 +2327,20 @@ fat_Rewrite:
jc .done1
inc ecx
jmp @b
.done1:
pop edi
call get_time_for_file
mov [edi+22], ax
call get_date_for_file
mov [edi+24], ax
mov [edi+18], ax
or byte [edi+11], 20h ; set 'archive' attribute
jmp .doit
.notfound:
; file is not found; generate short name
.short_name_found:
pop ecx edi esi
call fat_next_short_name
jnc .test_short_name_loop
.disk_full:
add esp, 12+36
call fat_unlock
popa
mov eax, ERROR_DISK_FULL
xor ebx, ebx
ret
.notfound: ; generate short name
call fat_name_is_legal
jc @f
add esp, 36
@ -2434,6 +2349,7 @@ fat_Rewrite:
mov eax, ERROR_FILE_NOT_FOUND
xor ebx, ebx
ret
@@:
sub esp, 12
mov edi, esp
@ -2459,18 +2375,6 @@ fat_Rewrite:
lea eax, [esp+12+12+8]
call dword [eax-8]
jnc .test_short_name_entry
jmp .found
.short_name_found:
pop ecx edi esi
call fat_next_short_name
jnc .test_short_name_loop
.disk_full:
add esp, 12+36
call fat_unlock
popa
mov eax, ERROR_DISK_FULL
xor ebx, ebx
ret
.found:
pop ecx edi esi
; now find space in directory
@ -2489,6 +2393,7 @@ fat_Rewrite:
inc esi
inc eax
jmp @b
@@:
sub esi, eax
add eax, 12+13
@ -2518,6 +2423,7 @@ fat_Rewrite:
mov eax, ERROR_DEVICE
xor ebx, ebx
ret
.scan_dir:
cmp byte [edi], 0
jz .free
@ -2544,6 +2450,7 @@ fat_Rewrite:
mov eax, ERROR_DISK_FULL
xor ebx, ebx
ret
.free:
test ecx, ecx
jnz @f
@ -2564,17 +2471,17 @@ fat_Rewrite:
; on a full disk.
; yup, the argument is quite non-intuitive... but what should I do if
; the entire function uses such arguments? BTW, it refers to al from pushad,
; which in turn is filled with 0 in fat_Rewrite and 1 in fat_CreateFolder.
; which in turn is filled with 0 in fat_CreateFile and 1 in fat_CreateFolder.
cmp byte [esp+8+12+8+12+36+28], 0
jz .no.preallocate.folder.data
call get_free_FAT
jnc @f
add esp, 8+12+8
jmp .disk_full
@@:
mov [esp+8+12+8+12+36+20], eax ; store the cluster somewhere
.no.preallocate.folder.data:
; calculate name checksum
.no.preallocate.folder.data: ; calculate name checksum
mov esi, [esp+8+12]
mov ecx, 11
xor eax, eax
@ -2622,8 +2529,6 @@ fat_Rewrite:
loop .writelfn
pop eax
pop esi
; lea eax, [esp+8+12+8]
; call dword [eax+16] ; end write
.nolfn:
xchg esi, [esp]
mov ecx, 11
@ -2659,6 +2564,15 @@ fat_Rewrite:
push ecx
push edi
jmp .doit2
.done1:
pop edi
call get_time_for_file
mov [edi+22], ax
call get_date_for_file
mov [edi+24], ax
mov [edi+18], ax
or byte [edi+11], 20h ; set 'archive' attribute
.doit:
mov esi, [esp+36+20]
lea eax, [esp+8]
@ -2690,7 +2604,6 @@ fat_Rewrite:
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
add eax, [ebp+FAT.DATA_START]
push [ebp+FAT.SECTORS_PER_CLUSTER]
; write data
.write_sector:
cmp byte [esp+20+36+28], 0
jnz .writedir
@ -2701,6 +2614,7 @@ fat_Rewrite:
mov ebx, esi
add esi, ecx
jmp .writecommon
.writeshort:
mov ecx, [esp+12]
push ecx
@ -2741,14 +2655,17 @@ fat_Rewrite:
pop edx
xchg eax, ecx
jmp .write_cluster
.diskfull:
mov eax, ERROR_DISK_FULL
jmp .ret
.writeerr:
pop eax eax
sub esi, ecx
mov eax, ERROR_DEVICE
jmp .ret
.writedone:
pop eax eax
.done:
@ -2777,6 +2694,7 @@ fat_Rewrite:
call fat_unlock
popad
ret
.writedir:
push 512
lea edi, [ebp+FAT.buffer]
@ -2830,38 +2748,27 @@ fat_read_symbols:
loop fat_read_symbols
ret
fat_Write.access_denied:
push ERROR_ACCESS_DENIED
fat_Write.ret0:
pop eax
xor ebx, ebx
ret
fat_Write.ret11:
push ERROR_DEVICE
jmp fat_Write.ret0
;----------------------------------------------------------------
; fat_Write - FAT implementation of writing to file
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_Write:
cmp byte [esi], 0
jz .access_denied
call fat_lock
push edi
stdcall hd_find_lfn, [esp+4+4]
call hd_find_lfn
jnc .found
pop edi
push eax
call fat_unlock
.ret0:
pop eax
xor ebx, ebx
ret
.access_denied:
push ERROR_ACCESS_DENIED
jmp .ret0
.found:
; FAT does not support files larger than 4GB
.found: ; FAT does not support files larger than 4GB
cmp dword [ebx+8], 0
jz @f
.eof:
@ -2875,20 +2782,17 @@ fat_Write:
mov ebx, [ebx+4]
; now edi points to direntry, ebx=start byte to write,
; ecx=number of bytes to write, edx=data pointer
; extend file if needed
add ecx, ebx
jc .eof ; FAT does not support files larger than 4GB
push edx
push eax ; save directory sector
push 0 ; return value=0
call get_time_for_file
mov [edi+22], ax ; last write time
call get_date_for_file
mov [edi+24], ax ; last write date
mov [edi+18], ax ; last access date
push dword [edi+28] ; save current file size
cmp ecx, [edi+28]
jbe .length_ok
@ -2949,7 +2853,7 @@ fat_Write:
mov byte [esp+8], ERROR_DEVICE
jmp .ret
.fat_err:
mov byte [esp+8], ERROR_FAT_TABLE
mov byte [esp+8], ERROR_FS_FAIL
jmp .ret
@@:
@ -3074,7 +2978,7 @@ hd_extend_file.zero_size:
; extends file on hd to given size (new data area is undefined)
; in: edi->direntry, ecx=new size
; out: CF=0 => OK, eax=0
; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL or ERROR_DEVICE)
; CF=1 => error, eax=code (ERROR_FS_FAIL or ERROR_DISK_FULL or ERROR_DEVICE)
hd_extend_file:
push esi
mov esi, [ebp+FAT.SECTORS_PER_CLUSTER]
@ -3106,7 +3010,7 @@ hd_extend_file:
jb .last_loop
.fat_err:
pop ecx esi
push ERROR_FAT_TABLE
push ERROR_FS_FAIL
jmp .ret_err
.last_found:
push eax
@ -3177,13 +3081,6 @@ fat_update_datetime:
mov [edi+18], ax ; last access date
ret
;----------------------------------------------------------------
; fat_SetFileEnd - FAT implementation of setting end-of-file
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_SetFileEnd:
call fat_lock
@ -3198,7 +3095,7 @@ fat_SetFileEnd:
pop edi
ret
@@:
stdcall hd_find_lfn, [esp+4+4]
call hd_find_lfn
jnc @f
.reteax:
push eax
@ -3409,21 +3306,15 @@ fat_SetFileEnd:
ret
.error_fat:
pop eax
mov byte [esp], ERROR_FAT_TABLE
mov byte [esp], ERROR_FS_FAIL
jmp .pop_ret
.error_fat2:
pop eax ecx eax edi
call update_disk
call fat_unlock
movi eax, ERROR_FAT_TABLE
movi eax, ERROR_FS_FAIL
ret
;----------------------------------------------------------------
; fat_GetFileInfo - FAT implementation of getting file info
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_GetFileInfo:
cmp byte [esi], 0
@ -3433,7 +3324,7 @@ fat_GetFileInfo:
@@:
push edi
call fat_lock
stdcall hd_find_lfn, [esp+4+4]
call hd_find_lfn
jc .error
push ebp
xor ebp, ebp
@ -3452,12 +3343,6 @@ fat_GetFileInfo:
pop edi
ret
;----------------------------------------------------------------
; fat_SetFileInfo - FAT implementation of setting file info
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_SetFileInfo:
cmp byte [esi], 0
@ -3467,7 +3352,7 @@ fat_SetFileInfo:
@@:
push edi
call fat_lock
stdcall hd_find_lfn, [esp+4+4]
call hd_find_lfn
jc .error
push eax
mov edx, [ebx+16]
@ -3487,12 +3372,6 @@ fat_SetFileInfo:
pop edi
ret
;----------------------------------------------------------------
; fat_Delete - FAT implementation of deleting a file/folder
; in: ebp = pointer to FAT structure
; in: esi+[esp+4] = name
; in: ebx = pointer to parameters from sysfunc 70
; out: eax, ebx = return values for sysfunc 70
;----------------------------------------------------------------
fat_Delete:
call fat_lock
@ -3510,7 +3389,7 @@ fat_Delete:
and [ebp+FAT.longname_sec1], 0
and [ebp+FAT.longname_sec2], 0
push edi
stdcall hd_find_lfn, [esp+4+4]
call hd_find_lfn
jnc .found
pop edi
push ERROR_FILE_NOT_FOUND
@ -3577,7 +3456,7 @@ fat_Delete:
popad
pop edi
call fat_unlock
movi eax, ERROR_FAT_TABLE
movi eax, ERROR_FS_FAIL
ret
.notempty:
popad

View File

@ -16,12 +16,13 @@ ERROR_FILE_NOT_FOUND = 5
ERROR_END_OF_FILE = 6
ERROR_MEMORY_POINTER = 7
ERROR_DISK_FULL = 8
ERROR_FAT_TABLE = 9 ;deprecated
ERROR_FS_FAIL = 9
ERROR_ACCESS_DENIED = 10
ERROR_DEVICE = 11
ERROR_OUT_OF_MEMORY = 12
maxPathLength = 1000h
image_of_eax EQU esp+32
image_of_ebx EQU esp+20
@ -50,25 +51,11 @@ file_system_lfn:
; start application
; 8 = delete file/folder
; 9 = create folder
lea esi, [ebx+20]
lodsb
test al, al
lea ebp, [ebx+20]
cmp byte [ebp], 0
jnz @f
mov esi, [esi]
lodsb
mov ebp, [ebx+21]
@@:
lea ebp, [esi-1]
if 0
cmp [ebx], dword 0
jne .1
DEBUGF 1,'read file %s\n',ebp
jmp @f
.1:
cmp [ebx], dword 5
jne @f
DEBUGF 1,'get file attributes %s\n',ebp
@@:
end if
cmp dword[ebx], 7 ; start application
jne @f
mov edx, [ebx+4]
@ -78,29 +65,24 @@ end if
ret
@@:
cmp al, '/'
jz .notcurdir
dec esi
mov ebp, esi
test al, al
jnz @f
xor ebp, ebp
@@:
mov esi, [current_slot]
mov esi, [esi+APPDATA.cur_dir]
jmp .parse_normal
.notcurdir:
cmp byte [esi], 0
cmp word [ebp], '/'
jz .rootdir
call process_replace_file_name
.parse_normal:
mov ax, [esi]
stdcall kernel_alloc, maxPathLength
push ebx
mov ebx, ebp
mov ebp, eax
push maxPathLength
push eax
call get_full_file_name
pop ebx
mov esi, ebp
mov ax, [ebp]
or ax, 2020h
cmp ax, 'cd'
jz .CD
call dyndisk_handler ; not returns if success
.notfound:
stdcall kernel_free, ebp
mov dword[image_of_eax], ERROR_FILE_NOT_FOUND
ret
@ -125,13 +107,6 @@ end if
cmp byte [esi], '/'
jnz @f
inc esi
@@:
cmp byte [esi], 0
jnz @f
test ebp, ebp
jz @f
mov esi, ebp
xor ebp, ebp
@@:
call reserve_cd
mov eax, edi
@ -160,15 +135,12 @@ end if
jae @f
add ebx, 4
call dword[fs_CdServices + eax*4]
call free_cd_channel
and [cd_status], 0
mov [image_of_eax], eax
mov [image_of_ebx], ebx
ret
@@:
call free_cd_channel
and [cd_status], 0
stdcall kernel_free, ebp
ret
.nextCD:
@ -183,12 +155,15 @@ end if
.maindir: ; list partitions
mov esi, .nextCD
.maindir_noesi: ; backjump from dyndisk_handler
push ebp
mov ebp, ecx
call kernel_free
cmp dword[ebx], 1
jnz .access_denied ; read folder?
push ecx
push ebp
pushd [ebx+4] ; first block
mov ebp, [ebx+12] ; the number of blocks to read
mov edx, [ebx+16] ; where to write the result
push dword[ebx+4] ; first block
mov edx, [ebx+16] ; buffer
mov ebx, [ebx+8] ; flags
mov ecx, 32/4
mov edi, edx
@ -293,8 +268,8 @@ end if
add edi, 8
xor eax, eax
rep stosd
push esi edi
lea esi, [esp+12]
push edi
lea esi, [esp+8]
cmp ebx, 1
jz .uni2
@@:
@ -302,7 +277,7 @@ end if
stosb
test eax, eax
jnz @b
pop edi esi eax
pop edi eax
add edi, 264
jmp .rootdir_loop
@ -311,7 +286,7 @@ end if
stosw
test eax, eax
jnz .uni2
pop edi esi eax
pop edi eax
add edi, 520
jmp .rootdir_loop
@ -370,23 +345,6 @@ end if
mov [image_of_ebx], ebx
ret
fs_NotImplemented:
mov eax, 2
ret
;-----------------------------------------------------------------------------
fs_CdServices:
dd fs_CdRead
dd fs_CdReadFolder
dd fs_NotImplemented
dd fs_NotImplemented
dd fs_NotImplemented
dd fs_CdGetFileInfo
dd fs_NotImplemented
dd 0
dd fs_NotImplemented
dd fs_NotImplemented
fs_NumCdServices = ($ - fs_CdServices)/4
;-----------------------------------------------------------------------------
process_replace_file_name:
; in: [esi] = virtual path
@ -476,14 +434,12 @@ sys_current_directory: ; sysfunction 30
@@:
ret
max_cur_dir equ 0x1000 ; length
.get: ; in: ecx -> buffer, edx = length
mov ebx, edi ; buffer
push ecx
push edi
xor eax, eax
mov ecx, max_cur_dir
mov ecx, maxPathLength
repne scasb
jnz .error
sub edi, ebx
@ -511,7 +467,7 @@ max_cur_dir equ 0x1000 ; length
.set:
pop eax
push max_cur_dir
push maxPathLength
push edi
push eax
mov ebx, ecx
@ -519,17 +475,48 @@ get_full_file_name:
; in: ebx -> file name, [esp+4] -> destination, [esp+8] = max length
; destroys all registers
push ebp
mov esi, [current_slot]
mov esi, [esi+APPDATA.cur_dir]
mov edx, esi
@@:
inc esi
cmp byte [esi-1], 0
jnz @b
dec esi
cmp byte [ebx], '/'
jz .set_absolute
jnz .set_relative
lea esi, [ebx+1]
call process_replace_file_name
mov edi, [esp+8]
mov edx, [esp+12]
add edx, edi
.set_copy:
lodsb
stosb
test al, al
jz .set_part2
.set_copy_cont:
cmp edi, edx
jb .set_copy
.overflow:
dec edi
.fail:
mov byte [edi], 0
xor eax, eax
pop ebp
ret 8
.set_part2:
mov esi, ebp
xor ebp, ebp
test esi, esi
jz .ret.ok
mov byte [edi-1], '/'
jmp .set_copy_cont
.set_relative:
mov edi, [current_slot]
mov edi, [edi+APPDATA.cur_dir]
mov edx, edi
mov ecx, [esp+12]
xor eax, eax
repnz scasb
mov esi, edi
dec esi
mov edi, [esp+8]
jecxz .fail
.relative:
cmp byte [ebx], 0
jz .set_ok
@ -556,18 +543,9 @@ get_full_file_name:
.set_ok:
cmp edx, edi ; is destination equal to APPDATA.cur_dir?
jz .set_ok.cur_dir
sub esi, edx
cmp esi, [esp+12]
jb .set_ok.copy
.fail:
mov byte [edi], 0
xor eax, eax
pop ebp
ret 8
.set_ok.copy:
jz @f
mov ecx, esi
sub ecx, edx
mov esi, edx
rep movsb
mov byte [edi], 0
@ -576,17 +554,15 @@ get_full_file_name:
pop ebp
ret 8
.set_ok.cur_dir:
@@:
mov byte [esi], 0
jmp .ret.ok
.doset_relative:
cmp edx, edi
jz .doset_relative.cur_dir
sub esi, edx
cmp esi, [esp+12]
jae .fail
mov ecx, esi
sub ecx, edx
mov esi, edx
mov edx, edi
rep movsb
@ -608,34 +584,8 @@ get_full_file_name:
jz .ret.ok
cmp edi, edx
jb @b
.overflow:
dec edi
jmp .fail
.set_absolute:
lea esi, [ebx+1]
call process_replace_file_name
mov edi, [esp+8]
mov edx, [esp+12]
add edx, edi
.set_copy:
lodsb
stosb
test al, al
jz .set_part2
.set_copy_cont:
cmp edi, edx
jb .set_copy
jmp .overflow
.set_part2:
mov esi, ebp
xor ebp, ebp
test esi, esi
jz .ret.ok
mov byte [edi-1], '/'
jmp .set_copy_cont
include "parse_fn.inc"
include "fs_common.inc"
include "iso9660.inc" ; read for CD filesystem

View File

@ -1,19 +1,49 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
;-----------------------------------------------------------------------------
uglobal
cd_current_pointer_of_input dd 0
cd_current_pointer_of_input_2 dd 0
cd_mem_location dd 0
cd_counter_block dd 0
; CD external functions
; in:
; esi -> path string
; ebx -> offset in file (qword)
; ecx = bytes to read
; edx -> buffer
; out:
; eax, ebx = return values for sysfunc 70
iglobal
align 4
fs_CdServices:
dd fs_CdRead
dd fs_CdReadFolder
dd fs_NotImplemented
dd fs_NotImplemented
dd fs_NotImplemented
dd fs_CdGetFileInfo
dd fs_NotImplemented
dd 0
dd fs_NotImplemented
dd fs_NotImplemented
fs_NumCdServices = ($ - fs_CdServices)/4
endg
uglobal
align 4
cd_current_pointer_of_input dd 0
cd_current_pointer_of_input_2 dd 0
cd_mem_location dd 0
cd_counter_block dd 0
cd_status dd 0
endg
;-----------------------------------------------------------------------------
fs_NotImplemented:
movi eax, ERROR_UNSUPPORTED_FS
ret
;-----------------------------------------------------------------------------
reserve_cd:
cli
@ -127,23 +157,7 @@ free_cd_channel:
call mutex_unlock
popad
ret
;-----------------------------------------------------------------------------
uglobal
cd_status dd 0
endg
;-----------------------------------------------------------------------------
;
; fs_CdRead - LFN variant for reading CD disk
;
; esi points to filename /dir1/dir2/.../dirn/file,0
; ebx pointer to 64-bit number = first wanted byte, 0+
; may be ebx=0 - start from first byte
; ecx number of bytes to read, 0+
; edx mem location to return data
;
; ret ebx = bytes read or 0xffffffff file not found
; eax = 0 ok read or other = errormsg
;
;-----------------------------------------------------------------------------
fs_CdRead:
push edi
@ -277,20 +291,7 @@ fs_CdRead:
pop eax edx ecx
sub ebx, edx
jmp .reteof
;-----------------------------------------------------------------------------
;
; fs_CdReadFolder - LFN variant for reading CD disk folder
;
; esi points to filename /dir1/dir2/.../dirn/file,0
; ebx pointer to structure 32-bit number = first wanted block, 0+
; & flags (bitfields)
; flags: bit 0: 0=ANSI names, 1=UNICODE names
; ecx number of blocks to read, 0+
; edx mem location to return data
;
; ret ebx = blocks read or 0xffffffff folder not found
; eax = 0 ok read or other = errormsg
;
;-----------------------------------------------------------------------------
fs_CdReadFolder:
push edi
@ -538,7 +539,7 @@ cd_get_parameters_of_file_1:
mov [edi+12], eax
; last access date
mov [edi+20], eax
; last write date
; last write date
mov [edi+28], eax
; get the data type of name
xor eax, eax
@ -559,11 +560,7 @@ cd_get_parameters_of_file_1:
mov eax, [ebp-23]
mov [edi+32], eax
ret
;-----------------------------------------------------------------------------
;
; fs_CdGetFileInfo - LFN variant for CD
; get file/directory attributes structure
;
;-----------------------------------------------------------------------------
fs_CdGetFileInfo:
cmp byte [esi], 0
@ -607,7 +604,7 @@ fs_CdGetFileInfo:
;-----------------------------------------------------------------------------
cd_find_lfn:
mov [cd_appl_data], 0
; in: esi+ebp -> name
; in: esi -> path string
; out: CF=1 - file not found
; else CF=0 and [cd_current_pointer_of_input] direntry
push eax esi
@ -684,12 +681,8 @@ cd_find_lfn:
call ReadCDWRetr ; read sector of directory
cmp [DevErrorCode], 0
jne .access_denied
push ebp
call cd_find_name_in_buffer
pop ebp
jnc .found
sub eax, 2048
; directory is over?
cmp eax, 0
@ -706,7 +699,6 @@ cd_find_lfn:
; the end of the file path
cmp byte [esi-1], 0
jz .done
.nested:
mov eax, [cd_current_pointer_of_input]
push dword [eax+2]
pop dword [CDSectorAddress] ; beginning of the directory
@ -715,14 +707,6 @@ cd_find_lfn:
;--------------------------------------
; file pointer found
.done:
test ebp, ebp
jz @f
mov esi, ebp
xor ebp, ebp
jmp .nested
;--------------------------------------
@@:
pop esi eax
mov [cd_appl_data], 1
clc

View File

@ -11,7 +11,7 @@ $Revision$
; in:
; ebx -> parameter structure of sysfunc 70
; ebp -> NTFS structure
; [esi]+[[esp+4]] = name
; esi -> path string
; out:
; eax, ebx = return values for sysfunc 70
iglobal
@ -1174,7 +1174,7 @@ unichar_toupper:
ret
ntfs_find_lfn:
; in: [esi]+[esp+4] = name
; in: esi -> path string
; out:
; [ebp+NTFS.cur_iRecord] = target fileRecord
; eax -> target index in the node
@ -1280,7 +1280,7 @@ ntfs_find_lfn:
.ret2:
pop esi
.ret:
ret 4
ret
.slash:
pop eax
@ -1337,14 +1337,9 @@ ntfs_find_lfn:
mov [esp+1Ch], esi
mov [esp+4], edi
popad
inc esi
cmp byte [esi-1], 0
jnz @f
cmp dword [esp+8], 0
cmp byte [esi], 0
jz .ret2
mov esi, [esp+8]
mov dword [esp+8], 0
@@:
inc esi
pop eax
jmp .doit2
@ -1358,7 +1353,7 @@ ntfs_ReadFile:
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jnc .found
call ntfs_unlock
or ebx, -1
@ -1493,7 +1488,7 @@ ntfs_ReadFolder:
mov [ebp+NTFS.cur_iRecord], 5 ; root directory
cmp byte [esi], 0
jz @f
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jc ntfsNotFound
@@:
mov [ebp+NTFS.cur_attr], 0x10 ; $STANDARD_INFORMATION
@ -1820,7 +1815,7 @@ ntfs_GetFileInfo:
mov edi, [ebx+16]
cmp byte [esi], 0
jz .volume
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jnc .found
test eax, eax
jz ntfsFail
@ -1885,7 +1880,7 @@ ntfs_CreateFile:
@@: ; 1. Search file
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jc .notFound
; found, rewrite
cmp [ebp+NTFS.cur_iRecord], 16
@ -2172,7 +2167,7 @@ ntfs_CreateFile:
mov edx, [ebp+NTFS.rootLastRead]
call writeRecord
mov esi, [esp+4]
stdcall ntfs_find_lfn.doit2, 0
call ntfs_find_lfn.doit2
test eax, eax
jz .errorPop3
mov edi, [ebp+NTFS.cur_index_buf]
@ -3510,7 +3505,7 @@ ntfs_WriteFile:
ret
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jc ntfsNotFound
cmp [ebp+NTFS.cur_iRecord], 16
jc ntfsDenied
@ -3690,7 +3685,7 @@ ntfs_Delete:
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jc ntfsNotFound
cmp [ebp+NTFS.cur_iRecord], 16
jc ntfsDenied
@ -3783,7 +3778,7 @@ ntfs_Delete:
mov eax, [ebp+NTFS.newRecord]
mov [ebp+NTFS.cur_iRecord], eax
mov esi, [ebp+NTFS.indexPointer]
stdcall ntfs_find_lfn.doit2, 0
call ntfs_find_lfn.doit2
jc ntfsFail
mov ebx, [ebp+NTFS.secondIndexBuffer]
mov byte [ebx], 0
@ -4008,7 +4003,7 @@ ntfs_SetFileEnd:
ret
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jc ntfsNotFound
cmp [ebp+NTFS.cur_iRecord], 16
jc ntfsDenied
@ -4142,7 +4137,7 @@ ntfs_SetFileInfo:
ret
@@:
call ntfs_lock
stdcall ntfs_find_lfn, [esp+4]
call ntfs_find_lfn
jnc @f
test eax, eax
jz ntfsFail