2010-01-23 16:24:03 +01:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
2013-07-01 18:29:16 +02:00
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
2010-01-23 16:24:03 +01:00
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
2010-02-01 19:47:19 +01:00
|
|
|
|
;; 02.02.2010 turbanoff - support 70.5 ;;
|
|
|
|
|
;; 23.01.2010 turbanoff - support 70.0 70.1 ;;
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;; 21.06.2013 yogev_ezra - Translate Russian comments ;;
|
2010-01-23 16:24:03 +01:00
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
EXT2_BAD_INO = 1
|
2010-01-23 16:24:03 +01:00
|
|
|
|
EXT2_ROOT_INO = 2
|
2012-07-25 18:26:11 +02:00
|
|
|
|
EXT2_ACL_IDX_INO = 3
|
2010-01-23 16:24:03 +01:00
|
|
|
|
EXT2_ACL_DATA_INO = 4
|
2012-07-25 18:26:11 +02:00
|
|
|
|
EXT2_BOOT_LOADER_INO = 5
|
|
|
|
|
EXT2_UNDEL_DIR_INO = 6
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: флаги, указываемые в inode файла ;ENG: flags specified in file inode
|
2012-07-25 18:26:11 +02:00
|
|
|
|
EXT2_S_IFREG = 0x8000
|
|
|
|
|
EXT2_S_IFDIR = 0x4000
|
2013-06-21 02:56:10 +02:00
|
|
|
|
EXT2_S_IFMT = 0xF000 ;RUS: маска для типа файла ;ENG: mask for file type
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: флаги, указываемые в linked list родительской папки
|
|
|
|
|
;ENG: flags specified in linked list of parent folder
|
|
|
|
|
EXT2_FT_REG_FILE = 1 ;RUS: это файл, запись в родительском каталоге
|
|
|
|
|
;ENG: this is a file, record in parent catalog
|
|
|
|
|
EXT2_FT_DIR = 2 ;RUS: это папка ;ENG: this is a folder
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: флаги используемые KolibriOS ;ENG: flags used by KolibriOS
|
2012-07-25 18:26:11 +02:00
|
|
|
|
FS_FT_HIDDEN = 2
|
2013-06-21 02:56:10 +02:00
|
|
|
|
FS_FT_DIR = 0x10 ;RUS: это папка ;ENG: this is a folder
|
|
|
|
|
FS_FT_ASCII = 0 ;RUS: имя в ascii ;ENG: name in ASCII
|
|
|
|
|
FS_FT_UNICODE = 1 ;RUS: имя в unicode ;ENG: name in UNICODE
|
|
|
|
|
|
|
|
|
|
EXT2_FEATURE_INCOMPAT_FILETYPE = 0x0002 ;RUS: тип файла должен указываться в директории
|
|
|
|
|
;ENG: file type must be specified in the folder
|
|
|
|
|
EXT4_FEATURE_INCOMPAT_EXTENTS = 0x0040 ;RUS: экстенты ;ENG: extents
|
|
|
|
|
EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x0200 ;RUS: гибкие группы блоков ;ENG: flexible block groups
|
|
|
|
|
|
|
|
|
|
;RUS: реализованные ext[234] features ;ENG: implemented ext[234] features
|
2012-07-25 18:26:11 +02:00
|
|
|
|
EXT4_FEATURE_INCOMPAT_SUPP = EXT2_FEATURE_INCOMPAT_FILETYPE \
|
2013-06-27 01:35:43 +02:00
|
|
|
|
or EXT4_FEATURE_INCOMPAT_EXTENTS \
|
|
|
|
|
or EXT4_FEATURE_INCOMPAT_FLEX_BG
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: флаги, указываемые для inode в i_flags ;ENG: flags specified for inode in i_flags
|
2012-07-25 18:26:11 +02:00
|
|
|
|
EXT2_EXTENTS_FL = 0x00080000
|
2010-02-08 20:51:43 +01:00
|
|
|
|
|
2012-02-22 16:46:09 +01:00
|
|
|
|
struct EXT2_INODE_STRUC
|
|
|
|
|
i_mode dw ?
|
|
|
|
|
i_uid dw ?
|
|
|
|
|
i_size dd ?
|
|
|
|
|
i_atime dd ?
|
|
|
|
|
i_ctime dd ?
|
|
|
|
|
i_mtime dd ?
|
|
|
|
|
i_dtime dd ?
|
|
|
|
|
i_gid dw ?
|
|
|
|
|
i_links_count dw ?
|
|
|
|
|
i_blocks dd ?
|
|
|
|
|
i_flags dd ?
|
|
|
|
|
i_osd1 dd ?
|
|
|
|
|
i_block rd 15
|
|
|
|
|
i_generation dd ?
|
|
|
|
|
i_file_acl dd ?
|
|
|
|
|
i_dir_acl dd ?
|
|
|
|
|
i_faddr dd ?
|
|
|
|
|
i_osd2 dd ? ; 1..12
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ends
|
|
|
|
|
|
2012-02-22 16:46:09 +01:00
|
|
|
|
struct EXT2_DIR_STRUC
|
|
|
|
|
inode dd ?
|
|
|
|
|
rec_len dw ?
|
|
|
|
|
name_len db ?
|
|
|
|
|
file_type db ?
|
|
|
|
|
name db ? ; 0..255
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ends
|
|
|
|
|
|
2012-02-22 16:46:09 +01:00
|
|
|
|
struct EXT2_BLOCK_GROUP_DESC
|
2012-07-25 18:26:11 +02:00
|
|
|
|
block_bitmap dd ? ;+0
|
|
|
|
|
inode_bitmap dd ? ;+4
|
|
|
|
|
inode_table dd ? ;+8
|
|
|
|
|
free_blocks_count dw ? ;+12
|
|
|
|
|
free_inodes_count dw ? ;+14
|
|
|
|
|
used_dirs_count dw ? ;+16
|
|
|
|
|
pad dw ? ;+18
|
|
|
|
|
reserved rb 12;+20
|
2010-02-17 18:26:25 +01:00
|
|
|
|
ends
|
|
|
|
|
|
2012-02-22 16:46:09 +01:00
|
|
|
|
struct EXT2_SB_STRUC
|
|
|
|
|
inodes_count dd ? ;+0
|
|
|
|
|
blocks_count dd ? ;+4
|
|
|
|
|
r_block_count dd ? ;+8
|
|
|
|
|
free_block_count dd ? ;+12
|
|
|
|
|
free_inodes_count dd ? ;+16
|
|
|
|
|
first_data_block dd ? ;+20
|
|
|
|
|
log_block_size dd ? ;+24
|
|
|
|
|
log_frag_size dd ? ;+28
|
|
|
|
|
blocks_per_group dd ? ;+32
|
|
|
|
|
frags_per_group dd ? ;+36
|
|
|
|
|
inodes_per_group dd ? ;+40
|
|
|
|
|
mtime dd ? ;+44
|
|
|
|
|
wtime dd ? ;+48
|
|
|
|
|
mnt_count dw ? ;+52
|
|
|
|
|
max_mnt_count dw ? ;+54
|
|
|
|
|
magic dw ? ;+56
|
|
|
|
|
state dw ? ;+58
|
|
|
|
|
errors dw ? ;+60
|
|
|
|
|
minor_rev_level dw ? ;+62
|
|
|
|
|
lastcheck dd ? ;+64
|
|
|
|
|
check_intervals dd ? ;+68
|
|
|
|
|
creator_os dd ? ;+72
|
|
|
|
|
rev_level dd ? ;+76
|
|
|
|
|
def_resuid dw ? ;+80
|
|
|
|
|
def_resgid dw ? ;+82
|
|
|
|
|
first_ino dd ? ;+84
|
|
|
|
|
inode_size dw ? ;+88
|
|
|
|
|
block_group_nr dw ? ;+90
|
|
|
|
|
feature_compat dd ? ;+92
|
|
|
|
|
feature_incompat dd ? ;+96
|
|
|
|
|
feature_ro_compat dd ? ;+100
|
|
|
|
|
uuid rb 16 ;+104
|
|
|
|
|
volume_name rb 16 ;+120
|
|
|
|
|
last_mounted rb 64 ;+136
|
|
|
|
|
algo_bitmap dd ? ;+200
|
|
|
|
|
prealloc_blocks db ? ;+204
|
|
|
|
|
preallock_dir_blocks db ? ;+205
|
2012-07-25 18:26:11 +02:00
|
|
|
|
reserved_gdt_blocks dw ? ;+206
|
2012-02-22 16:46:09 +01:00
|
|
|
|
journal_uuid rb 16 ;+208
|
|
|
|
|
journal_inum dd ? ;+224
|
|
|
|
|
journal_dev dd ? ;+228
|
|
|
|
|
last_orphan dd ? ;+232
|
|
|
|
|
hash_seed rd 4 ;+236
|
|
|
|
|
def_hash_version db ? ;+252
|
|
|
|
|
rb 3 ;+253 reserved
|
|
|
|
|
default_mount_options dd ? ;+256
|
|
|
|
|
first_meta_bg dd ? ;+260
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mkfs_time dd ? ;+264
|
|
|
|
|
jnl_blocks rd 17 ;+268
|
|
|
|
|
blocks_count_hi dd ? ;+336
|
|
|
|
|
r_blocks_count_hi dd ? ;+340
|
|
|
|
|
free_blocks_count_hi dd ? ;+344
|
|
|
|
|
min_extra_isize dw ? ;+348
|
|
|
|
|
want_extra_isize dw ? ;+350
|
|
|
|
|
flags dd ? ;+352
|
|
|
|
|
raid_stride dw ? ;+356
|
|
|
|
|
mmp_interval dw ? ;+358
|
|
|
|
|
mmp_block dq ? ;+360
|
|
|
|
|
raid_stripe_width dd ? ;+368
|
|
|
|
|
log_groups_per_flex db ? ;+372
|
|
|
|
|
ends
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
struct EXT4_EXTENT_HEADER ;RUS: заголовок блока экстентов/индексов
|
|
|
|
|
eh_magic dw ? ;RUS: в текущей реализации ext4 должно быть 0xF30A
|
|
|
|
|
eh_entries dw ? ;RUS: количество экстентов/индексов в блоке
|
|
|
|
|
eh_max dw ? ;RUS: max количество (используется при записи)
|
|
|
|
|
eh_depth dw ? ;RUS: глубина дерева (0, если это блок экстентов)
|
2012-07-25 18:26:11 +02:00
|
|
|
|
eh_generation dd ? ;???
|
|
|
|
|
ends
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
struct EXT4_EXTENT ;RUS: экстент ;ENG: extent
|
|
|
|
|
ee_block dd ? ;RUS: номер ext4 блока ;ENG: number of ext4 block
|
|
|
|
|
ee_len dw ? ;RUS: длина экстента ;ENG: extent length
|
|
|
|
|
ee_start_hi dw ? ;RUS: старшие 16 бит 48-битного адреса (пока не используются в KOS)
|
|
|
|
|
;ENG: upper 16 bits of the 48-bit address (not used in KolibriOS yet)
|
|
|
|
|
ee_start_lo dd ? ;RUS: младшие 32 бита 48-битного адреса
|
|
|
|
|
;ENG: lower 32 bits of the 48-bit address
|
2012-07-25 18:26:11 +02:00
|
|
|
|
ends
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
struct EXT4_EXTENT_IDX ;RUS: индекс - указатель на блок с экстентами/индексами
|
|
|
|
|
;ENG: index - pointer to block of extents/indexes
|
|
|
|
|
ei_block dd ? ;RUS: номер ext4 блока ;ENG: number of ext4 block
|
|
|
|
|
ei_leaf_lo dd ? ;RUS: младшие 32 бит 48-битного адреса
|
|
|
|
|
;ENG: lower 32 bits of the 48-bit address
|
|
|
|
|
ei_leaf_hi dw ? ;RUS: старшие 16 бит 48-битного адреса (пока не используются в KOS)
|
|
|
|
|
;ENG: upper 16 bits of the 48-bit address (not used in KolibriOS yet)
|
|
|
|
|
ei_unused dw ? ;RUS: зарезервировано ;ENG: reserved
|
2010-02-17 18:26:25 +01:00
|
|
|
|
ends
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
struct EXTFS PARTITION
|
|
|
|
|
Lock MUTEX
|
|
|
|
|
log_block_size dd ?
|
|
|
|
|
block_size dd ?
|
|
|
|
|
count_block_in_block dd ?
|
|
|
|
|
blocks_per_group dd ?
|
|
|
|
|
global_desc_table dd ?
|
|
|
|
|
root_inode dd ? ; pointer to root inode in memory
|
|
|
|
|
inode_size dd ?
|
|
|
|
|
count_pointer_in_block dd ? ; block_size / 4
|
|
|
|
|
count_pointer_in_block_square dd ? ; (block_size / 4)**2
|
|
|
|
|
ext2_save_block dd ? ;RUS: блок на глобальную 1 процедуру ;ENG: block for 1 global procedure
|
|
|
|
|
ext2_temp_block dd ? ;RUS: блок для мелких процедур ;ENG: block for small procedures
|
|
|
|
|
ext2_save_inode dd ? ;RUS: inode на глобальную процедуру ;ENG: inode for global procedure
|
|
|
|
|
ext2_temp_inode dd ? ;RUS: inode для мелких процедур ;ENG: inode for small procedures
|
|
|
|
|
groups_count dd ?
|
|
|
|
|
superblock rd 512/4
|
|
|
|
|
ends
|
|
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
|
align 4
|
|
|
|
|
ext2_user_functions:
|
|
|
|
|
dd ext2_free
|
|
|
|
|
dd (ext2_user_functions_end - ext2_user_functions - 4) / 4
|
|
|
|
|
dd ext2_Read
|
|
|
|
|
dd ext2_ReadFolder
|
|
|
|
|
dd ext2_Rewrite
|
|
|
|
|
dd ext2_Write
|
|
|
|
|
dd ext2_SetFileEnd
|
|
|
|
|
dd ext2_GetFileInfo
|
|
|
|
|
dd ext2_SetFileInfo
|
|
|
|
|
dd 0
|
|
|
|
|
dd ext2_Delete
|
|
|
|
|
dd ext2_CreateFolder
|
|
|
|
|
ext2_user_functions_end:
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
proc ext2_create_partition
|
|
|
|
|
push ebx
|
2010-02-13 14:34:41 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, 2 ;superblock start at 1024b
|
|
|
|
|
add ebx, 512 ; get pointer to fs-specific buffer
|
|
|
|
|
call fs_read32_sys
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp [ebx + EXT2_SB_STRUC.log_block_size], 3 ;0,1,2,3
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ja .no
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp [ebx + EXT2_SB_STRUC.magic], 0xEF53
|
2010-01-23 16:24:03 +01:00
|
|
|
|
jne .no
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp [ebx + EXT2_SB_STRUC.state], 1 ;EXT_VALID_FS=1
|
2010-01-23 16:24:03 +01:00
|
|
|
|
jne .no
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp [ebx + EXT2_SB_STRUC.inodes_per_group], 0
|
|
|
|
|
je .no
|
|
|
|
|
|
|
|
|
|
mov eax, [ebx + EXT2_SB_STRUC.feature_incompat]
|
2010-02-13 14:34:41 +01:00
|
|
|
|
test eax, EXT2_FEATURE_INCOMPAT_FILETYPE
|
|
|
|
|
jz .no
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, not EXT4_FEATURE_INCOMPAT_SUPP
|
2013-07-01 18:29:16 +02:00
|
|
|
|
jz ext2_setup
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
.no:
|
|
|
|
|
; No, this superblock isn't EXT2
|
2013-07-01 18:29:16 +02:00
|
|
|
|
pop ebx
|
|
|
|
|
xor eax, eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; OK, this is correct EXT2 superblock
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ext2_setup:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
movi eax, sizeof.EXTFS
|
|
|
|
|
call malloc
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz ext2_create_partition.no
|
|
|
|
|
|
|
|
|
|
mov ecx, dword [ebp+PARTITION.FirstSector]
|
|
|
|
|
mov dword [eax+EXTFS.FirstSector], ecx
|
|
|
|
|
mov ecx, dword [ebp+PARTITION.FirstSector+4]
|
|
|
|
|
mov dword [eax+EXTFS.FirstSector+4], ecx
|
|
|
|
|
mov ecx, dword [ebp+PARTITION.Length]
|
|
|
|
|
mov dword [eax+EXTFS.Length], ecx
|
|
|
|
|
mov ecx, dword [ebp+PARTITION.Length+4]
|
|
|
|
|
mov dword [eax+EXTFS.Length+4], ecx
|
|
|
|
|
mov ecx, [ebp+PARTITION.Disk]
|
|
|
|
|
mov [eax+EXTFS.Disk], ecx
|
|
|
|
|
mov [eax+EXTFS.FSUserFunctions], ext2_user_functions
|
2013-07-01 21:10:43 +02:00
|
|
|
|
push ebp esi edi
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebp, eax
|
|
|
|
|
lea ecx, [eax+EXTFS.Lock]
|
|
|
|
|
call mutex_init
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
|
|
|
|
mov esi, ebx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
lea edi, [ebp+EXTFS.superblock]
|
2010-02-17 18:26:25 +01:00
|
|
|
|
mov ecx, 512/4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep movsd ; copy sb to reserved mem
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
|
|
|
|
mov eax, [ebx + EXT2_SB_STRUC.blocks_count]
|
|
|
|
|
sub eax, [ebx + EXT2_SB_STRUC.first_data_block]
|
|
|
|
|
dec eax
|
|
|
|
|
xor edx, edx
|
|
|
|
|
div [ebx + EXT2_SB_STRUC.blocks_per_group]
|
|
|
|
|
inc eax
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.groups_count], eax
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ecx, [ebx + EXT2_SB_STRUC.log_block_size]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
inc ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.log_block_size], ecx ; 1, 2, 3, 4 equ 1kb, 2kb, 4kb, 8kb
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov eax, 1
|
|
|
|
|
shl eax, cl
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.count_block_in_block], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
shl eax, 7
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.count_pointer_in_block], eax
|
2013-06-21 02:56:10 +02:00
|
|
|
|
mov edx, eax ;RUS: потом еще квадрат найдем ;ENG: we'll find a square later
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
shl eax, 2
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.block_size], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2010-02-17 18:26:25 +01:00
|
|
|
|
push eax eax ; 2 kernel_alloc
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov eax, edx
|
|
|
|
|
mul edx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.count_pointer_in_block_square], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
call kernel_alloc
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.ext2_save_block], eax ; and for temp block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call kernel_alloc
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.ext2_temp_block], eax ; and for get_inode proc
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
movzx eax, word [ebx + EXT2_SB_STRUC.inode_size]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ecx, [ebx + EXT2_SB_STRUC.blocks_per_group]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.inode_size], eax
|
|
|
|
|
mov [ebp+EXTFS.blocks_per_group], ecx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push eax eax eax ;3 kernel_alloc
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call kernel_alloc
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.ext2_save_inode], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call kernel_alloc
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.ext2_temp_inode], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call kernel_alloc
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov [ebp+EXTFS.root_inode], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov ebx, eax
|
|
|
|
|
mov eax, EXT2_ROOT_INO
|
|
|
|
|
call ext2_get_inode ; read root inode
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, ebp ; return pointer to EXTFS
|
2013-07-01 21:10:43 +02:00
|
|
|
|
pop edi esi ebp ebx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
proc ext2_free
|
|
|
|
|
push ebp
|
|
|
|
|
xchg ebp, eax
|
|
|
|
|
stdcall kernel_free, [ebp+EXTFS.ext2_save_block]
|
|
|
|
|
stdcall kernel_free, [ebp+EXTFS.ext2_temp_block]
|
|
|
|
|
stdcall kernel_free, [ebp+EXTFS.ext2_save_inode]
|
|
|
|
|
stdcall kernel_free, [ebp+EXTFS.ext2_temp_inode]
|
|
|
|
|
stdcall kernel_free, [ebp+EXTFS.root_inode]
|
|
|
|
|
xchg ebp, eax
|
|
|
|
|
call free
|
|
|
|
|
pop ebp
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
proc ext2_lock
|
|
|
|
|
lea ecx, [ebp+EXTFS.Lock]
|
|
|
|
|
jmp mutex_lock
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
proc ext2_unlock
|
|
|
|
|
lea ecx, [ebp+EXTFS.Lock]
|
|
|
|
|
jmp mutex_unlock
|
|
|
|
|
endp
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
;==================================================================
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;read ext2 block form FS to memory
|
|
|
|
|
;in: eax = i_block (address of block in ext2 terms)
|
|
|
|
|
; ebx = pointer to return memory
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; ebp = pointer to EXTFS
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;out: eax - error code (0 = no_error)
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ext2_get_block:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push ebx ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, [ebp+EXTFS.log_block_size]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
shl eax, cl
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, eax
|
|
|
|
|
push [ebp+EXTFS.count_block_in_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, ecx
|
|
|
|
|
call fs_read32_sys
|
|
|
|
|
test eax, eax
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jnz .fail
|
2013-07-01 18:29:16 +02:00
|
|
|
|
inc ecx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
add ebx, 512
|
2013-07-01 18:29:16 +02:00
|
|
|
|
dec dword [esp]
|
|
|
|
|
jnz @B
|
|
|
|
|
pop ecx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
@@:
|
|
|
|
|
pop ecx ebx
|
|
|
|
|
ret
|
|
|
|
|
.fail:
|
|
|
|
|
mov eax, ERROR_DEVICE
|
|
|
|
|
jmp @B
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;===================================================================
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: получает номер блока из extent inode ;ENG: receives block number from extent inode
|
|
|
|
|
;RUS: in: ecx = номер блока по порядку ;ENG: in: ecx = consecutive block number
|
2013-07-01 18:29:16 +02:00
|
|
|
|
;RUS: esi = адрес extent header`а ;ENG: esi = address of extent header
|
|
|
|
|
;RUS: ebp = указатель на структуру EXTFS ;ENG: ebp = pointer to EXTFS
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: out: ecx - адрес очередного блока в случае успеха ;ENG: out: ecx - address of next block, if successful
|
|
|
|
|
;RUS: eax - номер ошибки (если равно 0, то ошибки нет) ;ENG: eax - error number (0 - no error)
|
2012-07-25 18:26:11 +02:00
|
|
|
|
ext4_block_recursive_search:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp word [esi + EXT4_EXTENT_HEADER.eh_magic], 0xF30A ;EXT4_EXT_MAGIC
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jne .fail
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
movzx ebx, [esi + EXT4_EXTENT_HEADER.eh_entries]
|
|
|
|
|
add esi, sizeof.EXT4_EXTENT_HEADER
|
|
|
|
|
cmp word [esi - sizeof.EXT4_EXTENT_HEADER + EXT4_EXTENT_HEADER.eh_depth], 0
|
2012-07-25 18:26:11 +02:00
|
|
|
|
je .leaf_block ;листовой ли это блок?
|
|
|
|
|
|
|
|
|
|
;не листовой блок, а индексный ; eax - ext4_extent_idx
|
|
|
|
|
test ebx, ebx
|
|
|
|
|
jz .fail ;пустой индексный блок -> ошибка
|
|
|
|
|
|
|
|
|
|
;цикл по индексам экстентов
|
|
|
|
|
@@:
|
|
|
|
|
cmp ebx, 1 ;у индексов не хранится длина,
|
|
|
|
|
je .end_search_index ;поэтому, если остался последний - то это нужный
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp ecx, [esi + EXT4_EXTENT_IDX.ei_block]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jb .fail
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp ecx, [esi + sizeof.EXT4_EXTENT_IDX + EXT4_EXTENT_IDX.ei_block] ;блок слeдующего индекса
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jb .end_search_index ;следующий дальше - значит текущий, то что нам нужен
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
add esi, sizeof.EXT4_EXTENT_IDX
|
2012-07-25 18:26:11 +02:00
|
|
|
|
dec ebx
|
|
|
|
|
jmp @B
|
|
|
|
|
|
|
|
|
|
.end_search_index:
|
|
|
|
|
;ebp указывает на нужный extent_idx, считываем следующий блок
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_block]
|
|
|
|
|
mov eax, [esi + EXT4_EXTENT_IDX.ei_leaf_lo]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
call ext2_get_block
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .fail
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov esi, ebx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jmp ext4_block_recursive_search ;рекурсивно прыгаем в начало
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
.leaf_block: ;листовой блок esi - ext4_extent
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;цикл по экстентам
|
|
|
|
|
@@:
|
|
|
|
|
test ebx, ebx
|
|
|
|
|
jz .fail ;ни один узел не подошел - ошибка
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edx, [esi + EXT4_EXTENT.ee_block]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp ecx, edx
|
|
|
|
|
jb .fail ;если меньше, значит он был в предыдущих блоках -> ошибка
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
movzx edi, [esi + EXT4_EXTENT.ee_len]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
add edx, edi
|
|
|
|
|
cmp ecx, edx
|
|
|
|
|
jb .end_search_extent ;нашли нужный блок
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
add esi, sizeof.EXT4_EXTENT
|
2012-07-25 18:26:11 +02:00
|
|
|
|
dec ebx
|
|
|
|
|
jmp @B
|
|
|
|
|
|
|
|
|
|
.end_search_extent:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edx, [esi + EXT4_EXTENT.ee_start_lo]
|
|
|
|
|
sub ecx, [esi + EXT4_EXTENT.ee_block] ;разница в ext4 блоках
|
2012-07-25 18:26:11 +02:00
|
|
|
|
add ecx, edx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.fail:
|
|
|
|
|
mov eax, ERROR_FS_FAIL
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2010-01-23 16:24:03 +01:00
|
|
|
|
;===================================================================
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;получает адрес ext2 блока из inode с определнным номером
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: in: ecx = номер блока в inode (0..) ;ENG: in: ecx = number of block in inode (0..)
|
2013-07-01 18:29:16 +02:00
|
|
|
|
;RUS: esi = адрес inode ;ENG: esi = inode address
|
|
|
|
|
;RUS: ebp = указатель на структуру EXTFS;ENG: ebp = pointer to EXTFS
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: out: ecx = адрес очередного блока ;ENG: out: ecx = next block address
|
|
|
|
|
;RUS: eax - error code ;ENG: eax - error code
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ext2_get_inode_block:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
test [esi + EXT2_INODE_STRUC.i_flags], EXT2_EXTENTS_FL
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jz @F
|
|
|
|
|
|
|
|
|
|
pushad
|
2013-07-01 18:29:16 +02:00
|
|
|
|
add esi, EXT2_INODE_STRUC.i_block ;esi - extent_header
|
2012-07-25 18:26:11 +02:00
|
|
|
|
call ext4_block_recursive_search
|
|
|
|
|
mov PUSHAD_ECX, ecx
|
|
|
|
|
mov PUSHAD_EAX, eax
|
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
@@:
|
2010-02-03 19:01:16 +01:00
|
|
|
|
cmp ecx, 12 ; 0..11 - direct block address
|
|
|
|
|
jb .get_direct_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
sub ecx, 12
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp ecx, [ebp+EXTFS.count_pointer_in_block] ; 12.. - indirect blocks
|
2010-02-03 19:01:16 +01:00
|
|
|
|
jb .get_indirect_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
sub ecx, [ebp+EXTFS.count_pointer_in_block]
|
|
|
|
|
cmp ecx, [ebp+EXTFS.count_pointer_in_block_square]
|
2010-02-03 19:01:16 +01:00
|
|
|
|
jb .get_double_indirect_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
sub ecx, [ebp+EXTFS.count_pointer_in_block_square]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;triple indirect block
|
|
|
|
|
push edx ebx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_block + 14*4]
|
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .fail
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
xor edx, edx
|
|
|
|
|
mov eax, ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
div [ebp+EXTFS.count_pointer_in_block_square]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: eax - номер в полученном блоке edx - номер дальше
|
|
|
|
|
;ENG: eax - current block number, edx - next block number
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, [ebx + eax*4]
|
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .fail
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, edx
|
|
|
|
|
jmp @F
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
.get_double_indirect_block:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push edx ebx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_block + 13*4]
|
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .fail
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov eax, ecx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
@@:
|
2010-01-23 16:24:03 +01:00
|
|
|
|
xor edx, edx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
div [ebp+EXTFS.count_pointer_in_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, [ebx + eax*4]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .fail
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ecx, [ebx + edx*4]
|
|
|
|
|
.fail:
|
|
|
|
|
pop ebx edx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.get_indirect_block:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push ebx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_block + 12*4]
|
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
2013-06-21 02:56:10 +02:00
|
|
|
|
jnz @F ;RUS: если не было ошибки ;ENG: if there was no error
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
mov ecx, [ebx + ecx*4] ;RUS: заносим результат ;ENG: ???
|
2012-07-25 18:26:11 +02:00
|
|
|
|
@@:
|
|
|
|
|
pop ebx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.get_direct_block:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, [esi + EXT2_INODE_STRUC.i_block + ecx*4]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor eax, eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;===================================================================
|
|
|
|
|
;get content inode by num
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;in: eax = inode_num
|
|
|
|
|
; ebx = address of inode content
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; ebp = pointer to EXTFS
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;out: eax - error code
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ext2_get_inode:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pushad
|
|
|
|
|
mov edi, ebx ;сохраним адрес inode
|
|
|
|
|
dec eax
|
|
|
|
|
xor edx, edx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
div [ebp + EXT2_SB_STRUC.inodes_per_group + EXTFS.superblock]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2010-02-17 18:26:25 +01:00
|
|
|
|
push edx ;locale num in group
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov edx, 32
|
|
|
|
|
mul edx ; address block_group in global_desc_table
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: в eax - смещение группы с inode-ом относительно начала глобальной дескрипторной таблицы
|
|
|
|
|
;RUS: найдем блок в котором он находится
|
|
|
|
|
;ENG: in eax - inode group offset relative to global descriptor table start
|
|
|
|
|
;ENG: let's find the block this inode is in
|
2013-07-01 18:29:16 +02:00
|
|
|
|
div [ebp+EXTFS.block_size]
|
|
|
|
|
add eax, [ebp + EXT2_SB_STRUC.first_data_block + EXTFS.superblock]
|
2010-02-17 18:26:25 +01:00
|
|
|
|
inc eax
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_block]
|
2010-02-17 18:26:25 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
2013-06-27 01:35:43 +02:00
|
|
|
|
jnz .fail
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
add ebx, edx ;RUS: локальный номер в блоке ;ENG: local number inside block
|
|
|
|
|
mov eax, [ebx + EXT2_BLOCK_GROUP_DESC.inode_table] ;RUS: номер блока - в терминах ext2
|
|
|
|
|
;ENG: block number - in ext2 terms
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, [ebp+EXTFS.log_block_size]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
shl eax, cl
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: eax - указывает на таблицу inode-ов на hdd ;ENG: eax - points to inode table on HDD
|
|
|
|
|
mov esi, eax ;RUS: сохраним его пока в esi ;ENG: let's save it in esi for now
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: прибавим локальный адрес inode-а ;ENG: add local address of inode
|
2010-01-23 16:24:03 +01:00
|
|
|
|
pop eax ; index
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, [ebp+EXTFS.inode_size]
|
2010-02-13 14:34:41 +01:00
|
|
|
|
mul ecx ; (index * inode_size)
|
2013-07-01 18:29:16 +02:00
|
|
|
|
;RUS: поделим на размер блока ;ENG: divide by block size
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
and ecx, 512 - 1
|
|
|
|
|
shrd eax, edx, 9
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
add eax, esi ;RUS: нашли адрес блока для чтения ;ENG: found block address to read
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_block]
|
|
|
|
|
call fs_read32_sys
|
|
|
|
|
test eax, eax
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jnz .fail
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov esi, ecx ;RUS: добавим "остаток" ;ENG: add the "remainder"
|
|
|
|
|
mov ecx, [ebp+EXTFS.inode_size]
|
2013-06-21 02:56:10 +02:00
|
|
|
|
add esi, ebx ;RUS: к адресу ;ENG: to the address
|
|
|
|
|
rep movsb ;RUS: копируем inode ;ENG: copy inode
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
.fail:
|
|
|
|
|
mov PUSHAD_EAX, eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; ext2_ReadFolder - EXT2FS implementation of reading a folder
|
|
|
|
|
; in: ebp = pointer to EXTFS structure
|
|
|
|
|
; in: esi+[esp+4] = name
|
|
|
|
|
; in: ebx = pointer to parameters from sysfunc 70
|
|
|
|
|
; out: eax, ebx = return values for sysfunc 70
|
|
|
|
|
;----------------------------------------------------------------
|
|
|
|
|
ext2_ReadFolder:
|
|
|
|
|
call ext2_lock
|
2010-01-23 16:24:03 +01:00
|
|
|
|
cmp byte [esi], 0
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jz .root_folder
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push ebx
|
|
|
|
|
stdcall ext2_find_lfn, [esp+4+4] ;вернет в esi адрес inode
|
|
|
|
|
pop ebx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_ret
|
2013-07-01 18:29:16 +02:00
|
|
|
|
test [esi + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jz .error_not_found
|
|
|
|
|
jmp @F
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.root_folder:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov esi, [ebp+EXTFS.root_inode]
|
|
|
|
|
test [esi + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jz .error_root
|
|
|
|
|
;придется копировать inode
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edi, [ebp+EXTFS.ext2_save_inode]
|
|
|
|
|
mov ecx, [ebp+EXTFS.inode_size]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
shr ecx, 2
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push edi
|
2012-07-25 18:26:11 +02:00
|
|
|
|
rep movsd
|
2013-07-01 18:29:16 +02:00
|
|
|
|
pop esi
|
2010-02-03 19:01:16 +01:00
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [esi + EXT2_INODE_STRUC.i_size], 0 ;папка пуста
|
2012-07-25 18:26:11 +02:00
|
|
|
|
je .error_empty_dir
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edx, [ebx + 16]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push edx ;адрес результата [edi + 28]
|
|
|
|
|
push 0 ;конец очередного блока папки [edi + 24]
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push dword [ebx +12];сколько файлов нужно прочитать [edi + 20]
|
|
|
|
|
push dword [ebx + 4];первый "нужный" файл [edi + 16]
|
|
|
|
|
push dword [ebx + 8];флаги [edi + 12]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push 0 ;[EXT2_read_in_folder] [edi + 8]
|
|
|
|
|
push 0 ;[EXT2_files_in_folder] [edi + 4]
|
|
|
|
|
push 0 ;номер блока по порядку [edi]
|
|
|
|
|
|
2010-02-03 19:01:16 +01:00
|
|
|
|
mov edi, edx
|
|
|
|
|
mov ecx, 32/4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep stosd ; fill header zero
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
|
|
|
|
mov edi, esp ; edi - указатель на локальные переменные
|
|
|
|
|
add edx, 32 ; edx = current mem for return
|
2010-02-03 19:01:16 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor ecx, ecx ; получим номер первого блока
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_inode_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov eax, ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block ; и считываем блок с hdd
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, ebx ; ebx = current dir record
|
|
|
|
|
add eax, [ebp+EXTFS.block_size]
|
|
|
|
|
mov [edi + 24], eax ; запомним конец очередного блока
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ecx, [edi + 16] ; ecx = first wanted (flags ommited)
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
.find_wanted_start:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jecxz .find_wanted_end
|
2010-01-23 16:24:03 +01:00
|
|
|
|
.find_wanted_cycle:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [ebx + EXT2_DIR_STRUC.inode], 0 ; if (inode = 0) => not used
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jz @F
|
2012-07-25 18:26:11 +02:00
|
|
|
|
inc dword [edi + 4] ; EXT2_files_in_folder
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ecx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
movzx eax, [ebx + EXT2_DIR_STRUC.rec_len]
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp eax, 12 ; минимальная длина записи
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jb .error_bad_len
|
2013-07-01 18:29:16 +02:00
|
|
|
|
test eax, 0x3 ; длина записи должна делиться на 4
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jnz .error_bad_len
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
sub [esi + EXT2_INODE_STRUC.i_size], eax ;вычитаем напрямую из структуры inode
|
|
|
|
|
add ebx, eax ; к следующей записи
|
|
|
|
|
cmp ebx, [edi + 24] ; сравниваем с концом блока
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jb .find_wanted_start
|
2010-02-08 21:43:55 +01:00
|
|
|
|
|
2010-02-17 18:26:25 +01:00
|
|
|
|
push .find_wanted_start
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.end_block: ;вылетели из цикла
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [esi + EXT2_INODE_STRUC.i_size], 0
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jle .end_dir
|
2010-02-08 21:43:55 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
inc dword [edi] ;получаем новый блок
|
2010-02-08 21:43:55 +01:00
|
|
|
|
push ecx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ecx, [edi]
|
2010-02-08 21:43:55 +01:00
|
|
|
|
call ext2_get_inode_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_block
|
|
|
|
|
|
2010-02-08 21:43:55 +01:00
|
|
|
|
mov eax, ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_block]
|
2010-02-08 21:43:55 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_block
|
|
|
|
|
|
2010-02-08 21:43:55 +01:00
|
|
|
|
pop ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, ebx
|
|
|
|
|
add eax, [ebp+EXTFS.block_size]
|
|
|
|
|
mov [edi + 24], eax ;запомним конец блока
|
2012-07-25 18:26:11 +02:00
|
|
|
|
ret ; опять в цикл
|
2010-02-09 15:17:26 +01:00
|
|
|
|
|
|
|
|
|
.wanted_end:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
loop .find_wanted_cycle ; ecx 0 => -1 нужно посчитать сколько файлов
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;дошли до первого "нужного" файла
|
2010-02-08 21:43:55 +01:00
|
|
|
|
.find_wanted_end:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ecx, [edi + 20]
|
|
|
|
|
.wanted_start: ; ищем first_wanted+count
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jecxz .wanted_end
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [ebx + EXT2_DIR_STRUC.inode], 0 ; if (inode = 0) => not used
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jz .empty_rec
|
2012-07-25 18:26:11 +02:00
|
|
|
|
inc dword [edi + 8]
|
|
|
|
|
inc dword [edi + 4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push edi ecx
|
|
|
|
|
mov edi, edx ;обнуляем место под очереное имя файла/папки
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov ecx, 40 / 4
|
|
|
|
|
rep stosd
|
2012-07-25 18:26:11 +02:00
|
|
|
|
pop ecx edi
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push ebx edi edx
|
|
|
|
|
mov eax, [ebx + EXT2_DIR_STRUC.inode] ;получим дочерний inode
|
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_temp_inode]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call ext2_get_inode
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_read_subinode
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
lea edi, [edx + 8]
|
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov eax, [ebx + EXT2_INODE_STRUC.i_ctime] ; переведем время в ntfs формат
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor edx, edx
|
|
|
|
|
add eax, 3054539008 ;(369 * 365 + 89) * 24 * 3600
|
|
|
|
|
adc edx, 2
|
|
|
|
|
call ntfs_datetime_to_bdfe.sec
|
|
|
|
|
|
|
|
|
|
mov eax, [ebx + EXT2_INODE_STRUC.i_atime]
|
|
|
|
|
xor edx, edx
|
|
|
|
|
add eax, 3054539008
|
|
|
|
|
adc edx, 2
|
|
|
|
|
call ntfs_datetime_to_bdfe.sec
|
|
|
|
|
|
|
|
|
|
mov eax, [ebx + EXT2_INODE_STRUC.i_mtime]
|
|
|
|
|
xor edx, edx
|
|
|
|
|
add eax, 3054539008
|
|
|
|
|
adc edx, 2
|
|
|
|
|
call ntfs_datetime_to_bdfe.sec
|
|
|
|
|
|
|
|
|
|
pop edx ; пока достаем только буфер
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test [ebx + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR ; для папки размер
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jnz @F ; не возвращаем
|
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov eax, [ebx + EXT2_INODE_STRUC.i_size] ;low size
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stosd
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov eax, [ebx + EXT2_INODE_STRUC.i_dir_acl] ;high size
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stosd
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor dword [edx], FS_FT_DIR ;помечаем, что это файл(2 раза xor)
|
|
|
|
|
@@:
|
|
|
|
|
xor dword [edx], FS_FT_DIR ;помечаем, что это файл
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;теперь скопируем имя, сконвертировав из UTF-8 в CP866
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push ecx esi ;edi уже сохранен в стеке
|
|
|
|
|
mov esi, [esp+12]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
movzx ecx, [esi + EXT2_DIR_STRUC.name_len]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
lea edi, [edx + 40]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
lea esi, [esi + EXT2_DIR_STRUC.name]
|
|
|
|
|
call utf8_to_cp866
|
2011-10-14 23:38:50 +02:00
|
|
|
|
and byte [edi], 0
|
2013-07-01 18:29:16 +02:00
|
|
|
|
pop esi ecx edi ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp byte [edx + 40], '.' ; в linux файл, начинающийся с точки - скрытый
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jne @F
|
|
|
|
|
or dword [edx], FS_FT_HIDDEN
|
2012-07-25 18:26:11 +02:00
|
|
|
|
@@:
|
2010-02-08 20:51:43 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add edx, 40 + 264 ; go to next record
|
|
|
|
|
dec ecx ; если запись пустая ecx не надо уменьшать
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.empty_rec:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
movzx eax, [ebx + EXT2_DIR_STRUC.rec_len]
|
|
|
|
|
cmp eax, 12 ; минимальная длина записи
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jb .error_bad_len
|
2013-07-01 18:29:16 +02:00
|
|
|
|
test eax, 0x3 ; длина записи должна делиться на 4
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jnz .error_bad_len
|
2010-02-17 18:26:25 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
sub [esi + EXT2_INODE_STRUC.i_size], eax ;вычитаем напрямую из структуры inode
|
|
|
|
|
add ebx, eax
|
|
|
|
|
cmp ebx, [edi + 24] ;дошли ли до конца блока?
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jb .wanted_start
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push .wanted_start ; дошли
|
2010-02-09 15:17:26 +01:00
|
|
|
|
jmp .end_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.end_dir: ;конец папки, когда еще не дошли до нужного файла
|
2013-07-01 18:29:16 +02:00
|
|
|
|
call ext2_unlock
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov edx, [edi + 28] ;адрес структуры результата
|
|
|
|
|
mov ebx, [edi + 8] ;EXT2_read_in_folder
|
|
|
|
|
mov ecx, [edi + 4] ;EXT2_files_in_folder
|
2010-01-23 16:24:03 +01:00
|
|
|
|
mov dword [edx], 1 ;version
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov [edx + 4], ebx
|
|
|
|
|
mov [edx + 8], ecx
|
|
|
|
|
|
|
|
|
|
lea esp, [edi + 32]
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
xor eax, eax ;RUS: зарезервировано: нули в текущей реализации
|
|
|
|
|
;ENG: reserved: zeros in current implementation
|
2010-01-23 16:24:03 +01:00
|
|
|
|
lea edi, [edx + 12]
|
|
|
|
|
mov ecx, 20 / 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep stosd
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
|
|
|
|
.error_bad_len:
|
|
|
|
|
mov eax, ERROR_FS_FAIL
|
|
|
|
|
.error_read_subinode:
|
|
|
|
|
.error_get_block:
|
|
|
|
|
lea esp, [edi + 32]
|
|
|
|
|
.error_ret:
|
|
|
|
|
or ebx, -1
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push eax
|
|
|
|
|
call ext2_unlock
|
|
|
|
|
pop eax
|
2012-07-25 18:26:11 +02:00
|
|
|
|
ret
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
.error_empty_dir: ;RUS: inode папки без блоков ;ENG: inode of folder without blocks
|
|
|
|
|
.error_root: ;RUS: root - не папка ;ENG: root is not a folder
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov eax, ERROR_FS_FAIL
|
|
|
|
|
jmp .error_ret
|
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
.error_not_found: ;RUS: файл не найден ;ENG: file not found
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov eax, ERROR_FILE_NOT_FOUND
|
|
|
|
|
jmp .error_ret
|
|
|
|
|
|
|
|
|
|
;============================================
|
|
|
|
|
;convert UTF-8 string to ASCII-string (codepage 866)
|
|
|
|
|
;in: ecx = length source
|
|
|
|
|
; esi = source
|
|
|
|
|
; edi = buffer
|
2010-02-08 20:51:43 +01:00
|
|
|
|
; destroys: eax,esi,edi
|
2012-07-25 18:26:11 +02:00
|
|
|
|
utf8_to_cp866:
|
2010-02-08 20:51:43 +01:00
|
|
|
|
jecxz .ret
|
|
|
|
|
.start:
|
|
|
|
|
lodsw
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp al, 0x80
|
2010-02-08 20:51:43 +01:00
|
|
|
|
jb .ascii
|
|
|
|
|
|
2010-02-09 15:17:26 +01:00
|
|
|
|
xchg al, ah ; big-endian
|
2010-02-08 20:51:43 +01:00
|
|
|
|
cmp ax, 0xd080
|
|
|
|
|
jz .yo1
|
|
|
|
|
cmp ax, 0xd191
|
|
|
|
|
jz .yo2
|
|
|
|
|
cmp ax, 0xd090
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jb .unk
|
|
|
|
|
cmp ax, 0xd180
|
|
|
|
|
jb .rus1
|
|
|
|
|
cmp ax, 0xd190
|
2010-02-08 20:51:43 +01:00
|
|
|
|
jb .rus2
|
|
|
|
|
.unk:
|
|
|
|
|
mov al, '_'
|
|
|
|
|
jmp .doit
|
|
|
|
|
.yo1:
|
|
|
|
|
mov al, 0xf0 ; Ё capital
|
|
|
|
|
jmp .doit
|
|
|
|
|
.yo2:
|
|
|
|
|
mov al, 0xf1 ; ё small
|
|
|
|
|
jmp .doit
|
|
|
|
|
.rus1:
|
|
|
|
|
sub ax, 0xd090 - 0x80
|
|
|
|
|
jmp .doit
|
|
|
|
|
.rus2:
|
|
|
|
|
sub ax, 0xd18f - 0xEF
|
|
|
|
|
.doit:
|
|
|
|
|
stosb
|
|
|
|
|
sub ecx, 2
|
|
|
|
|
ja .start
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.ascii:
|
|
|
|
|
stosb
|
|
|
|
|
dec esi
|
|
|
|
|
dec ecx
|
|
|
|
|
jnz .start
|
|
|
|
|
.ret:
|
|
|
|
|
ret
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;----------------------------------------------------------------
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; ext2_Read - EXT2FS 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
|
|
|
|
|
;----------------------------------------------------------------
|
|
|
|
|
ext2_Read:
|
|
|
|
|
call ext2_lock
|
2010-01-23 16:24:03 +01:00
|
|
|
|
cmp byte [esi], 0
|
2010-02-08 20:51:43 +01:00
|
|
|
|
jnz @F
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2010-02-01 19:47:19 +01:00
|
|
|
|
.this_is_nofile:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
call ext2_unlock
|
2010-01-23 16:24:03 +01:00
|
|
|
|
or ebx, -1
|
|
|
|
|
mov eax, ERROR_ACCESS_DENIED
|
|
|
|
|
ret
|
|
|
|
|
|
2010-02-08 20:51:43 +01:00
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push ebx
|
|
|
|
|
stdcall ext2_find_lfn, [esp+4+4]
|
|
|
|
|
pop ebx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jz @F
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
call ext2_unlock
|
2010-02-08 20:51:43 +01:00
|
|
|
|
or ebx, -1
|
|
|
|
|
mov eax, ERROR_FILE_NOT_FOUND
|
|
|
|
|
ret
|
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
@@:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ax, [esi + EXT2_INODE_STRUC.i_mode]
|
2012-09-11 19:39:26 +02:00
|
|
|
|
and ax, EXT2_S_IFMT ;оставляем только тип inode в ax
|
|
|
|
|
cmp ax, EXT2_S_IFREG
|
|
|
|
|
jne .this_is_nofile
|
2010-02-08 20:51:43 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edi, [ebx+16] ; edi = pointer to return mem
|
|
|
|
|
mov ecx, [ebx+12]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [ebx+4]
|
|
|
|
|
mov edx, [ebx+8] ;RUS: edx : eax - стартовый номер байта ;ENG: edx : eax - start byte number
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;RUS: ///// сравним хватит ли нам файла или нет ;ENG: ///// check if file is big enough for us
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [esi + EXT2_INODE_STRUC.i_dir_acl], edx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ja .size_great
|
|
|
|
|
jb .size_less
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [esi + EXT2_INODE_STRUC.i_size], eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ja .size_great
|
|
|
|
|
|
|
|
|
|
.size_less:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
call ext2_unlock
|
2010-02-08 20:51:43 +01:00
|
|
|
|
xor ebx, ebx
|
2010-02-17 18:26:25 +01:00
|
|
|
|
mov eax, ERROR_END_OF_FILE
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2010-01-23 16:24:03 +01:00
|
|
|
|
.size_great:
|
2013-06-21 02:56:10 +02:00
|
|
|
|
add eax, ecx ;RUS: add to first_wanted кол-во байт для чтения
|
|
|
|
|
;ENG: add to first_wanted number of bytes to read
|
2013-07-01 18:29:16 +02:00
|
|
|
|
adc edx, 0
|
2010-02-08 20:51:43 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [esi + EXT2_INODE_STRUC.i_dir_acl], edx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ja .size_great_great
|
|
|
|
|
jb .size_great_less
|
2013-07-01 18:29:16 +02:00
|
|
|
|
cmp [esi + EXT2_INODE_STRUC.i_size], eax
|
2013-06-21 02:56:10 +02:00
|
|
|
|
jae .size_great_great ; and if it's equal, no matter where we jump
|
2010-02-08 20:51:43 +01:00
|
|
|
|
|
2010-01-23 16:24:03 +01:00
|
|
|
|
.size_great_less:
|
2013-06-21 02:56:10 +02:00
|
|
|
|
push 1 ;RUS: читаем по границе размера ;ENG: reading till the end of file
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, [esi + EXT2_INODE_STRUC.i_size]
|
|
|
|
|
sub ecx, [ebx+4] ;RUS: (размер - старт) = сколько читать ;ENG: to read = (size - start)
|
2010-01-23 16:24:03 +01:00
|
|
|
|
jmp @F
|
|
|
|
|
|
|
|
|
|
.size_great_great:
|
2013-06-21 02:56:10 +02:00
|
|
|
|
push 0 ;RUS: читаем столько, сколько запросили ;ENG: reading as much as requested
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
@@:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;здесь мы точно знаем сколько байт читать - ecx
|
|
|
|
|
;edi - return memory
|
|
|
|
|
;esi -> first wanted
|
|
|
|
|
|
|
|
|
|
push ecx ;количество считанных байт
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;получим кусок из первого блока
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edx, [ebx+8]
|
|
|
|
|
mov eax, [ebx+4]
|
|
|
|
|
div [ebp+EXTFS.block_size]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-03-03 14:53:24 +01:00
|
|
|
|
push eax ;счетчик блоков ложим в стек
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2010-01-23 16:24:03 +01:00
|
|
|
|
push ecx
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
call ext2_get_inode_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_at_first_block
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
mov eax, ecx
|
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_at_first_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
pop ecx
|
|
|
|
|
add ebx, edx
|
|
|
|
|
|
|
|
|
|
neg edx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
add edx, [ebp+EXTFS.block_size] ;RUS: block_size - стартовый байт = сколько байт 1-го блока
|
2013-06-21 02:56:10 +02:00
|
|
|
|
;ENG: block_size - start byte = number of bytes in 1st block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
cmp ecx, edx
|
|
|
|
|
jbe .only_one_block
|
|
|
|
|
|
|
|
|
|
mov eax, ecx
|
|
|
|
|
sub eax, edx
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push esi
|
2010-01-23 16:24:03 +01:00
|
|
|
|
mov esi, ebx
|
2013-06-21 02:56:10 +02:00
|
|
|
|
rep movsb ;RUS: кусок 1-го блока ;ENG: part of 1st block
|
2013-07-01 18:29:16 +02:00
|
|
|
|
pop esi
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
;теперь в eax кол-во оставшихся байт для чтения
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.calc_blocks_count:
|
2010-02-08 20:51:43 +01:00
|
|
|
|
mov ebx, edi ;чтение блока прям в ->ebx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
xor edx, edx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
div [ebp+EXTFS.block_size] ;кол-во байт в последнем блоке (остаток) в edx
|
2010-02-08 20:51:43 +01:00
|
|
|
|
mov edi, eax ;кол-во целых блоков в edi
|
2010-01-23 16:24:03 +01:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
test edi, edi
|
2010-01-23 16:24:03 +01:00
|
|
|
|
jz .finish_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
inc dword [esp]
|
|
|
|
|
mov ecx, [esp]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_inode_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_at_read_cycle
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2010-02-08 20:51:43 +01:00
|
|
|
|
mov eax, ecx ;а ebx уже забит нужным значением
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_at_read_cycle
|
2013-07-01 18:29:16 +02:00
|
|
|
|
add ebx, [ebp+EXTFS.block_size]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2010-02-08 20:51:43 +01:00
|
|
|
|
dec edi
|
2010-01-23 16:24:03 +01:00
|
|
|
|
jmp @B
|
|
|
|
|
|
|
|
|
|
.finish_block: ;в edx - кол-во байт в последнем блоке
|
2010-02-08 20:51:43 +01:00
|
|
|
|
test edx, edx
|
|
|
|
|
jz .end_read
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
pop ecx ;счетчик блоков -> ecx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
inc ecx
|
|
|
|
|
call ext2_get_inode_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
2013-03-03 19:42:16 +01:00
|
|
|
|
jnz .error_at_finish_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
|
|
|
|
mov edi, ebx
|
|
|
|
|
mov eax, ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_block]
|
2010-01-23 16:24:03 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_at_finish_block
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2013-06-27 01:35:43 +02:00
|
|
|
|
mov ecx, edx
|
2010-01-23 16:24:03 +01:00
|
|
|
|
mov esi, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep movsb ;кусок last блока
|
2013-03-03 14:53:24 +01:00
|
|
|
|
jmp @F
|
|
|
|
|
|
2010-02-04 17:44:28 +01:00
|
|
|
|
.end_read:
|
2013-03-03 14:53:24 +01:00
|
|
|
|
pop ecx ;счетчик блоков, который хранился в стеке
|
|
|
|
|
@@:
|
|
|
|
|
pop ebx ;количество считанных байт
|
2013-07-01 18:29:16 +02:00
|
|
|
|
call ext2_unlock
|
2013-03-03 14:53:24 +01:00
|
|
|
|
pop eax ; 1 или 0 - достигли ли конца файла
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
jz @F
|
|
|
|
|
|
2010-02-17 18:26:25 +01:00
|
|
|
|
mov eax, ERROR_END_OF_FILE
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
|
|
|
|
@@:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
|
|
|
|
.only_one_block:
|
|
|
|
|
mov esi, ebx
|
|
|
|
|
rep movsb ;кусок last блока
|
|
|
|
|
jmp .end_read
|
|
|
|
|
|
|
|
|
|
.error_at_first_block:
|
|
|
|
|
pop edx
|
|
|
|
|
.error_at_read_cycle:
|
2013-06-27 01:35:43 +02:00
|
|
|
|
pop ebx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.error_at_finish_block:
|
|
|
|
|
pop ecx edx
|
|
|
|
|
or ebx, -1
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push eax
|
|
|
|
|
call ext2_unlock
|
|
|
|
|
pop eax
|
2012-07-25 18:26:11 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------
|
|
|
|
|
; in: esi = file path
|
|
|
|
|
; ebx = pointer to dir block
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; ebp = pointer to EXTFS structure
|
2012-07-25 18:26:11 +02:00
|
|
|
|
; out: esi - name without parent or not_changed
|
|
|
|
|
; ebx - dir_rec of inode children
|
|
|
|
|
ext2_test_block_by_name:
|
|
|
|
|
sub esp, 256 ;EXT2_filename
|
|
|
|
|
mov edx, ebx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
add edx, [ebp+EXTFS.block_size] ;RUS: запомним конец блока ;ENG: save block end
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
|
|
|
|
.start_rec:
|
|
|
|
|
cmp [ebx + EXT2_DIR_STRUC.inode], 0
|
|
|
|
|
jz .next_rec
|
|
|
|
|
|
|
|
|
|
mov edi, esp
|
|
|
|
|
push esi
|
|
|
|
|
movzx ecx, [ebx + EXT2_DIR_STRUC.name_len]
|
|
|
|
|
lea esi, [ebx + EXT2_DIR_STRUC.name]
|
|
|
|
|
call utf8_to_cp866
|
|
|
|
|
|
|
|
|
|
mov ecx, edi
|
|
|
|
|
lea edi, [esp + 4]
|
2013-06-21 02:56:10 +02:00
|
|
|
|
sub ecx, edi ;RUS: кол-во байт в получившейся строке ;ENG: number of bytes in resulting string
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
|
|
|
|
mov esi, [esp]
|
|
|
|
|
@@:
|
|
|
|
|
jecxz .test_find
|
|
|
|
|
dec ecx
|
|
|
|
|
|
|
|
|
|
lodsb
|
|
|
|
|
call char_toupper
|
|
|
|
|
|
|
|
|
|
mov ah, [edi]
|
|
|
|
|
inc edi
|
|
|
|
|
xchg al, ah
|
|
|
|
|
call char_toupper
|
|
|
|
|
cmp al, ah
|
|
|
|
|
je @B
|
2013-06-21 02:56:10 +02:00
|
|
|
|
@@: ;RUS: не подошло ;ENG: didn't fit
|
2012-07-25 18:26:11 +02:00
|
|
|
|
pop esi
|
|
|
|
|
.next_rec:
|
|
|
|
|
movzx eax, [ebx + EXT2_DIR_STRUC.rec_len]
|
2013-06-21 02:56:10 +02:00
|
|
|
|
add ebx, eax ;RUS: к след. записи ;ENG: go to next record
|
|
|
|
|
cmp ebx, edx ;RUS: проверим конец ли ;ENG: check if this is the end
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jb .start_rec
|
|
|
|
|
add esp, 256
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.test_find:
|
|
|
|
|
cmp byte [esi], 0
|
2013-06-21 02:56:10 +02:00
|
|
|
|
je .ret ;RUS: нашли конец ;ENG: the end reached
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp byte [esi], '/'
|
|
|
|
|
jne @B
|
|
|
|
|
inc esi
|
|
|
|
|
.ret:
|
|
|
|
|
add esp, 256 + 4
|
|
|
|
|
ret
|
|
|
|
|
|
2010-01-23 16:24:03 +01:00
|
|
|
|
;========================
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;Ищет inode по строке пути
|
2013-07-01 18:29:16 +02:00
|
|
|
|
;in: esi+[esp+4] = name
|
|
|
|
|
; ebp = pointer to EXTFS
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;out: eax - error code
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; esi = inode
|
2012-07-25 18:26:11 +02:00
|
|
|
|
; dl - первый байт из имени файла/папки
|
2010-02-01 19:47:19 +01:00
|
|
|
|
ext2_find_lfn:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edx, [ebp+EXTFS.root_inode]
|
|
|
|
|
cmp [edx + EXT2_INODE_STRUC.i_blocks], 0
|
2012-07-25 18:26:11 +02:00
|
|
|
|
je .error_empty_root
|
|
|
|
|
|
|
|
|
|
.next_path_part:
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push [edx + EXT2_INODE_STRUC.i_blocks]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor ecx, ecx
|
|
|
|
|
.folder_block_cycle:
|
2013-03-22 19:35:06 +01:00
|
|
|
|
push ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
xchg esi, edx
|
2010-02-01 19:47:19 +01:00
|
|
|
|
call ext2_get_inode_block
|
2013-07-01 18:29:16 +02:00
|
|
|
|
xchg esi, edx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_inode_block
|
|
|
|
|
|
2010-02-01 19:47:19 +01:00
|
|
|
|
mov eax, ecx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_block] ;ebx = cur dir record
|
2010-02-01 19:47:19 +01:00
|
|
|
|
call ext2_get_block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_block
|
|
|
|
|
|
|
|
|
|
push esi
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push edx
|
2010-02-01 19:47:19 +01:00
|
|
|
|
call ext2_test_block_by_name
|
2013-07-01 18:29:16 +02:00
|
|
|
|
pop edx
|
2013-03-22 19:35:06 +01:00
|
|
|
|
pop edi ecx
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
cmp edi, esi ;RUS: нашли имя? ;ENG: did we find a name?
|
|
|
|
|
je .next_folder_block ;RUS: не нашли -> к след. блоку ;ENG: we didn't -> moving to next block
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
cmp byte [esi], 0 ;RUS: дошли до "конца" пути -> возваращаемся
|
|
|
|
|
;ENG: reached the "end" of path -> returning
|
2013-07-01 18:29:16 +02:00
|
|
|
|
jnz @f
|
|
|
|
|
cmp dword [esp+8], 0
|
2010-02-01 19:47:19 +01:00
|
|
|
|
jz .get_inode_ret
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov esi, [esp+8]
|
|
|
|
|
mov dword [esp+8], 0
|
|
|
|
|
@@:
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2013-06-21 02:56:10 +02:00
|
|
|
|
cmp [ebx + EXT2_DIR_STRUC.file_type], EXT2_FT_DIR ;RUS: нашли, но это не папка
|
|
|
|
|
jne .not_found ;ENG: found, but it's not a folder
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2010-02-01 19:47:19 +01:00
|
|
|
|
mov eax, [ebx + EXT2_DIR_STRUC.inode]
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_inode] ;RUS: все же папка. ;ENG: it's a folder afterall
|
2010-02-01 19:47:19 +01:00
|
|
|
|
call ext2_get_inode
|
2012-07-25 18:26:11 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz .error_get_inode
|
2013-06-21 02:56:10 +02:00
|
|
|
|
pop ecx ;RUS: в стеке лежит кол-во блоков ;ENG: stack top contains number of blocks
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov edx, ebx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jmp .next_path_part
|
|
|
|
|
|
|
|
|
|
.next_folder_block:
|
|
|
|
|
;к следующему блоку в текущей папке
|
2013-06-21 02:56:10 +02:00
|
|
|
|
pop eax ;RUS: счетчик блоков ;ENG: blocks counter
|
2013-07-01 18:29:16 +02:00
|
|
|
|
sub eax, [ebp+EXTFS.count_block_in_block]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jle .not_found
|
|
|
|
|
|
2013-03-03 17:32:44 +01:00
|
|
|
|
push eax
|
2012-07-25 18:26:11 +02:00
|
|
|
|
inc ecx
|
|
|
|
|
jmp .folder_block_cycle
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
|
|
|
|
.not_found:
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov eax, ERROR_FILE_NOT_FOUND
|
2013-07-01 18:29:16 +02:00
|
|
|
|
ret 4
|
2012-07-25 18:26:11 +02:00
|
|
|
|
|
2010-02-01 19:47:19 +01:00
|
|
|
|
.get_inode_ret:
|
2013-06-21 02:56:10 +02:00
|
|
|
|
pop ecx ;RUS: в стеке лежит кол-во блоков ;ENG: stack top contains number of blocks
|
|
|
|
|
mov dl, [ebx + EXT2_DIR_STRUC.name] ;RUS: в dl - первый символ () ;ENG: ???
|
2010-02-01 19:47:19 +01:00
|
|
|
|
mov eax, [ebx + EXT2_DIR_STRUC.inode]
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ebx, [ebp+EXTFS.ext2_save_inode]
|
2010-02-01 19:47:19 +01:00
|
|
|
|
call ext2_get_inode
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov esi, ebx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
xor eax, eax
|
2013-07-01 18:29:16 +02:00
|
|
|
|
ret 4
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.error_get_inode_block:
|
|
|
|
|
.error_get_block:
|
2013-03-22 19:35:06 +01:00
|
|
|
|
pop ecx
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.error_get_inode:
|
|
|
|
|
pop ebx
|
|
|
|
|
.error_empty_root:
|
|
|
|
|
mov eax, ERROR_FS_FAIL
|
2013-07-01 18:29:16 +02:00
|
|
|
|
ret 4
|
2010-01-23 16:24:03 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
;----------------------------------------------------------------
|
2013-07-01 18:29:16 +02:00
|
|
|
|
; ext2_GetFileInfo - EXT2 implementation of getting file info
|
|
|
|
|
; in: ebp = pointer to EXTFS structure
|
|
|
|
|
; in: esi+[esp+4] = name
|
|
|
|
|
; in: ebx = pointer to parameters from sysfunc 70
|
|
|
|
|
; out: eax, ebx = return values for sysfunc 70
|
|
|
|
|
;----------------------------------------------------------------
|
|
|
|
|
ext2_GetFileInfo:
|
|
|
|
|
call ext2_lock
|
|
|
|
|
mov edx, [ebx+16]
|
2010-02-01 19:47:19 +01:00
|
|
|
|
cmp byte [esi], 0
|
2012-07-25 18:26:11 +02:00
|
|
|
|
jz .is_root
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
push edx
|
2013-07-01 18:29:16 +02:00
|
|
|
|
stdcall ext2_find_lfn, [esp+4+4]
|
2012-07-25 18:26:11 +02:00
|
|
|
|
mov ebx, edx
|
|
|
|
|
pop edx
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz @F
|
2013-07-01 18:29:16 +02:00
|
|
|
|
push eax
|
|
|
|
|
call ext2_unlock
|
|
|
|
|
pop eax
|
2010-02-01 19:47:19 +01:00
|
|
|
|
ret
|
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
.is_root:
|
2013-06-21 02:56:10 +02:00
|
|
|
|
xor ebx, ebx ;RUS: root не может быть скрытым ;ENG: root cannot be hidden
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov esi, [ebp+EXTFS.root_inode]
|
2010-02-09 15:17:26 +01:00
|
|
|
|
@@:
|
2010-02-01 19:47:19 +01:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov edi, edx
|
|
|
|
|
mov ecx, 40/4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep stosd ; fill zero
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2012-07-25 18:26:11 +02:00
|
|
|
|
cmp bl, '.'
|
|
|
|
|
jne @F
|
2010-02-09 15:17:26 +01:00
|
|
|
|
or dword [edx], FS_FT_HIDDEN
|
2010-02-01 19:47:19 +01:00
|
|
|
|
@@:
|
2010-02-09 15:17:26 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
test [esi + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jnz @F
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_size] ;low size
|
|
|
|
|
mov ebx, [esi + EXT2_INODE_STRUC.i_dir_acl] ;high size
|
2010-02-01 19:47:19 +01:00
|
|
|
|
mov dword [edx+32], eax
|
|
|
|
|
mov dword [edx+36], ebx
|
2010-02-09 15:17:26 +01:00
|
|
|
|
xor dword [edx], FS_FT_DIR
|
|
|
|
|
@@:
|
|
|
|
|
xor dword [edx], FS_FT_DIR
|
|
|
|
|
|
|
|
|
|
lea edi, [edx + 8]
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_ctime]
|
2010-02-09 15:17:26 +01:00
|
|
|
|
xor edx, edx
|
|
|
|
|
add eax, 3054539008
|
|
|
|
|
adc edx, 2
|
|
|
|
|
call ntfs_datetime_to_bdfe.sec
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_atime]
|
2010-02-09 15:17:26 +01:00
|
|
|
|
xor edx, edx
|
|
|
|
|
add eax, 3054539008
|
|
|
|
|
adc edx, 2
|
|
|
|
|
call ntfs_datetime_to_bdfe.sec
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov eax, [esi + EXT2_INODE_STRUC.i_mtime]
|
2010-02-09 15:17:26 +01:00
|
|
|
|
xor edx, edx
|
|
|
|
|
add eax, 3054539008
|
|
|
|
|
adc edx, 2
|
|
|
|
|
call ntfs_datetime_to_bdfe.sec
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
call ext2_unlock
|
2010-02-01 19:47:19 +01:00
|
|
|
|
xor eax, eax
|
2010-01-23 16:24:03 +01:00
|
|
|
|
ret
|
2010-02-01 19:47:19 +01:00
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
ext2_Rewrite:
|
|
|
|
|
ext2_Write:
|
|
|
|
|
ext2_SetFileEnd:
|
|
|
|
|
ext2_SetFileInfo:
|
|
|
|
|
ext2_Delete:
|
|
|
|
|
ext2_CreateFolder:
|
2010-01-23 16:24:03 +01:00
|
|
|
|
xor ebx, ebx
|
|
|
|
|
mov eax, ERROR_UNSUPPORTED_FS
|
|
|
|
|
ret
|