diff --git a/c_build_helper.sh b/c_build_helper.sh index 842d0a1..8a97716 100644 --- a/c_build_helper.sh +++ b/c_build_helper.sh @@ -1,4 +1,4 @@ -CFLAGS="-g -c -m32 -fno-pie -mno-sse -O3 -D __bits__=32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-incompatible-pointer-types -Wno-address-of-packed-member -Wno-discarded-qualifiers -fno-stack-protector -mno-red-zone -mno-sse -mno-sse2 -ffreestanding -nostdlib -mno-mmx" +CFLAGS="-g -c -m32 -fno-pie -mno-sse -O3 -D __bits__=32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-incompatible-pointer-types -fno-stack-protector -mno-red-zone -mno-sse -mno-sse2 -ffreestanding -nostdlib -mno-mmx" LDFLAGS_i386="-Ttext 0xc0000000 --oformat binary -melf_i386" cd src/kernel/ diff --git a/src/kernel/system/ramfs.c b/src/kernel/system/ramfs.c index 11c7392..bb36440 100644 --- a/src/kernel/system/ramfs.c +++ b/src/kernel/system/ramfs.c @@ -5,7 +5,6 @@ #include "../shared/string.h" #define MODULE_NAME "KVFS" - fileops_t ramfs_ops = { ramfs_create, @@ -22,20 +21,55 @@ vfile_t root_dir = {"/", FS_FILE_IS_DIR | FS_FILE_SYSTEM, &ramfs_ops}; void ramfs_init(){ mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT); root_dir.private = kmalloc(1); - root_dir.size = 4096;//one page is 4096 bytes + root_dir.size = PAGE_SIZE_BYTES;//one page is 4096 bytes // printf("Sizeof VFILE_T: %d", sizeof(vfile_t)); } +vfile_t *search_dir(char *subname, vfile_t *directory){ + +} + //resolves the path relative to start vfile_t *resolve_path(char *pathname, vfile_t *start){ - // vfile_t **buffer = (vfile_t *)start->private; - // for(int i = 0; i < start->size/4, i++){ + const uint32_t MAX_TOKENS = PAGE_SIZE_BYTES/4; + + if(!start){ + return 0; + } + char *path = kmalloc(1); + strcpy(pathname, path); + + char **path_tokens = kmalloc(1); + uint32_t pathname_entries = 0; + char *pathtok = path; + char *i = path; + while (*i != '\0') { + if (*i == '/') { + *i = '\0'; + if (pathname_entries < MAX_TOKENS) { + path_tokens[pathname_entries++] = pathtok; + } + pathtok = i + 1; + } + i++; + } + if (pathname_entries < MAX_TOKENS) { + path_tokens[pathname_entries++] = pathtok; + } + + vfile_t **buffer = (vfile_t **)start->private; + printf("START\n"); + vfile_t *entry = start; + for(int i = 0; i < pathname_entries - 1; i++){ + printf("%s", path_tokens[i]); - // } + } + printf("END\n"); } + vfile_t *ramfs_create(char *path, FS_FILE_FLAGS flags){ - + resolve_path("test/test1/test2", &root_dir); return 0; }