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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a3fe8d8
xattr: make the xattr array itself const
wedsonaf Sep 29, 2023
484ec70
rust: introduce `InPlaceModule`
wedsonaf Sep 29, 2023
da1a2b6
samples: rust: add in-place initialisation sample
wedsonaf Sep 29, 2023
883e433
rust: add the `container_of` macro
wedsonaf Sep 29, 2023
14513c0
rust: init: introduce `Opaque::try_ffi_init`
wedsonaf Sep 29, 2023
c7d0fb2
rust: time: introduce `time` module
wedsonaf Sep 29, 2023
ca4a93c
rust: types: add little-endian type
wedsonaf Sep 29, 2023
a44bdcc
rust: types: introduce `FromBytes` trait
wedsonaf Sep 29, 2023
caf9b29
rust: mem_cache: introduce `MemCache`
wedsonaf Sep 29, 2023
b0bc357
kbuild: rust: allow modules to allocate memory
wedsonaf Sep 29, 2023
528babd
rust: fs: add registration/unregistration of file systems
wedsonaf Sep 29, 2023
e909f43
rust: fs: introduce the `module_fs` macro
wedsonaf Sep 29, 2023
ad07f4b
samples: rust: add initial ro file system sample
wedsonaf Sep 29, 2023
626056a
rust: fs: introduce `FileSystem::super_params`
wedsonaf Sep 29, 2023
a448dc5
rust: fs: introduce `INode<T>`
wedsonaf Sep 29, 2023
b26f77a
rust: fs: introduce `FileSystem::init_root`
wedsonaf Sep 29, 2023
ac0f637
rust: fs: introduce `FileSystem::read_dir`
wedsonaf Sep 29, 2023
14b32d0
rust: fs: introduce `FileSystem::lookup`
wedsonaf Sep 29, 2023
5e601b9
rust: folio: introduce basic support for folios
wedsonaf Sep 29, 2023
c02d2b9
rust: fs: introduce `FileSystem::read_folio`
wedsonaf Sep 29, 2023
ce0acb6
rust: fs: introduce `FileSystem::read_xattr`
wedsonaf Sep 29, 2023
3f94966
rust: fs: introduce `FileSystem::statfs`
wedsonaf Sep 29, 2023
6032d93
rust: fs: introduce more inode types
wedsonaf Sep 29, 2023
1cf6e5e
rust: fs: add per-superblock data
wedsonaf Sep 29, 2023
516d0e4
rust: fs: add basic support for fs buffer heads
wedsonaf Sep 29, 2023
0605dba
rust: fs: allow file systems backed by a block device
wedsonaf Sep 29, 2023
b40e37b
rust: fs: allow per-inode data
wedsonaf Sep 29, 2023
80fda66
rust: fs: export file type from mode constants
wedsonaf Sep 29, 2023
7189177
tarfs: introduce tar fs
wedsonaf Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ source "fs/sysv/Kconfig"
source "fs/ufs/Kconfig"
source "fs/erofs/Kconfig"
source "fs/vboxsf/Kconfig"
source "fs/tarfs/Kconfig"

endif # MISC_FILESYSTEMS

Expand Down
1 change: 1 addition & 0 deletions fs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ obj-$(CONFIG_EFIVAR_FS) += efivarfs/
obj-$(CONFIG_EROFS_FS) += erofs/
obj-$(CONFIG_VBOXSF_FS) += vboxsf/
obj-$(CONFIG_ZONEFS_FS) += zonefs/
obj-$(CONFIG_TARFS_FS) += tarfs/
16 changes: 16 additions & 0 deletions fs/tarfs/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0-only
#

config TARFS_FS
tristate "TAR file system support"
depends on RUST && BLOCK
select BUFFER_HEAD
help
This is a simple read-only file system intended for mounting
tar files that have had an index appened to them.

To compile this file system support as a module, choose M here: the
module will be called tarfs.

If you don't know whether you need it, then you don't need it:
answer N.
8 changes: 8 additions & 0 deletions fs/tarfs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the linux tarfs filesystem routines.
#

obj-$(CONFIG_TARFS_FS) += tarfs.o

tarfs-y := tar.o
80 changes: 80 additions & 0 deletions fs/tarfs/defs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// SPDX-License-Identifier: GPL-2.0

//! Definitions of tarfs structures.

use kernel::types::LE;

/// Flags used in [`Inode::flags`].
pub mod inode_flags {
/// Indicates that the inode is opaque.
///
/// When set, inode will have the "trusted.overlay.opaque" set to "y" at runtime.
pub const OPAQUE: u8 = 0x1;
}

kernel::derive_readable_from_bytes! {
/// An inode in the tarfs inode table.
#[repr(C)]
pub struct Inode {
/// The mode of the inode.
///
/// The bottom 9 bits are the rwx bits for owner, group, all.
///
/// The bits in the [`S_IFMT`] mask represent the file mode.
pub mode: LE<u16>,

/// Tarfs flags for the inode.
///
/// Values are drawn from the [`inode_flags`] module.
pub flags: u8,

/// The bottom 4 bits represent the top 4 bits of mtime.
pub hmtime: u8,

/// The owner of the inode.
pub owner: LE<u32>,

/// The group of the inode.
pub group: LE<u32>,

/// The bottom 32 bits of mtime.
pub lmtime: LE<u32>,

/// Size of the contents of the inode.
pub size: LE<u64>,

/// Either the offset to the data, or the major and minor numbers of a device.
///
/// For the latter, the 32 LSB are the minor, and the 32 MSB are the major numbers.
pub offset: LE<u64>,
}

/// An entry in a tarfs directory entry table.
#[repr(C)]
pub struct DirEntry {
/// The inode number this entry refers to.
pub ino: LE<u64>,

/// The offset to the name of the entry.
pub name_offset: LE<u64>,

/// The length of the name of the entry.
pub name_len: LE<u64>,

/// The type of entry.
pub etype: u8,

/// Unused padding.
pub _padding: [u8; 7],
}

/// The super-block of a tarfs instance.
#[repr(C)]
pub struct Header {
/// The offset to the beginning of the inode-table.
pub inode_table_offset: LE<u64>,

/// The number of inodes in the file system.
pub inode_count: LE<u64>,
}
}
Loading