From 2d91384197847a7e8fe2c3f548918a8277d3086d Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 18 Sep 2018 03:03:28 +0200 Subject: sysfs, errno, improve foolshell, etc --- fs/sysfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 fs/sysfs.c (limited to 'fs/sysfs.c') diff --git a/fs/sysfs.c b/fs/sysfs.c new file mode 100644 index 0000000..57a56c8 --- /dev/null +++ b/fs/sysfs.c @@ -0,0 +1,46 @@ +#include "mount.h" +#include "sysfs.h" + +#include "mem.h" +#include "kmalloc.h" +#include "mount.h" + +#include "log.h" + +#include "lib/string/string.h" + +static const char* names[] = {"/mem","/kmalloc","/mount"}; +static uint32_t map[]={mem_sysfs,kmalloc_sysfs,mount_sysfs}; +static uint32_t count=3; + + +/* mount interface */ + +fd sysfs_file_open(mount *m,char *path) +{ + klog("sysfs file open: %s",path); + for (int i=0;i=count)return 0; + memcpy(dirs->name,names[*pos],strlen(names[*pos])+1); + *pos+=1; + return 1; +} + +void sysfs_mount(char* path) +{ + mount m; + m.type=MOUNT_TYPE_SYS; + memcpy(m.path,path,strlen(path)+1); + m.mount_file_open=sysfs_file_open; + m.mount_read_dir=sysfs_read_dir; + mount_add(m); +} -- cgit v1.2.3