aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/proc.c
diff options
context:
space:
mode:
authorMarvin Borner2021-02-07 00:54:21 +0100
committerMarvin Borner2021-02-07 00:54:21 +0100
commite5086811a048120d51add9bff9ba7a669fb582f5 (patch)
tree8ccf3b193df5213548fc36c88ab83ac99d5e8654 /kernel/features/proc.c
parent6944f48d30a581d437bc2c8f873a499291412bb7 (diff)
Fixed some memory leaks (broke some stuff too)
Diffstat (limited to 'kernel/features/proc.c')
-rw-r--r--kernel/features/proc.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 1a3c7e1..bec48fa 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -165,7 +165,7 @@ struct proc *proc_make(void)
return proc;
}
-u32 procfs_write(const char *path, void *buf, u32 offset, u32 count, struct device *dev)
+s32 procfs_write(const char *path, void *buf, u32 offset, u32 count, struct device *dev)
{
while (*path == '/')
path++;
@@ -184,7 +184,7 @@ u32 procfs_write(const char *path, void *buf, u32 offset, u32 count, struct devi
if (pid) {
struct proc *p = proc_from_pid(pid);
if (!p || path[0] != '/')
- return 0;
+ return -1;
path++;
if (!memcmp(path, "msg", 4)) {
@@ -194,10 +194,10 @@ u32 procfs_write(const char *path, void *buf, u32 offset, u32 count, struct devi
}
printf("%s - off: %d, cnt: %d, buf: %x, dev %x\n", path, offset, count, buf, dev);
- return 0;
+ return -1;
}
-u32 procfs_read(const char *path, void *buf, u32 offset, u32 count, struct device *dev)
+s32 procfs_read(const char *path, void *buf, u32 offset, u32 count, struct device *dev)
{
(void)dev;
@@ -218,7 +218,7 @@ u32 procfs_read(const char *path, void *buf, u32 offset, u32 count, struct devic
if (pid) {
struct proc *p = proc_from_pid(pid);
if (!p || path[0] != '/')
- return 0;
+ return -1;
path++;
if (!memcmp(path, "pid", 4)) {
@@ -243,10 +243,10 @@ u32 procfs_read(const char *path, void *buf, u32 offset, u32 count, struct devic
}
}
- return 0;
+ return -1;
}
-u32 procfs_ready(const char *path, struct device *dev)
+u8 procfs_ready(const char *path, struct device *dev)
{
(void)path;
(void)dev;
@@ -271,6 +271,7 @@ void proc_init(void)
vfs->read = procfs_read;
vfs->write = procfs_write;
vfs->ready = procfs_ready;
+ vfs->data = NULL;
struct device *dev = malloc(sizeof(*dev));
dev->name = "proc";
dev->type = DEV_CHAR;