Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixede ting som sagt til øvelserne + term

  • Loading branch information...
commit 854a532efadb973738ac34536a50f05634e4c027 1 parent 8e18a99
@ArvoX authored
View
2  buenos/fs/flatfs.h
@@ -47,7 +47,7 @@
#define FLATFS_BLOCK_SIZE 512
/* Magic number found on each flatfs filesystem's header block. */
-#define FLATFS_MAGIC 3745
+#define FLATFS_MAGIC 0x00BAB5E2
/* Block numbers for system blocks */
#define FLATFS_HEADER_BLOCK 0
View
10 buenos/proc/syscall.c
@@ -118,7 +118,7 @@ void syscall_handle(context_t *user_context)
break;
//else read file
default:
- length = vfs_read(fhandle, buffer, length);
+ length = vfs_read(fhandle - 3, buffer, length);
break;
}
user_context->cpu_regs[MIPS_REGISTER_V0] = length;
@@ -151,7 +151,7 @@ void syscall_handle(context_t *user_context)
}
//else write to file
default:
- length = vfs_write(fhandle, buffer, length);
+ length = vfs_write(fhandle - 3, buffer, length);
break;
}
user_context->cpu_regs[MIPS_REGISTER_V0] = length;
@@ -160,13 +160,13 @@ void syscall_handle(context_t *user_context)
case SYSCALL_OPEN:
{
char *path = (char*)user_context->cpu_regs[MIPS_REGISTER_A1];
- user_context->cpu_regs[MIPS_REGISTER_V0] = vfs_open(path);
+ user_context->cpu_regs[MIPS_REGISTER_V0] = vfs_open(path) + 3;
break;
}
case SYSCALL_CLOSE:
{
int filehandle = (int)user_context->cpu_regs[MIPS_REGISTER_A1];
- user_context->cpu_regs[MIPS_REGISTER_V0] = vfs_close(filehandle);
+ user_context->cpu_regs[MIPS_REGISTER_V0] = vfs_close(filehandle - 3);
break;
}
case SYSCALL_CREATE:
@@ -186,7 +186,7 @@ void syscall_handle(context_t *user_context)
{
int filehandle = (int)user_context->cpu_regs[MIPS_REGISTER_A1];
int offset = (int)user_context->cpu_regs[MIPS_REGISTER_A2];
- user_context->cpu_regs[MIPS_REGISTER_V0] = vfs_seek(filehandle, offset);
+ user_context->cpu_regs[MIPS_REGISTER_V0] = vfs_seek(filehandle - 3, offset);
break;
}
default:
View
14 buenos/tests/term.c
@@ -6,6 +6,7 @@ char* numbers = "0123456789";
void write(char *buf);
void writeInt(int i);
int strlen(char *buf);
+int strcmp(char *s1, char *s2);
int readline(char *buf, int len);
int main(void)
@@ -17,6 +18,8 @@ int main(void)
char buf[80];
if(readline(buf, 80))
{
+ if(strcmp(buf,"exit") == 0)
+ break;
int pid = syscall_exec(buf);
write("Starting ");
write(buf);
@@ -103,3 +106,14 @@ int readline(char *out, int len)
}
}
}
+
+int strcmp(char *s1, char *s2)
+{
+ int i;
+ for(i=0; s1[i] != '\0' && s2[i] != '\0'; i++)
+ if(s1[i] < s2i[i])
+ return -1;
+ else if(s1[i] > s2i[i])
+ return 1;
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.