diff --git a/.gitignore b/.gitignore index 6755ae5..4f24396 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.swp .vim +.exrc *.o kofu kofuse diff --git a/kofu.c b/kofu.c index 6c21bdf..2d6e4bb 100644 --- a/kofu.c +++ b/kofu.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -37,25 +38,49 @@ char **split_args(char *s) { return argv; } -void kofu_ls(char **arg) { - struct f70s1ret *dir = (struct f70s1ret*)malloc(sizeof(struct f70s1ret) + sizeof(struct bdfe) * DIRENTS_TO_READ); - struct f70s1arg f70 = {1, 0, CP866, DIRENTS_TO_READ, dir, 0, arg[1]}; +void ls_range(struct f70s1arg *f70) { + int status = kos_fuse_lfn(f70); +// printf("status = %d\n", status); + if (status == F70_SUCCESS || status == F70_END_OF_FILE) { + struct f70s1ret *dir = f70->buf; + for (size_t i = 0; i < dir->cnt; i++) { + printf("%s\n", dir->bdfes[i].name); + } + } +} + +void ls_all(struct f70s1arg *f70) { while (true) { - int status = kos_fuse_lfn(&f70); - printf("status = %d\n", status); - if (status != 0 && status != 6) { + int status = kos_fuse_lfn(f70); +// printf("status = %d\n", status); + if (status != F70_SUCCESS && status != F70_END_OF_FILE) { abort(); } - f70.offset += dir->cnt; + struct f70s1ret *dir = f70->buf; + f70->offset += dir->cnt; for (size_t i = 0; i < dir->cnt; i++) { printf("%s\n", dir->bdfes[i].name); } - if (status == 6) { + if (status == F70_END_OF_FILE) { break; } } +} + +void kofu_ls(char **arg) { + struct f70s1ret *dir = (struct f70s1ret*)malloc(sizeof(struct f70s1ret) + sizeof(struct bdfe) * DIRENTS_TO_READ); + struct f70s1arg f70 = {1, 0, CP866, DIRENTS_TO_READ, dir, 0, arg[1]}; + if (arg[2]) { + sscanf(arg[2], "%"SCNu32, &f70.size); + if (arg[3]) { + sscanf(arg[3], "%"SCNu32, &f70.offset); + } + ls_range(&f70); + } else { + ls_all(&f70); + } free(dir); return; } diff --git a/kofuse.c b/kofuse.c index 2e4aaaa..a8a685d 100644 --- a/kofuse.c +++ b/kofuse.c @@ -52,7 +52,7 @@ static int kofuse_getattr(const char *path, struct stat *stbuf, static int kofuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags) { - (void) offset; + (void) offset; // TODO (void) fi; (void) flags; diff --git a/kolibri.asm b/kolibri.asm index f85c4d8..f318763 100644 --- a/kolibri.asm +++ b/kolibri.asm @@ -44,10 +44,9 @@ kos_fuse_init: mov [file_disk.Sectors], eax mov [file_disk.Logical], 512 stdcall disk_add, disk_functions, disk_name, file_disk, DISK_NO_INSERT_NOTIFICATION - mov [disk], eax - stdcall disk_media_changed, [disk], 1 - - mov eax, [disk] + push eax + stdcall disk_media_changed, eax, 1 + pop eax mov eax, [eax + DISK.NumPartitions] pop ebp edi esi ebx @@ -279,7 +278,6 @@ ide_channel8_mutex MUTEX section '.bss' writeable align 16 file_disk FILE_DISK -disk dd ? alloc_base rb 8*1024*1024 IncludeUGlobals ; crap diff --git a/kolibri.h b/kolibri.h index 94a76e9..a873dc8 100644 --- a/kolibri.h +++ b/kolibri.h @@ -10,6 +10,22 @@ enum encoding { UTF8, }; +enum f70status { + F70_SUCCESS, + F70_DISK_BASE, + F70_UNSUPPORTED_FS, + F70_UNKNOWN_FS, + F70_PARTITION, + F70_FILE_NOT_FOUND, + F70_END_OF_FILE, + F70_MEMORY_POINTER, + F70_DISK_FULL, + F70_FS_FAIL, + F70_ACCESS_DENIED, + F70_DEVICE, + F70_OUT_OF_MEMORY, +}; + struct bdfe { uint32_t attr; uint32_t enc; diff --git a/test/t_ls b/test/t_ls index ba26ce4..380074c 100644 --- a/test/t_ls +++ b/test/t_ls @@ -1,4 +1,2 @@ -ls /hd0/1 ls /hd0/1/ -ls /hd0/1/123 -ls /hd0/1/123/ +ls /hd0/1/shortform/