diff options
author | dzwdz | 2021-08-17 23:24:08 +0200 |
---|---|---|
committer | dzwdz | 2021-08-17 23:24:08 +0200 |
commit | c9d4cf8572f8cbb0024bfa9802c25473f90e9d60 (patch) | |
tree | 4ec33eb94effe55e28e246d297e74d413eb40f29 | |
parent | 42e17f8877cc28e904c7a218e88de3fa2bc44d98 (diff) |
draft some of the spec for the new filesystem idea
-rw-r--r-- | docs/vfs.org | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/docs/vfs.org b/docs/vfs.org index fda0799..7312851 100644 --- a/docs/vfs.org +++ b/docs/vfs.org @@ -9,20 +9,40 @@ *** be the only abstraction for accessing resources / access control I don't really know how to explain this well (TODO). In short: the less shit there is to manage, the easier it is to manage. * operations -** creating filesystems - ~fs_t create_fs(struct fs_impl);~ - - ~fs_impl~ contains a bunch of function pointers to the implementations of the basic filesystem operations - so, all the functions mentioned in the file IO section. - +** mounting + ~void mount(path_t path, fd_t fd);~ - ~fs_t create_bind(path_t path);~ + Mounts ~fd~ over ~path~ (~path~ doesn't have to be a real directory/file!). The files previously accessible under ~path~ won't ever be accessible anymore to the process or any of its children. If the ~fd~ refers to a file/directory, a bind mount is created. The bind mount is a copy of the original mount, so it will persist even if the latter is gone. This means that you can e.g. mount a directory over ~/~ and it will work like a chroot. +** creating filesystems + ~fd_t fs_create(fs_handle_t *);~ + ~void fs_destroy(fs_handle_t *);~ - Creates a filesystem which is just a view of the current process' VFS at ~path~. Can be used for bind mounts. - note: This can be implemented fully in userland, using only ~create_fs()~. That doesn't mean that it's a good idea, the performance would be awful. -** mounting - ~void mount(path_t path, fs_t fs);~ + ~void fs_wait(fs_handle_t, fs_call_t *info);~ + Waits for a filesystem request, the details of which will be put in ~info~. - Mounts ~fs~ over ~path~ (which doesn't have to be a real directory/file!). The files that were previously accessible on ~path~ will NOT be accessible anymore. The calls to ~fs~ won't include the ~path~. ~path~ + ~void fs_respond(fs_call_t *info);~ + Responds to a filesystem request. +*** TODO more details +*** example + #+begin_src C +struct fs_call call; +fs_handle_t myfs_back; +fd_t myfs_front; + +myfs_front = fs_create(&myfs_back); +mount("/some/where", myfs_front); + +for (;;) { + fs_wait(myfs_back, &call); + switch (call.type) { + case FS_CLEANUP: + break; + default: + call.error = ENOTIMPLEMENTED; + } + fs_respond(&call); +} + #+end_src ** file IO ~fd_t open(path_t path);~ |