-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,019 additions
and
1,204 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
# ASM_SRC = $(filter-out ramdisk.S, $(sort $(wildcard *.S))) | ||
C_SRC = $(sort $(wildcard *.c)) | ||
OBJ = $(patsubst %.S,%.o,$(ASM_SRC)) $(patsubst %.c,%.o,$(C_SRC)) | ||
OBJ = $(patsubst %.c,%.o,$(C_SRC)) | ||
|
||
all:$(OBJ) | ||
|
||
%.o:%.c | ||
${GCC} ${CFLAG} -c $< | ||
|
||
clean: | ||
$(shell rm *.o 2>/dev/null) | ||
$(shell rm *.o 2>/dev/null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "fs.h" | ||
#include "vfs.h" | ||
#include "mm.h" | ||
#include "string.h" | ||
#include "printk.h" | ||
#include "fat32.h" | ||
|
||
struct files_struct *file_init() { | ||
// todo: alloc pages for files_struct, and initialize stdin, stdout, stderr | ||
struct files_struct *ret = NULL; | ||
return ret; | ||
} | ||
|
||
uint32_t get_fs_type(const char *filename) { | ||
uint32_t ret; | ||
if (memcmp(filename, "/fat32/", 7) == 0) { | ||
ret = FS_TYPE_FAT32; | ||
} else if (memcmp(filename, "/ext2/", 6) == 0) { | ||
ret = FS_TYPE_EXT2; | ||
} else { | ||
ret = -1; | ||
} | ||
return ret; | ||
} | ||
|
||
int32_t file_open(struct file* file, const char* path, int flags) { | ||
file->opened = 1; | ||
file->perms = flags; | ||
file->cfo = 0; | ||
file->fs_type = get_fs_type(path); | ||
memcpy(file->path, path, strlen(path) + 1); | ||
|
||
if (file->fs_type == FS_TYPE_FAT32) { | ||
file->lseek = fat32_lseek; | ||
file->write = fat32_write; | ||
file->read = fat32_read; | ||
file->fat32_file = fat32_open_file(path); | ||
// todo: check if fat32_file is valid (i.e. successfully opened) and return | ||
} else if (file->fs_type == FS_TYPE_EXT2) { | ||
printk(RED "Unsupport ext2\n" CLEAR); | ||
return -1; | ||
} else { | ||
printk(RED "Unknown fs type: %s\n" CLEAR, path); | ||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.