diff options
| author | Miguel <m.i@gmx.at> | 2018-09-18 03:03:28 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-18 03:03:28 +0200 |
| commit | 2d91384197847a7e8fe2c3f548918a8277d3086d (patch) | |
| tree | 7c93404e290a0ffbdaf9a8a94766d7bd0fd6e4f2 /fs/sysfs.c | |
| parent | 06e6e427c76bdb88a7f72dd04411d95a4bda3270 (diff) | |
sysfs, errno, improve foolshell, etc
Diffstat (limited to 'fs/sysfs.c')
| -rw-r--r-- | fs/sysfs.c | 46 |
1 files changed, 46 insertions, 0 deletions
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;i++) + { + if(!strcmp(path,names[i])) + return fd_from_sysfs(map[i]); + } + return fd_from_sysfs(map[0]); +} + +int sysfs_read_dir(mount *m,char *path, fs_dirent *dirs, uint32_t *pos) +{ + if(*pos>=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); +} |
