Pass sector size as argument, don't hardcode.

This commit is contained in:
Ivan Baravy 2018-05-18 19:48:50 +03:00
parent 428e646336
commit 3d39097fb1
4 changed files with 14 additions and 9 deletions

2
kofu.c
View File

@ -135,7 +135,7 @@ int main(int argc, char **argv) {
int fd = open(argv[1], O_RDONLY); int fd = open(argv[1], O_RDONLY);
struct stat st; struct stat st;
fstat(fd, &st); fstat(fd, &st);
if (!kos_fuse_init(fd, st.st_size / 512)) { if (!kos_fuse_init(fd, st.st_size / 512, 512)) {
exit(1); exit(1);
} }

View File

@ -102,6 +102,6 @@ int main(int argc, char *argv[]) {
int fd = open(argv[2], O_RDONLY); int fd = open(argv[2], O_RDONLY);
struct stat st; struct stat st;
fstat(fd, &st); fstat(fd, &st);
kos_fuse_init(fd, st.st_size / 512); kos_fuse_init(fd, st.st_size / 512, 512);
return fuse_main(argc-1, argv, &kofuse_oper, NULL); return fuse_main(argc-1, argv, &kofuse_oper, NULL);
} }

View File

@ -38,7 +38,7 @@ kos_time_to_epoch:
ret ret
;void *kos_fuse_init(int fd, uint32_t sect_cnt); ;void *kos_fuse_init(int fd, uint32_t sect_cnt, uint32_t sect_sz);
public kos_fuse_init public kos_fuse_init
kos_fuse_init: kos_fuse_init:
push ebx esi edi ebp push ebx esi edi ebp
@ -49,7 +49,8 @@ kos_fuse_init:
mov [file_disk.fd], eax mov [file_disk.fd], eax
mov eax, [esp + 0x18] mov eax, [esp + 0x18]
mov [file_disk.Sectors], eax mov [file_disk.Sectors], eax
mov [file_disk.Logical], 512 mov eax, [esp + 0x1c]
mov [file_disk.Logical], eax
stdcall disk_add, disk_functions, disk_name, file_disk, DISK_NO_INSERT_NOTIFICATION stdcall disk_add, disk_functions, disk_name, file_disk, DISK_NO_INSERT_NOTIFICATION
push eax push eax
stdcall disk_media_changed, eax, 1 stdcall disk_media_changed, eax, 1
@ -75,8 +76,10 @@ proc disk_read stdcall, userdata, buffer, startsector:qword, numsectors
pushad pushad
mov eax, dword[startsector + 0] ; sector lo mov eax, dword[startsector + 0] ; sector lo
mov edx, dword[startsector + 4] ; sector hi mov edx, dword[startsector + 4] ; sector hi
xor ecx, ecx mov edx, [userdata]
imul edx, eax, 512 mul [edx + FILE_DISK.Logical]
mov ecx, edx
mov edx, eax
;DEBUGF 1, "lseek to: %x\n", edx ;DEBUGF 1, "lseek to: %x\n", edx
mov eax, [userdata] mov eax, [userdata]
mov ebx, [eax + FILE_DISK.fd] mov ebx, [eax + FILE_DISK.fd]
@ -110,8 +113,10 @@ proc disk_write stdcall, userdata, buffer, startsector:qword, numsectors
pushad pushad
mov eax, dword[startsector + 0] ; sector lo mov eax, dword[startsector + 0] ; sector lo
mov edx, dword[startsector + 4] ; sector hi mov edx, dword[startsector + 4] ; sector hi
xor ecx, ecx mov edx, [userdata]
imul edx, eax, 512 mul [edx + FILE_DISK.Logical]
mov ecx, edx
mov edx, eax
;DEBUGF 1, "lseek to: %x\n", ecx ;DEBUGF 1, "lseek to: %x\n", ecx
mov eax, [userdata] mov eax, [userdata]
mov ebx, [eax + FILE_DISK.fd] mov ebx, [eax + FILE_DISK.fd]

View File

@ -84,7 +84,7 @@ struct f70s5arg {
#define KF_FOLDER 0x10 #define KF_FOLDER 0x10
uint32_t kos_time_to_epoch(uint32_t *time); uint32_t kos_time_to_epoch(uint32_t *time);
void *kos_fuse_init(int fd, uint32_t sect_cnt); void *kos_fuse_init(int fd, uint32_t sect_cnt, uint32_t sect_sz);
int kos_fuse_lfn(void *f70arg); int kos_fuse_lfn(void *f70arg);
#endif #endif