Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vfs abstractions and tarfs #1037

Draft
wants to merge 29 commits into
base: rust-next
Choose a base branch
from
Draft

Commits on Oct 18, 2023

  1. xattr: make the xattr array itself const

    As it is currently declared, the xattr_handler structs are const but the
    array containing their pointers is not. This patch makes it so that fs
    modules can place them in .rodata, which makes it harder for
    accidental/malicious modifications at runtime.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    a3fe8d8 View commit details
    Browse the repository at this point in the history
  2. rust: introduce InPlaceModule

    This allows modules to be initialised in-place in pinned memory, which
    enables the usage of pinned types (e.g., mutexes, spinlocks, driver
    registrations, etc.) in modules without any extra allocations.
    
    Drivers that don't need this may continue to implement `Module` without
    any changes.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    484ec70 View commit details
    Browse the repository at this point in the history
  3. samples: rust: add in-place initialisation sample

    This is a modified version of rust_minimal that is initialised in-place.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    da1a2b6 View commit details
    Browse the repository at this point in the history
  4. rust: add the container_of macro

    This is the Rust version of the macro with the same name in C. It
    produces a raw pointer to an outer type from a pointer to an inner
    field.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    883e433 View commit details
    Browse the repository at this point in the history
  5. rust: init: introduce Opaque::try_ffi_init

    We'll need it, for example, when calling `register_filesystem` to
    initialise a file system registration.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    14513c0 View commit details
    Browse the repository at this point in the history
  6. rust: time: introduce time module

    It only contains the bare minimum to implement inode timestamps.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    c7d0fb2 View commit details
    Browse the repository at this point in the history
  7. rust: types: add little-endian type

    It allows us to read/write data in little-endian format. Compared to
    just using the correctly-sized integer type, it has the advantage of
    forcing users to convert to and from little endian format (which will be
    no-ops in little-endian architectures).
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    ca4a93c View commit details
    Browse the repository at this point in the history
  8. rust: types: introduce FromBytes trait

    If a type `T` implements this trait, it's possible to safely get a
    shared reference to a `T` from a byte slice.
    
    This commit also provides a macro that allows the automatic derivation
    of `FromBytes` for simple structs whose fields all implement `FromBytes`
    as well.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    a44bdcc View commit details
    Browse the repository at this point in the history
  9. rust: mem_cache: introduce MemCache

    This is just the basics of `kmem_cache` to be used in file systems for
    inodes. All dead-code annotations will be removed in the next commit.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    caf9b29 View commit details
    Browse the repository at this point in the history
  10. kbuild: rust: allow modules to allocate memory

    The `allocator_api` feature is needed by drivers that allocate memory.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    b0bc357 View commit details
    Browse the repository at this point in the history
  11. rust: fs: add registration/unregistration of file systems

    Allow basic registration and unregistration of Rust file system types.
    Unregistration happens automatically when a registration variable is
    dropped (e.g., when it goes out of scope).
    
    File systems registered this way are visible in `/proc/filesystems` but
    cannot be mounted yet because `init_fs_context` fails.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    528babd View commit details
    Browse the repository at this point in the history
  12. rust: fs: introduce the module_fs macro

    Simplify the declaration of modules that only expose a file system type.
    They can now do it using the `module_fs` macro.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    e909f43 View commit details
    Browse the repository at this point in the history
  13. samples: rust: add initial ro file system sample

    Introduce a basic sample that for now only registers the file system and
    doesn't really provide any functionality beyond having it listed in
    `/proc/filesystems`. New functionality will be added to the sample in
    subsequent patches as their abstractions are introduced.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    ad07f4b View commit details
    Browse the repository at this point in the history
  14. rust: fs: introduce FileSystem::super_params

    Allow Rust file systems to initialise superblocks, which allows them
    to be mounted (though they are still empty).
    
    Some scaffolding code is added to create an empty directory as the root.
    It is replaced by proper inode creation in a subsequent patch in this
    series.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    626056a View commit details
    Browse the repository at this point in the history
  15. rust: fs: introduce INode<T>

    Allow Rust file systems to handle typed and ref-counted inodes.
    
    This is in preparation for creating new inodes (for example, to create
    the root inode of a new superblock), which comes in the next patch in
    the series.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    a448dc5 View commit details
    Browse the repository at this point in the history
  16. rust: fs: introduce FileSystem::init_root

    Allow Rust file systems to specify their root directory. Also allow them
    to create (and do cache lookups of) directory inodes. (More types of
    inodes are added in subsequent patches in the series.)
    
    The `NewINode` type ensures that a new inode is properly initialised
    before it is marked so. It also facilitates error paths by automatically
    marking inodes as failed if they're not properly initialised.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    b26f77a View commit details
    Browse the repository at this point in the history
  17. rust: fs: introduce FileSystem::read_dir

    Allow Rust file systems to report the contents of their directory
    inodes. The reported entries cannot be opened yet.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    ac0f637 View commit details
    Browse the repository at this point in the history
  18. rust: fs: introduce FileSystem::lookup

    Allow Rust file systems to create inodes that are children of a
    directory inode when they're looked up by name.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    14b32d0 View commit details
    Browse the repository at this point in the history
  19. rust: folio: introduce basic support for folios

    Allow Rust file systems to handle ref-counted folios.
    
    Provide the minimum needed to implement `read_folio` (part of `struct
    address_space_operations`) in read-only file systems and to read
    uncached blocks.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    5e601b9 View commit details
    Browse the repository at this point in the history
  20. rust: fs: introduce FileSystem::read_folio

    Allow Rust file systems to create regular file inodes backed by the page
    cache. The contents of such files are read into folios via `read_folio`.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    c02d2b9 View commit details
    Browse the repository at this point in the history
  21. rust: fs: introduce FileSystem::read_xattr

    Allow Rust file systems to expose xattrs associated with inodes.
    `overlayfs` uses an xattr to indicate that a directory is opaque (i.e.,
    that lower layers should not be looked up). The planned file systems
    need to support opaque directories, so they must be able to implement
    this.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    ce0acb6 View commit details
    Browse the repository at this point in the history
  22. rust: fs: introduce FileSystem::statfs

    Allow Rust file systems to expose their stats. `overlayfs` requires that
    this be implemented by all file systems that are part of an overlay.
    The planned file systems need to be overlayed with overlayfs, so they
    must be able to implement this.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    3f94966 View commit details
    Browse the repository at this point in the history
  23. rust: fs: introduce more inode types

    Allow Rust file system modules to create inodes that are symlinks,
    pipes, sockets, char devices and block devices (in addition to the
    already-supported directories and regular files).
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    6032d93 View commit details
    Browse the repository at this point in the history
  24. rust: fs: add per-superblock data

    Allow Rust file systems to associate [typed] data to super blocks when
    they're created. Since we only have a pointer-sized field in which to
    store the state, it must implement the `ForeignOwnable` trait.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    1cf6e5e View commit details
    Browse the repository at this point in the history
  25. rust: fs: add basic support for fs buffer heads

    Introduce the abstractions that will be used by modules to handle buffer
    heads, which will be used to access cached blocks from block devices.
    
    All dead-code annotations are removed in the next commit in the series.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    516d0e4 View commit details
    Browse the repository at this point in the history
  26. rust: fs: allow file systems backed by a block device

    Allow Rust file systems that are backed by block devices (in addition to
    in-memory ones).
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    0605dba View commit details
    Browse the repository at this point in the history
  27. rust: fs: allow per-inode data

    Allow Rust file systems to attach extra [typed] data to each inode. If
    no data is needed, use the regular inode kmem_cache, otherwise we create
    a new one.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    b40e37b View commit details
    Browse the repository at this point in the history
  28. rust: fs: export file type from mode constants

    Allow Rust file system modules to use these constants if needed.
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    80fda66 View commit details
    Browse the repository at this point in the history
  29. tarfs: introduce tar fs

    It is a file system based on tar files and an index appended to them (to
    facilitate finding fs entries without having to traverse the whole tar
    file).
    
    Signed-off-by: Wedson Almeida Filho <[email protected]>
    wedsonaf committed Oct 18, 2023
    Configuration menu
    Copy the full SHA
    7189177 View commit details
    Browse the repository at this point in the history