| Crates.io | unpfs |
| lib.rs | unpfs |
| version | 0.13.0 |
| created_at | 2025-10-26 04:39:45.25518+00 |
| updated_at | 2025-10-29 00:46:16.132797+00 |
| description | An example filesystem built on top of the rs9p library |
| homepage | |
| repository | https://github.com/rs9p/rs9p |
| max_upload_size | |
| id | 1900944 |
| size | 45,008 |
Tokio-based asynchronous filesystems library using 9P2000.L protocol, an extended variant of 9P from Plan 9.
#![forbid(unsafe_code)] - no unsafe codeAdd to your Cargo.toml:
[dependencies]
rs9p = "0.5"
async-trait = "0.1"
tokio = { version = "1", features = ["full"] }
Implement the Filesystem trait:
use rs9p::{srv::{Filesystem, FId, srv_async}, Result, FCall, QId, QIdType};
use async_trait::async_trait;
#[derive(Clone)]
struct MyFs;
#[derive(Default)]
struct MyFId;
#[async_trait]
impl Filesystem for MyFs {
type FId = MyFId;
async fn rattach(
&self,
_fid: &FId<Self::FId>,
_afid: Option<&FId<Self::FId>>,
_uname: &str,
_aname: &str,
_n_uname: u32,
) -> Result<FCall> {
Ok(FCall::RAttach {
qid: QId {
typ: QIdType::DIR,
version: 0,
path: 0,
}
})
}
// Implement other methods...
}
#[tokio::main]
async fn main() -> Result<()> {
srv_async(MyFs, "tcp!127.0.0.1!564").await
}
See the Filesystem Trait Guide for complete examples.
unpfs is the reference implementation of a file server which exports your filesystem.
You can install unpfs from crates.io:
cargo install unpfs
or build it from source with the following commands:
git clone https://github.com/rs9p/rs9p
cd rs9p
cargo install crates/unpfs
and run unpfs with the following command to export ./testdir:
# Unix domain socket:
# port number is a suffix to the unix domain socket
# 'unix!/tmp/unpfs-socket!n' creates `/tmp/unpfs-socket:n`
unpfs 'unix!/tmp/unpfs-socket!0' testdir
You are now ready to import/mount the remote filesystem.
Let's mount it at ./mount:
# Unix domain socket
sudo mount -t 9p -o version=9p2000.L,trans=unix,uname=$USER /tmp/unpfs-socket:0 ./mount
The default transport is normally TCP, but the port its listening on is in the restricted range, which requires root permissions. That's why we started with the unix domain socket, because it's more likely to just work.
But TCP is obviously supported as well. Here's the same commands as above, but using TCP this time:
sudo unpfs 'tcp!0.0.0.0!564' testdir
# TCP
sudo mount -t 9p -o version=9p2000.L,trans=tcp,port=564,uname=$USER 127.0.0.1 ./mount
| Mount option | Value |
|---|---|
| version | must be "9p2000.L" |
| trans | an alternative v9fs transport. "tcp" or "unix" |
| port | port to connect to on the remote server |
| uname | user name to attempt mount as on the remote server |
See v9fs documentation for more details.
Contributions are welcome! Please:
cargo test, cargo clippy, and cargo fmt --check passEOPNOTSUPP - implement for production useSee the Filesystem Trait Guide for security best practices.
rs9p is distributed under the BSD 3-Clause License. See LICENSE for details.