Add close, add filesystem code to main kernel for hardware testing
This commit is contained in:
@@ -20,9 +20,21 @@ size_t fat32_file_write(int8_t fd, const void* buf, size_t nbytes) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* file_close
|
||||
* DESCRIPTION: close device abstracted as file
|
||||
* INPUTS: fd -- file descriptor for file to be closed
|
||||
* OUTPUTS: none
|
||||
* RETURN VALUE: none
|
||||
* SIDE EFFECTS: none
|
||||
*/
|
||||
int8_t fat32_file_close(int8_t fd) {
|
||||
(void)fd;
|
||||
return -1;
|
||||
struct pcb* pcb;
|
||||
pcb = get_pcb_ptr();
|
||||
|
||||
/* update pcb to remove process */
|
||||
pcb->file_desc_array[fd].flags = !IN_USE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t fat32_file_open(const char* filename) {
|
||||
@@ -64,7 +76,6 @@ int8_t fat32_file_open(const char* filename) {
|
||||
|
||||
size_t fat32_file_read(int8_t fd, void* buf, size_t nbytes) {
|
||||
uint16_t i;
|
||||
uint8_t error;
|
||||
size_t offset;
|
||||
size_t leftover_length;
|
||||
size_t bytes_read = 0;
|
||||
|
||||
@@ -21,6 +21,9 @@ void handle_rtc_interrupt() {
|
||||
char buf[128];
|
||||
|
||||
int main() {
|
||||
int8_t fd;
|
||||
size_t nbytes, i;
|
||||
|
||||
cputs("Kernel\n");
|
||||
|
||||
cputs("Init Mapper\n");
|
||||
@@ -49,17 +52,19 @@ int main() {
|
||||
|
||||
fat32_init();
|
||||
|
||||
terminal_open(NULL);
|
||||
terminal_write(0, "Terminal Write\n", 15);
|
||||
/* This is what is going to be part of open */
|
||||
fd = fat32_file_open("VERYLA~1TXT");
|
||||
cprintf("fd: %x\n", fd);
|
||||
|
||||
while(1) {
|
||||
if (terminal_read(0, buf, 128)) {
|
||||
cprintf("Fail\n");
|
||||
break;
|
||||
nbytes = fat32_file_read(fd, buf, 23);
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
cprintf("%c", buf[i]);
|
||||
}
|
||||
|
||||
while ((nbytes = fat32_file_read(fd, buf, 128))){
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
cprintf("%c", buf[i]);
|
||||
}
|
||||
terminal_write(0, "Got: ", 5);
|
||||
terminal_write(0, buf, strlen(buf));
|
||||
terminal_write(0, "\n", 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -34,11 +34,10 @@ struct pcb {
|
||||
struct file_desc file_desc_array[FILE_DESC_SIZE];
|
||||
int32_t is_vidmapped;
|
||||
uint8_t args[128];
|
||||
uint32_t execute_return;
|
||||
int32_t pid;
|
||||
int32_t parent_pid;
|
||||
uint32_t parent_esp;
|
||||
uint32_t parent_ebp;
|
||||
uint16_t execute_return;
|
||||
uint16_t pid;
|
||||
uint16_t parent_pid;
|
||||
uint16_t parent_esp;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user