Skip to content

Commit ad07f4b

Browse files
committed
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]>
1 parent e909f43 commit ad07f4b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

samples/rust/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ config SAMPLE_RUST_PRINT
4141

4242
If unsure, say N.
4343

44+
config SAMPLE_RUST_ROFS
45+
tristate "Read-only file system"
46+
help
47+
This option builds the Rust read-only file system sample.
48+
49+
To compile this as a module, choose M here:
50+
the module will be called rust_rofs.
51+
52+
If unsure, say N.
53+
4454
config SAMPLE_RUST_HOSTPROGS
4555
bool "Host programs"
4656
help

samples/rust/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
obj-$(CONFIG_SAMPLE_RUST_MINIMAL) += rust_minimal.o
44
obj-$(CONFIG_SAMPLE_RUST_INPLACE) += rust_inplace.o
55
obj-$(CONFIG_SAMPLE_RUST_PRINT) += rust_print.o
6+
obj-$(CONFIG_SAMPLE_RUST_ROFS) += rust_rofs.o
67

78
subdir-$(CONFIG_SAMPLE_RUST_HOSTPROGS) += hostprogs

samples/rust/rust_rofs.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
//! Rust read-only file system sample.
4+
5+
use kernel::prelude::*;
6+
use kernel::{c_str, fs};
7+
8+
kernel::module_fs! {
9+
type: RoFs,
10+
name: "rust_rofs",
11+
author: "Rust for Linux Contributors",
12+
description: "Rust read-only file system sample",
13+
license: "GPL",
14+
}
15+
16+
struct RoFs;
17+
impl fs::FileSystem for RoFs {
18+
const NAME: &'static CStr = c_str!("rust-fs");
19+
}

0 commit comments

Comments
 (0)