Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int *ptr = f->esp;
- switch (*ptr) {
- case SYS_HALT: {
- halt();
- break;
- }
- case SYS_CREATE: {
- ptr = ptr + 4;
- char nameOfFile = *((char**)(ptr));
- ptr = ptr + 4;
- int sizeOfFile = *((int*))ptr));
- f->eax = create(nameOfFile, sizeOfFile);
- break;
- }
- case SYS_OPEN: {
- ptr = ptr + 4;
- char *nameOfFile1 = *((char**)(ptr));
- f->eax = open(nameOfFile);
- break;
- }
- case SYS_CLOSE: {
- ptr = ptr + 4:
- int fd = *((int*)(ptr));
- close(fd);
- break;
- }
- case SYS_READ: {
- ptr = ptr + 4;
- int readFd = *((int*))ptr));
- ptr = ptr + 4;
- void *readBuffer = *((void**)ptr);
- ptr = ptr + 4;
- int sizeOfBuffer = *((int*)(ptr));
- f->eax = read(readFd, readBuffer, sizeOfBuffer);
- break;
- }
- case SYS_WRITE: {
- ptr = ptr + 4;
- int writeFd = *((int*))ptr));
- ptr = ptr + 4;
- void *writeBuffer = ((void**)ptr);
- ptr = ptr + 4;
- int sizeOfWrBuffer = *(int*)(ptr)
- f->eax = write(writeFd, writeBuffer, sizeOfWrBuffer);
- break;
- }
- case SYS_EXIT: {
- exit(0);
- break;
- }
- }
- }
- void halt(void) {
- power_off();
- }
- bool create(const char *file, unsigned intitial_size) {
- return filesys_create(file, intitial_size);
- }
- int open(const char *file) {
- struct file *newFile = filesys_open(file);
- if(newFile != NULL) {
- for(int i = 2; i < 128; i++) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement