Implement read command, add test/t_read.
This commit is contained in:
19
README
19
README
@@ -1 +1,20 @@
|
|||||||
|
This is a common project for two related tools, kofuse and kofu. The idea is to
|
||||||
|
make UNIX tools that use unchanged KolibriOS dyndisk and fs source to test these
|
||||||
|
parts in native environment.
|
||||||
|
|
||||||
|
|
||||||
|
Kofuse
|
||||||
|
is a short for KolibriOS and FUSE [1].
|
||||||
|
|
||||||
|
|
||||||
|
Kofu
|
||||||
|
is Kolibri Filesystem in Userspace.
|
||||||
|
|
||||||
|
|
||||||
|
Architecture
|
||||||
|
|
||||||
|
|
||||||
Find img files here: https://baravy.by/kofuse/img/
|
Find img files here: https://baravy.by/kofuse/img/
|
||||||
|
|
||||||
|
|
||||||
|
[1] https://github.com/libfuse/libfuse
|
||||||
|
20
kocdecl.asm
20
kocdecl.asm
@@ -135,23 +135,21 @@ kos_fuse_read:
|
|||||||
|
|
||||||
mov edx, sf70_params
|
mov edx, sf70_params
|
||||||
mov dword[edx + 0x00], 0
|
mov dword[edx + 0x00], 0
|
||||||
mov eax, [esp + 0x20]
|
mov eax, [esp + 0x20] ; offset lo
|
||||||
mov dword[edx + 0x04], eax
|
mov dword[edx + 0x04], eax
|
||||||
mov dword[edx + 0x08], 0
|
mov dword[edx + 0x08], 0 ; offset hi
|
||||||
mov eax, [esp + 0x1c]
|
mov eax, [esp + 0x1c] ; size
|
||||||
mov dword[edx + 0x0c], eax
|
mov dword[edx + 0x0c], eax
|
||||||
mov eax, [esp + 0x18]
|
mov eax, [esp + 0x18] ; buf
|
||||||
mov dword[edx + 0x10], eax
|
mov dword[edx + 0x10], eax
|
||||||
mov eax, [esp + 0x14] ; path
|
mov eax, [esp + 0x14] ; path
|
||||||
inc eax ; skip '/'
|
mov byte[edx + 0x14], 0
|
||||||
mov [edx + 0x14], eax
|
mov [edx + 0x15], eax
|
||||||
|
|
||||||
mov ebp, [fs_struct]
|
|
||||||
mov ebx, sf70_params
|
mov ebx, sf70_params
|
||||||
mov esi, eax
|
pushad ; file_system_lfn writes here
|
||||||
push 0
|
call file_system_lfn
|
||||||
call xfs_Read
|
popad
|
||||||
pop eax
|
|
||||||
|
|
||||||
pop ebp edi esi ebx
|
pop ebp edi esi ebx
|
||||||
mov eax, 0
|
mov eax, 0
|
||||||
|
21
kofu.c
21
kofu.c
@@ -55,6 +55,23 @@ void kofu_stat(char **arg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kofu_read(char **arg) {
|
||||||
|
size_t size;
|
||||||
|
size_t offset;
|
||||||
|
sscanf(arg[2], "%zu", &size);
|
||||||
|
sscanf(arg[3], "%zu", &offset);
|
||||||
|
char *buf = (char*)malloc(size + 4096);
|
||||||
|
kos_fuse_read(arg[1], buf, size, offset);
|
||||||
|
for (size_t i = 0; i < size; i++) {
|
||||||
|
if (i % 32 == 0 && i != 0) {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
printf("%2.2x", buf[i]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct func_table {
|
struct func_table {
|
||||||
char *name;
|
char *name;
|
||||||
void (*func) (char **arg);
|
void (*func) (char **arg);
|
||||||
@@ -63,6 +80,7 @@ struct func_table {
|
|||||||
struct func_table funcs[] = {
|
struct func_table funcs[] = {
|
||||||
{ "ls", kofu_ls },
|
{ "ls", kofu_ls },
|
||||||
{ "stat", kofu_stat },
|
{ "stat", kofu_stat },
|
||||||
|
{ "read", kofu_read },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,9 +111,6 @@ int main(int argc, char **argv) {
|
|||||||
if (!strcmp(arg[0], ft->name)) {
|
if (!strcmp(arg[0], ft->name)) {
|
||||||
found = true;
|
found = true;
|
||||||
ft->func(arg);
|
ft->func(arg);
|
||||||
if (!is_tty) {
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
}
|
|
||||||
cmd_num++;
|
cmd_num++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
1
test/t_read
Normal file
1
test/t_read
Normal file
@@ -0,0 +1 @@
|
|||||||
|
read /hd0/1/123/two 2 2
|
Reference in New Issue
Block a user