summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/fs/vfs.c6
-rw-r--r--kernel/random.c1
-rw-r--r--userland/libc/fcntl/open.c2
-rw-r--r--userland/libc/stdio/putchar.c2
-rw-r--r--userland/minibox/utilities/touch.c2
5 files changed, 9 insertions, 4 deletions
diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c
index 8ae2b1f..bcc0ce5 100644
--- a/kernel/fs/vfs.c
+++ b/kernel/fs/vfs.c
@@ -9,6 +9,10 @@ vfs_mounts_t mounts[10];
int num_mounts = 0;
vfs_fd_t *get_vfs_fd(int fd, process_t *p) {
+ if (fd < 0) {
+ return NULL;
+ }
+
if (!p) {
p = current_task;
}
@@ -265,7 +269,7 @@ int vfs_open(const char *file, int flags, int mode) {
vfs_resolve_path(file, resolved_path);
vfs_inode_t *inode = vfs_internal_open(resolved_path);
if (0 == inode) {
- if (mode & O_CREAT) {
+ if (flags & O_CREAT) {
if (vfs_create_file(resolved_path)) {
klog("VFS: File created", LOG_NOTE);
return vfs_open(file, flags, mode);
diff --git a/kernel/random.c b/kernel/random.c
index bb28606..38924ce 100644
--- a/kernel/random.c
+++ b/kernel/random.c
@@ -1,4 +1,5 @@
// FIXME: This is mostlikely incredibly inefficent and insecure.
+#include <assert.h>
#include <crypto/ChaCha20/chacha20.h>
#include <crypto/SHA1/sha1.h>
#include <crypto/xoshiro256plusplus/xoshiro256plusplus.h>
diff --git a/userland/libc/fcntl/open.c b/userland/libc/fcntl/open.c
index 37bb629..357d826 100644
--- a/userland/libc/fcntl/open.c
+++ b/userland/libc/fcntl/open.c
@@ -8,7 +8,7 @@ int open(const char *file, int flags, ...) {
if (flags & O_CREAT) {
va_list ap;
va_start(ap, flags);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, int);
va_end(ap);
}
RC_ERRNO(syscall(SYS_OPEN, file, flags, mode, 0, 0));
diff --git a/userland/libc/stdio/putchar.c b/userland/libc/stdio/putchar.c
index 3fcf7ca..7db6125 100644
--- a/userland/libc/stdio/putchar.c
+++ b/userland/libc/stdio/putchar.c
@@ -2,6 +2,6 @@
#include <unistd.h>
int putchar(int c) {
- printf("%c", (char)c);
+ write(1, (char *)&c, 1);
return c;
}
diff --git a/userland/minibox/utilities/touch.c b/userland/minibox/utilities/touch.c
index 949ad96..dd2f072 100644
--- a/userland/minibox/utilities/touch.c
+++ b/userland/minibox/utilities/touch.c
@@ -5,7 +5,7 @@ int touch_main(int argc, char **argv) {
if (argc < 2)
return 1;
int fd;
- COND_PERROR_EXP(open(argv[1], 0, O_CREAT), "open", return 1)
+ COND_PERROR_EXP(open(argv[1], O_CREAT, 0), "open", return 1)
close(fd);
return 0;
}