summaryrefslogtreecommitdiff
path: root/src/init/fs/misc.c
diff options
context:
space:
mode:
authordzwdz2022-04-07 23:13:00 +0200
committerdzwdz2022-04-07 23:13:00 +0200
commit6152d11ae205d4b4a9f03574cfcb0c24cb54b4b5 (patch)
treeed8ddd0e03f6a730e396cb2877517d05d3954fd7 /src/init/fs/misc.c
parentab74da4bfff9d37b7b5f5f98bda7edfc2ebc3ea6 (diff)
init: two concurrent shells - serial & vga/ps2
Diffstat (limited to 'src/init/fs/misc.c')
-rw-r--r--src/init/fs/misc.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/init/fs/misc.c b/src/init/fs/misc.c
index ef064a2..2f02e09 100644
--- a/src/init/fs/misc.c
+++ b/src/init/fs/misc.c
@@ -47,14 +47,13 @@ static void fs_respond_delegate(struct fs_wait_response *res, handle_t delegate,
* ```
*/
static char buf[1024];
- int buf_size = 1024;
int size;
int ret;
switch (res->op) {
case VFSOP_READ:
// TODO instead of truncating the size, allocate a bigger buffer
- size = res->capacity < buf_size ? res->capacity : buf_size;
+ size = res->capacity < sizeof(buf) ? res->capacity : sizeof(buf);
ret = _syscall_read(delegate, buf, size, res->offset);
_syscall_fs_respond(buf, ret);
break;
@@ -74,17 +73,16 @@ static void fs_respond_delegate(struct fs_wait_response *res, handle_t delegate,
void fs_passthru(const char *prefix) {
struct fs_wait_response res;
- int buf_size = 64; // TODO just use sizeof...
- char buf[ 64];
+ static char buf[1024];
int ret, prefix_len;
if (prefix) prefix_len = strlen(prefix);
- while (!_syscall_fs_wait(buf, buf_size, &res)) {
+ while (!_syscall_fs_wait(buf, sizeof(buf), &res)) {
switch (res.op) {
case VFSOP_OPEN:
if (prefix) {
/* special case: rewriting the path */
- if (prefix_len + res.len <= buf_size) {
+ if (prefix_len + res.len <= sizeof(buf)) {
// TODO memmove
char tmp[64];
memcpy(tmp, buf, res.len);
@@ -117,11 +115,10 @@ void fs_dir_inject(const char *path) {
struct fs_wait_response res;
struct fs_dir_handle handles[16]; // TODO hardcoded FD_MAX - use malloc instead
int handle_next = 0;
- int buf_size = 64;
- char buf[ 64];
+ static char buf[1024];
int ret;
- while (!_syscall_fs_wait(buf, buf_size, &res)) {
+ while (!_syscall_fs_wait(buf, sizeof buf, &res)) {
switch (res.op) {
case VFSOP_OPEN:
if (handle_next > 15) _syscall_fs_respond(NULL, -2); // we ran out of handles, which is entirely our fault.
@@ -153,7 +150,7 @@ void fs_dir_inject(const char *path) {
buf[out_len++] = '\0';
if (h.delegate >= 0) {
- int to_read = res.capacity < buf_size ? res.capacity : buf_size;
+ int to_read = res.capacity < sizeof(buf) ? res.capacity : sizeof(buf);
to_read -= out_len;
ret = _syscall_read(h.delegate, buf + out_len, to_read, 0);
if (ret > 0) out_len += ret;