summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2013-05-20 17:52:01 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2013-05-20 17:52:01 +0200
commit3e51eabb1cb8ca35fa350c68fc4fddedc85daa84 (patch)
treeaf7b22f3851f673cfd0e5cdf2310800c1e68c1e8 /src/kernel
parent868c136fd4515a0497d362b11ca2cf99f28a4f4a (diff)
downloadTCE-3e51eabb1cb8ca35fa350c68fc4fddedc85daa84.tar.gz
TCE-3e51eabb1cb8ca35fa350c68fc4fddedc85daa84.zip
Minor modificiations ; added a simple Line EDitor.
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/mem/paging.cpp2
-rw-r--r--src/kernel/task/task.cpp5
-rw-r--r--src/kernel/vfs/node.h2
-rw-r--r--src/kernel/vfs/vfile.cpp14
-rw-r--r--src/kernel/vfs/vfile.h2
5 files changed, 19 insertions, 6 deletions
diff --git a/src/kernel/mem/paging.cpp b/src/kernel/mem/paging.cpp
index 03c6e2d..2ac190f 100644
--- a/src/kernel/mem/paging.cpp
+++ b/src/kernel/mem/paging.cpp
@@ -136,7 +136,7 @@ uint32_t paging_fault(registers *regs) {
}
if (seg == 0) {
- NL; WHERE; *ke_vt << "Unhandled Page Fault\t";
+ NL; WHERE; *ke_vt << "Unhandled Page Fault (PID " << current_thread->process->pid << ")\t";
*ke_vt << "cr2:" << addr;
NL; TAB;
if (regs->err_code & 0x1) *ke_vt << "present"; TAB;
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index 46fb4d4..4a802b8 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -116,11 +116,12 @@ uint32_t tasking_handleException(registers *regs) {
*ke_vt << "\nException in kernel. Stack trace:\n";
stack_trace(regs->ebp);
}
+ *ke_vt << "\n (PID " << current_thread->process->pid << ") ";
if (regs->int_no == 14) {
- *ke_vt << "\n>>> Process exiting.\n";
+ *ke_vt << ">>> Process exiting.\n";
thread_exit_stackJmp(EX_PR_EXCEPTION);
} else {
- *ke_vt << "\n>>> Thread exiting.\n";
+ *ke_vt << ">>> Thread exiting.\n";
thread_exit_stackJmp(EX_TH_EXCEPTION);
}
PANIC("This should never have happened. Please report this.");
diff --git a/src/kernel/vfs/node.h b/src/kernel/vfs/node.h
index b0ade41..c3b1585 100644
--- a/src/kernel/vfs/node.h
+++ b/src/kernel/vfs/node.h
@@ -28,7 +28,7 @@ class node {
virtual size_t get_size() { return 0; }
virtual int link(node* other, int mode) { return E_NOT_IMPLEMENTED; }
- // kind of like dynamic_cast'int these things
+ // kind of like dynamic_cast'ing these things
virtual display *as_display() { return 0; }
virtual vt *as_vt() { return 0; }
};
diff --git a/src/kernel/vfs/vfile.cpp b/src/kernel/vfs/vfile.cpp
index ff57c9e..38ea291 100644
--- a/src/kernel/vfs/vfile.cpp
+++ b/src/kernel/vfs/vfile.cpp
@@ -12,7 +12,19 @@ vfile::~vfile() {
if (own_data) kfree(data);
}
+int vfile::open(process *proc, int mode) {
+ if (mode & FM_TRUNC) {
+ if (own_data) kfree(data);
+ size = 0;
+ own_data = false;
+ data = 0;
+ }
+ return 0;
+}
+
int vfile::read(size_t offset, size_t len, char* buffer) {
+ if (size == 0) return 0;
+
if (offset + len > size) len = size - offset;
memcpy(buffer, data + offset, len);
return len;
@@ -22,7 +34,7 @@ int vfile::write(size_t offset, size_t len, char* buffer) {
size_t new_size = MAX(offset + len, size);
if (!own_data || new_size > size) {
char* new_data = (char*)kmalloc(new_size);
- memcpy(new_data, data, size);
+ if (size > 0) memcpy(new_data, data, size);
if (new_size > size) memset(new_data + size, 0, new_size - size);
if (own_data) kfree(data);
data = new_data;
diff --git a/src/kernel/vfs/vfile.h b/src/kernel/vfs/vfile.h
index 9b68b68..ffbccf9 100644
--- a/src/kernel/vfs/vfile.h
+++ b/src/kernel/vfs/vfile.h
@@ -13,7 +13,7 @@ class vfile : public node {
vfile(node* parent, char* data = 0, size_t size = 0);
virtual ~vfile();
- // TODO: handle open(TRUNC)
+ virtual int open(process *proc, int mode);
virtual int read(size_t offset, size_t len, char* buffer);
virtual int write(size_t offset, size_t len, char* buffer);
virtual size_t get_size() { return size; }