summaryrefslogtreecommitdiff
path: root/src/user/app/init/driver
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/init/driver')
-rw-r--r--src/user/app/init/driver/ansiterm.c12
-rw-r--r--src/user/app/init/driver/tmpfs.c9
2 files changed, 11 insertions, 10 deletions
diff --git a/src/user/app/init/driver/ansiterm.c b/src/user/app/init/driver/ansiterm.c
index 5daab41..0c720eb 100644
--- a/src/user/app/init/driver/ansiterm.c
+++ b/src/user/app/init/driver/ansiterm.c
@@ -84,10 +84,14 @@ void ansiterm_drv(void) {
break;
case VFSOP_WRITE:
- for (size_t i = 0; i < res.len; i++)
- in_char(buf[i]);
- /* if (pendingFlush) */ flush();
- _syscall_fs_respond(NULL, res.len, 0);
+ if (res.flags) {
+ _syscall_fs_respond(NULL, -1, 0);
+ } else {
+ for (size_t i = 0; i < res.len; i++)
+ in_char(buf[i]);
+ /* if (pendingFlush) */ flush();
+ _syscall_fs_respond(NULL, res.len, 0);
+ }
break;
default:
diff --git a/src/user/app/init/driver/tmpfs.c b/src/user/app/init/driver/tmpfs.c
index e4c079c..7bda37f 100644
--- a/src/user/app/init/driver/tmpfs.c
+++ b/src/user/app/init/driver/tmpfs.c
@@ -99,11 +99,7 @@ void tmpfs_drv(void) {
_syscall_fs_respond(NULL, -1, 0);
break;
}
- if (res.len == 0) {
- _syscall_fs_respond(NULL, 0, 0);
- break;
- }
- if (!ptr->buf) {
+ if (res.len > 0 && !ptr->buf) {
ptr->buf = malloc(256);
if (!ptr->buf) {
_syscall_fs_respond(NULL, -1, 0);
@@ -121,8 +117,9 @@ void tmpfs_drv(void) {
}
memcpy(ptr->buf + res.offset, buf, res.len);
- if (ptr->size < res.offset + res.len)
+ if ((res.flags & WRITE_TRUNCATE) || ptr->size < res.offset + res.len) {
ptr->size = res.offset + res.len;
+ }
_syscall_fs_respond(NULL, res.len, 0);
break;