[RFC PATCH 00/19] Rust abstractions for VFS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wedson Almeida Filho <walmeida@xxxxxxxxxxxxx>

This series introduces Rust abstractions that allow page-cache-backed read-only
file systems to be written in Rust.

There are two file systems that are built on top of these abstractions: tarfs
and puzzlefs. The former has zero unsafe blocks and is included as a patch in
this series; the latter is described elsewhere [1]. We limit the functionality
to the bare minimum needed to implement them.

Rust file system modules can be declared with the `module_fs` macro and are
required to implement the following functions (which are part of the
`FileSystem` trait):

impl FileSystem for MyFS {
    fn super_params(sb: &NewSuperBlock<Self>) -> Result<SuperParams<Self::Data>>;
    fn init_root(sb: &SuperBlock<Self>) -> Result<ARef<INode<Self>>>;
    fn read_dir(inode: &INode<Self>, emitter: &mut DirEmitter) -> Result;
    fn lookup(parent: &INode<Self>, name: &[u8]) -> Result<ARef<INode<Self>>>;
    fn read_folio(inode: &INode<Self>, folio: LockedFolio<'_>) -> Result;
}

They can optionally implement the following:

fn read_xattr(inode: &INode<Self>, name: &CStr, outbuf: &mut [u8]) -> Result<usize>;
fn statfs(sb: &SuperBlock<Self>) -> Result<Stat>;

They may also choose the type of the data they can attach to superblocks and/or
inodes.

There a couple of issues that are likely to lead to unsoundness that have to do
with the unregistration of file systems. I will send separate emails about
them.

A git tree is available here:
    git://github.com/wedsonaf/linux.git vfs

Web:
    https://github.com/wedsonaf/linux/commits/vfs

[1]: The PuzzleFS container filesystem: https://lwn.net/Articles/945320/

Wedson Almeida Filho (19):
  rust: fs: add registration/unregistration of file systems
  rust: fs: introduce the `module_fs` macro
  samples: rust: add initial ro file system sample
  rust: fs: introduce `FileSystem::super_params`
  rust: fs: introduce `INode<T>`
  rust: fs: introduce `FileSystem::init_root`
  rust: fs: introduce `FileSystem::read_dir`
  rust: fs: introduce `FileSystem::lookup`
  rust: folio: introduce basic support for folios
  rust: fs: introduce `FileSystem::read_folio`
  rust: fs: introduce `FileSystem::read_xattr`
  rust: fs: introduce `FileSystem::statfs`
  rust: fs: introduce more inode types
  rust: fs: add per-superblock data
  rust: fs: add basic support for fs buffer heads
  rust: fs: allow file systems backed by a block device
  rust: fs: allow per-inode data
  rust: fs: export file type from mode constants
  tarfs: introduce tar fs

 fs/Kconfig                        |    1 +
 fs/Makefile                       |    1 +
 fs/tarfs/Kconfig                  |   16 +
 fs/tarfs/Makefile                 |    8 +
 fs/tarfs/defs.rs                  |   80 ++
 fs/tarfs/tar.rs                   |  322 +++++++
 rust/bindings/bindings_helper.h   |   13 +
 rust/bindings/lib.rs              |    6 +
 rust/helpers.c                    |  142 ++++
 rust/kernel/error.rs              |    6 +-
 rust/kernel/folio.rs              |  214 +++++
 rust/kernel/fs.rs                 | 1290 +++++++++++++++++++++++++++++
 rust/kernel/fs/buffer.rs          |   60 ++
 rust/kernel/lib.rs                |    2 +
 rust/kernel/mem_cache.rs          |    2 -
 samples/rust/Kconfig              |   10 +
 samples/rust/Makefile             |    1 +
 samples/rust/rust_rofs.rs         |  154 ++++
 scripts/generate_rust_analyzer.py |    2 +-
 19 files changed, 2324 insertions(+), 6 deletions(-)
 create mode 100644 fs/tarfs/Kconfig
 create mode 100644 fs/tarfs/Makefile
 create mode 100644 fs/tarfs/defs.rs
 create mode 100644 fs/tarfs/tar.rs
 create mode 100644 rust/kernel/folio.rs
 create mode 100644 rust/kernel/fs.rs
 create mode 100644 rust/kernel/fs/buffer.rs
 create mode 100644 samples/rust/rust_rofs.rs


base-commit: b0bc357ef7a98904600826dea3de79c0c67eb0a7
-- 
2.34.1





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux